diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index f532dbd9e3b..87a87404d2e 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -1,7 +1,7 @@ name: Qodana on: schedule: - - cron: "0 20 * * *" + - cron: "0 20 * * 1,3,5" workflow_dispatch: branches: - develop @@ -9,6 +9,9 @@ on: # branches: # - develop +permissions: + contents: read + jobs: qodana: runs-on: ubuntu-latest @@ -18,7 +21,7 @@ jobs: fetch-depth: 1 #php-version: '7.1' - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2023.1.0 + uses: JetBrains/qodana-action@v2023.1.4 #with: # php-version: '7.1' env: diff --git a/.github/workflows/github_ci_php71_pgsql.yml b/.github/workflows/github_ci_php71_pgsql.yml new file mode 100644 index 00000000000..140fa0488f1 --- /dev/null +++ b/.github/workflows/github_ci_php71_pgsql.yml @@ -0,0 +1,362 @@ +name: GitHub CI PHP 7.1 Postgres + +on: + push: + branches: + - develop + - 1* + - 2* + pull_request: + types: [opened] + +permissions: + contents: read + +jobs: + github_ci_php71_pgsql: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password + ports: + - 32574:3306 + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + # git clone dolibarr into GITHUB_WORKSPACE = /home/runner/work/dolibarr/dolibarr + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Version PHP + run: | + php -i | head - + + - name: Install packages for PHP 7.1 + run: | + sudo composer self-update 2.2.18 + sudo chmod -R a+rwx /home/runner + composer -n config -g vendor-dir htdocs/includes + + sudo add-apt-repository -y ppa:ondrej/php + sudo apt-get update + sudo apt-get install -y pgloader memcached + sudo apt install apache2 php7.1 php7.1-cli php7.1-mysql php7.1-pgsql php7.1-gd php7.1-imap php7.1-intl php7.1-ldap php7.1-xml php7.1-mbstring php7.1-xml php7.1-zip libapache2-mod-php7.1 + sudo update-alternatives --set php /usr/bin/php7.1 + php -i | head - + + cd $GITHUB_WORKSPACE + ls $GITHUB_WORKSPACE + composer -n require --ignore-platform-reqs phpunit/phpunit ^7.5 \ + php-parallel-lint/php-parallel-lint ^1 \ + php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ + squizlabs/php_codesniffer ^3 + #For php7.3 + #composer -n require phpunit/phpunit ^7.5 \ + # php-parallel-lint/php-parallel-lint ^1.2 \ + # php-parallel-lint/php-console-highlighter ^0 \ + # php-parallel-lint/php-var-dump-check ~0.4 \ + # squizlabs/php_codesniffer ^3 + sudo rm -fr htdocs/includes/phpunit/php-code-coverage/src/Report/Html + + - name: Adding path of binaries tools installed by composer to the PATH + run: | + export PATH="$GITHUB_WORKSPACE/htdocs/includes/bin:$PATH" + echo $PATH + # We must have a directory bin created by the previous composer call + ls $GITHUB_WORKSPACE/htdocs/includes/bin + + - name: Version information + run: | + composer -V + # Check Parallel-lint version + echo "Parallel-lint version" + htdocs/includes/bin/parallel-lint -V + # Check PHP CodeSniffer version + echo "PHPCS version" + htdocs/includes/bin/phpcs --version | head - + htdocs/includes/bin/phpcs -i | head - + # Check PHP Vardump check version + echo "PHP Vardump check version" + htdocs/includes/bin/var-dump-check --version + # Check PHPUnit version + echo "PHPUnit version" + htdocs/includes/bin/phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check Database + echo "Database version" + mysql --version | head - + psql --version + echo "Check pgloader version" + pgloader --version + + - name: Create database + run: | + pwd + echo GITHUB_WORKSPACE = $GITHUB_WORKSPACE + sudo apt-get install -y mysql-client + mysql --version | head - + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SELECT VERSION();" | head - + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SHOW DATABASES" + echo "Drop and create database" + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'DROP DATABASE IF EXISTS travis;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8';' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password';" + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'FLUSH PRIVILEGES;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis -e "UPDATE llx_const set value = '0666' WHERE name = 'MAIN_UMASK';" + + #psql -c 'create database travis;' -U postgres + #psql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/dolibarr_src postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dest + ps fauxww | grep postgres + ls /etc/postgresql/14/main/ + sudo cat /etc/postgresql/14/main/pg_hba.conf + + sudo echo "local all postgres trust" > /etc/postgresql/14/main/pg_hba.conf + sudo echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/14/main/pg_hba.conf + sudo echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/14/main/pg_hba.conf + sudo echo "host all all ::1/128 trust" >> /etc/postgresql/14/main/pg_hba.conf + + sudo cat /etc/postgresql/14/main/pg_hba.conf + + sudo /etc/init.d/postgresql restart + + #$(PGPASSWORD="postgres"; psql -h 127.0.0.1 -p 5432 -U postgres -l -A) + psql -h 127.0.0.1 -p 5432 -U postgres -l -A + + echo sudo pgloader mysql://root:password@127.0.0.1/travis postgresql://postgres:postgres@127.0.0.1:5432/travis + sudo mkdir -p /tmp/pgloader + sudo chmod -R a+rwx /tmp/pgloader/ + sudo pgloader mysql://root:password@127.0.0.1/travis postgresql://postgres:postgres@127.0.0.1:5432/travis + echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql -U postgres travis + echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql -U postgres travis + # Create pgsql compatibility functions + psql -U postgres travis < htdocs/install/pgsql/functions/functions.sql + + - name: Generate Dolibarr conf file + run: | + export CONF_FILE=$GITHUB_WORKSPACE/htdocs/conf/conf.php + echo "Setting up Dolibarr $CONF_FILE" + echo ' $CONF_FILE + echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_document_root=\'/var/www/html\'';' >> $CONF_FILE + echo '$'dolibarr_main_data_root=\'/var/www/html/documents\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_user=\'root\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_pass=\'password\'';' >> $CONF_FILE + echo '$'dolibarr_main_instance_unique_id=\'travis1234567890\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_port=\'32574\'';' >> $CONF_FILE + echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE + cat $CONF_FILE + - name: Generate install.forced.php file to test installation + run: | + export INSTALL_FORCED_FILE=$GITHUB_WORKSPACE/htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + # For mysql + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + #echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'root\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'password\'';' >> $INSTALL_FORCED_FILE + # For mysql + echo '$'force_install_port=\'32574\'';' >> $INSTALL_FORCED_FILE + #echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'/var/www/html\'';' >> $INSTALL_FORCED_FILE + cat $INSTALL_FORCED_FILE + + - name: Create document directory + run: | + echo "Create documents directory and set permissions" + # and admin/temp subdirectory needed for unit tests + sudo mkdir -p /var/www/html/documents/admin/temp + sudo chmod -R a+rwx /var/www/html/documents + sudo echo "***** First line of dolibarr.log" > /var/www/html/documents/dolibarr.log + sudo chmod a+rwx /var/www/html/documents/dolibarr.log + + - name: Copy app into /var/www + run: | + sudo cp -r $GITHUB_WORKSPACE/htdocs/. /var/www/html + sudo mv /var/www/html/index.html /var/www/html/index.disabled.html + sudo ln -fs /var/www/html /var/www/htdocs + sudo cp -r $GITHUB_WORKSPACE/test/. /var/www/test + sudo cp -r $GITHUB_WORKSPACE/dev/. /var/www/dev + sudo cp -r $GITHUB_WORKSPACE/scripts/. /var/www/scripts + + - name: Setup Apache + run: | + pwd + whoami + # install apache web server + a2query -s + a2query -m + ls /etc/apache2/sites-available + #sudo cp -f $GITHUB_WORKSPACE/build/travis-ci/apache-githubaction.conf /etc/apache2/sites-available/000-default.conf + #sudo sed -e "s?%GITHUB_WORKSPACE%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + a2ensite 000-default + a2enmod php7.1 + ls /etc/apache2/sites-enabled + sudo adduser $(whoami) www-data + sudo adduser $(whoami) root + sudo adduser root www-data + sudo chown -R www-data:www-data /etc/apache2/sites-available/ + sudo chmod -R 777 /etc/apache2/sites-available/ + sudo chown -R www-data:www-data /var/www/html/ + ls -l /var/www/html + #ls -l /var/www/html/conf + #ls -l /var/www/html/install/ + set +e + sudo cat /etc/apache2/sites-enabled/000-default.conf + sudo service apache2 restart + curl -I localhost + - name: Chech Apache availability + run: | + echo "Checking webserver availability by a wget -O - --debug http://127.0.0.1" + # Ensure we stop on error with set -e + set +e + ls /var/log/apache2 + #wget -O - --debug http://127.0.0.1/robots.txt + # The wget should return a page with line ' + wget -O - --debug http://127.0.0.1 > $GITHUB_WORKSPACE/test.html 2>&1 + head -n 200 $GITHUB_WORKSPACE/test.html + + echo Logs are... + #sudo cat /tmp/install.log + sudo cat /var/log/apache2/access.log + sudo cat /var/log/apache2/error.log + sudo cat /var/log/apache2/other_vhosts_access.log + set +e + + - name: Upgrading Dolibarr + run: | + # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. + set -e + sudo chmod -R a+rwx $GITHUB_WORKSPACE + sudo chmod -R a+rwx /var/www + ls -l /var/www + cd /var/www/html/install + echo Execute upgrade, upgrade2 and step5 for each major version + php upgrade.php 3.5.0 3.6.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade350360.log + php upgrade2.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-3.log + php upgrade.php 3.6.0 3.7.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade360370.log + php upgrade2.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-3.log + php upgrade.php 3.7.0 3.8.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade370380.log + php upgrade2.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-3.log + php upgrade.php 3.8.0 3.9.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade380390.log + php upgrade2.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-3.log + php upgrade.php 3.9.0 4.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade390400.log + php upgrade2.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-3.log + php upgrade.php 4.0.0 5.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade400500.log + php upgrade2.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-3.log + php upgrade.php 5.0.0 6.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade500600.log + php upgrade2.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-3.log + php upgrade.php 7.0.0 8.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade700800.log + php upgrade2.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-2.log + php step5.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-3.log + php upgrade.php 9.0.0 10.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade9001000.log + php upgrade2.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-2.log + php step5.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-3.log + php upgrade.php 10.0.0 11.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade10001100.log + php upgrade2.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-2.log + php step5.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-3.log + php upgrade.php 11.0.0 12.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade11001200.log + php upgrade2.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-2.log + php step5.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-3.log + php upgrade.php 12.0.0 13.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade12001300.log + php upgrade2.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-2.log + php step5.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-3.log + php upgrade.php 13.0.0 14.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade13001400.log + php upgrade2.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-2.log + php step5.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-3.log + php upgrade.php 14.0.0 15.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade14001500.log + php upgrade2.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-2.log + php step5.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-3.log + php upgrade.php 15.0.0 16.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade15001600.log + php upgrade2.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-2.log + php step5.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-3.log + php upgrade.php 16.0.0 17.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade16001700.log + php upgrade2.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-2.log + php step5.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-3.log + php upgrade.php 17.0.0 18.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade17001800.log + php upgrade2.php 17.0.0 18.0.0 > $GITHUB_WORKSPACE/upgrade17001800-2.log + php step5.php 17.0.0 18.0.0 > $GITHUB_WORKSPACE/upgrade17001800-3.log + + - name: Result of migration scripts + if: always() + run: | + ls -alrt $GITHUB_WORKSPACE/ + + echo Show content of last file + cat "$(ls -rt $GITHUB_WORKSPACE/ | tail -n1)" + + - name: Enabling new modules + run: | + # Enable modules not enabled into original dump + set -e + cd /var/www/html/install + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE,MAIN_MODULE_EXPENSEREPORT > $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KNOWLEDGEMANAGEMENT,MAIN_MODULE_EVENTORGANIZATION,MAIN_MODULE_PARTNERSHIP >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_EMAILCOLLECTOR >> $GITHUB_WORKSPACE/enablemodule.log + echo $? + cd - + + - name: Result of migration scripts + if: always() + run: | + echo Show content of enablemodule.log file + cat $GITHUB_WORKSPACE/enablemodule.log + + - name: Unit testing + run: | + # Ensure we catch errors. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file. + set -e + cd /var/www/html + sudo chmod -R a+rwx /var/www/html/documents + includes/bin/phpunit -d memory_limit=-1 -c /var/www/test/phpunit/phpunittest.xml /var/www/test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" + set +e + diff --git a/.github/workflows/github_ci_php81_mysql.yml b/.github/workflows/github_ci_php81_mysql.yml new file mode 100644 index 00000000000..abe8b481245 --- /dev/null +++ b/.github/workflows/github_ci_php81_mysql.yml @@ -0,0 +1,332 @@ +name: GitHub CI PHP 8.1 MySQL + +on: + push: + branches: + - develop + - 1* + - 2* + pull_request: + types: [opened] + +permissions: + contents: read + +jobs: + github_ci_php81_mysql: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password + ports: + - 32574:3306 + + steps: + # git clone dolibarr into GITHUB_WORKSPACE = /home/runner/work/dolibarr/dolibarr + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Version PHP + run: | + php -i | head - + + - name: Install packages for PHP 8.1 + run: | + sudo composer self-update 2.2.18 + sudo chmod -R a+rwx /home/runner + composer -n config -g vendor-dir htdocs/includes + + sudo add-apt-repository -y ppa:ondrej/php + sudo apt-get update + sudo apt-get install -y pgloader memcached + sudo apt install apache2 php8.1 php8.1-cli php8.1-mysql php8.1-pgsql php8.1-gd php8.1-imap php8.1-intl php8.1-ldap php8.1-xml php8.1-mbstring php8.1-xml php8.1-zip libapache2-mod-php8.1 + sudo update-alternatives --set php /usr/bin/php8.1 + php -i | head - + + composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ + php-parallel-lint/php-parallel-lint ^1.2 \ + php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ + squizlabs/php_codesniffer ^3 + sudo rm -fr htdocs/includes/phpunit/php-code-coverage/src/Report/Html + + - name: Adding path of binaries tools installed by composer to the PATH + run: | + export PATH="$GITHUB_WORKSPACE/htdocs/includes/bin:$PATH" + echo $PATH + # We must have a directory bin created by the previous composer call + ls $GITHUB_WORKSPACE/htdocs/includes/bin + + - name: Version information + run: | + composer -V + # Check Parallel-lint version + echo "Parallel-lint version" + htdocs/includes/bin/parallel-lint -V + # Check PHP CodeSniffer version + echo "PHPCS version" + htdocs/includes/bin/phpcs --version | head - + htdocs/includes/bin/phpcs -i | head - + # Check PHP Vardump check version + echo "PHP Vardump check version" + htdocs/includes/bin/var-dump-check --version + # Check PHPUnit version + echo "PHPUnit version" + htdocs/includes/bin/phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check Database + echo "Database version" + mysql --version | head - + psql --version + echo "Check pgloader version" + pgloader --version + + - name: Create database + run: | + pwd + echo GITHUB_WORKSPACE = $GITHUB_WORKSPACE + sudo apt-get install -y mysql-client + mysql --version | head - + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SELECT VERSION();" | head - + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "SHOW DATABASES" + echo "Drop and create database" + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'DROP DATABASE IF EXISTS travis;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8';' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password';" + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e 'FLUSH PRIVILEGES;' + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -D travis -e "UPDATE llx_const set value = '0666' WHERE name = 'MAIN_UMASK';" + - name: Generate Dolibarr conf file + run: | + export CONF_FILE=$GITHUB_WORKSPACE/htdocs/conf/conf.php + echo "Setting up Dolibarr $CONF_FILE" + echo ' $CONF_FILE + echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_document_root=\'/var/www/html\'';' >> $CONF_FILE + echo '$'dolibarr_main_data_root=\'/var/www/html/documents\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_user=\'root\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_pass=\'password\'';' >> $CONF_FILE + echo '$'dolibarr_main_instance_unique_id=\'travis1234567890\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_port=\'32574\'';' >> $CONF_FILE + echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE + cat $CONF_FILE + - name: Generate install.forced.php file to test installation + run: | + export INSTALL_FORCED_FILE=$GITHUB_WORKSPACE/htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + # For mysql + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + #echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'root\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'password\'';' >> $INSTALL_FORCED_FILE + # For mysql + echo '$'force_install_port=\'32574\'';' >> $INSTALL_FORCED_FILE + #echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'/var/www/html\'';' >> $INSTALL_FORCED_FILE + cat $INSTALL_FORCED_FILE + + - name: Create document directory + run: | + echo "Create documents directory and set permissions" + # and admin/temp subdirectory needed for unit tests + sudo mkdir -p /var/www/html/documents/admin/temp + sudo chmod -R a+rwx /var/www/html/documents + sudo echo "***** First line of dolibarr.log" > /var/www/html/documents/dolibarr.log + sudo chmod a+rwx /var/www/html/documents/dolibarr.log + + - name: Copy app into /var/www + run: | + sudo cp -r $GITHUB_WORKSPACE/htdocs/. /var/www/html + sudo mv /var/www/html/index.html /var/www/html/index.disabled.html + sudo ln -fs /var/www/html /var/www/htdocs + sudo cp -r $GITHUB_WORKSPACE/test/. /var/www/test + sudo cp -r $GITHUB_WORKSPACE/dev/. /var/www/dev + sudo cp -r $GITHUB_WORKSPACE/scripts/. /var/www/scripts + + - name: Setup Apache + run: | + pwd + whoami + # install apache web server + a2query -s + a2query -m + ls /etc/apache2/sites-available + #sudo cp -f $GITHUB_WORKSPACE/build/travis-ci/apache-githubaction.conf /etc/apache2/sites-available/000-default.conf + #sudo sed -e "s?%GITHUB_WORKSPACE%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + a2ensite 000-default + a2enmod php8.1 + ls /etc/apache2/sites-enabled + sudo adduser $(whoami) www-data + sudo adduser $(whoami) root + sudo adduser root www-data + sudo chown -R www-data:www-data /etc/apache2/sites-available/ + sudo chmod -R 777 /etc/apache2/sites-available/ + sudo chown -R www-data:www-data /var/www/html/ + ls -l /var/www/html + #ls -l /var/www/html/conf + #ls -l /var/www/html/install/ + set +e + sudo cat /etc/apache2/sites-enabled/000-default.conf + sudo service apache2 restart + curl -I localhost + - name: Chech Apache availability + run: | + echo "Checking webserver availability by a wget -O - --debug http://127.0.0.1" + # Ensure we stop on error with set -e + set +e + ls /var/log/apache2 + #wget -O - --debug http://127.0.0.1/robots.txt + # The wget should return a page with line ' + wget -O - --debug http://127.0.0.1 > $GITHUB_WORKSPACE/test.html 2>&1 + head -n 200 $GITHUB_WORKSPACE/test.html + + echo Logs are... + #sudo cat /tmp/install.log + sudo cat /var/log/apache2/access.log + sudo cat /var/log/apache2/error.log + sudo cat /var/log/apache2/other_vhosts_access.log + set +e + + - name: Upgrading Dolibarr + run: | + # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. + set -e + sudo chmod -R a+rwx $GITHUB_WORKSPACE + sudo chmod -R a+rwx /var/www + ls -l /var/www + cd /var/www/html/install + echo Execute upgrade, upgrade2 and step5 for each major version + php upgrade.php 3.5.0 3.6.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade350360.log + php upgrade2.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $GITHUB_WORKSPACE/upgrade350360-3.log + php upgrade.php 3.6.0 3.7.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade360370.log + php upgrade2.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $GITHUB_WORKSPACE/upgrade360370-3.log + php upgrade.php 3.7.0 3.8.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade370380.log + php upgrade2.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $GITHUB_WORKSPACE/upgrade370380-3.log + php upgrade.php 3.8.0 3.9.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade380390.log + php upgrade2.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $GITHUB_WORKSPACE/upgrade380390-3.log + php upgrade.php 3.9.0 4.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade390400.log + php upgrade2.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $GITHUB_WORKSPACE/upgrade390400-3.log + php upgrade.php 4.0.0 5.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade400500.log + php upgrade2.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 > $GITHUB_WORKSPACE/upgrade400500-3.log + php upgrade.php 5.0.0 6.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade500600.log + php upgrade2.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 > $GITHUB_WORKSPACE/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $GITHUB_WORKSPACE/upgrade600700-3.log + php upgrade.php 7.0.0 8.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade700800.log + php upgrade2.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-2.log + php step5.php 7.0.0 8.0.0 > $GITHUB_WORKSPACE/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $GITHUB_WORKSPACE/upgrade800900-3.log + php upgrade.php 9.0.0 10.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade9001000.log + php upgrade2.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-2.log + php step5.php 9.0.0 10.0.0 > $GITHUB_WORKSPACE/upgrade9001000-3.log + php upgrade.php 10.0.0 11.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade10001100.log + php upgrade2.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-2.log + php step5.php 10.0.0 11.0.0 > $GITHUB_WORKSPACE/upgrade10001100-3.log + php upgrade.php 11.0.0 12.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade11001200.log + php upgrade2.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-2.log + php step5.php 11.0.0 12.0.0 > $GITHUB_WORKSPACE/upgrade11001200-3.log + php upgrade.php 12.0.0 13.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade12001300.log + php upgrade2.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-2.log + php step5.php 12.0.0 13.0.0 > $GITHUB_WORKSPACE/upgrade12001300-3.log + php upgrade.php 13.0.0 14.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade13001400.log + php upgrade2.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-2.log + php step5.php 13.0.0 14.0.0 > $GITHUB_WORKSPACE/upgrade13001400-3.log + php upgrade.php 14.0.0 15.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade14001500.log + php upgrade2.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-2.log + php step5.php 14.0.0 15.0.0 > $GITHUB_WORKSPACE/upgrade14001500-3.log + php upgrade.php 15.0.0 16.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade15001600.log + php upgrade2.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-2.log + php step5.php 15.0.0 16.0.0 > $GITHUB_WORKSPACE/upgrade15001600-3.log + php upgrade.php 16.0.0 17.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade16001700.log + php upgrade2.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-2.log + php step5.php 16.0.0 17.0.0 > $GITHUB_WORKSPACE/upgrade16001700-3.log + php upgrade.php 17.0.0 18.0.0 ignoredbversion > $GITHUB_WORKSPACE/upgrade17001800.log + php upgrade2.php 17.0.0 18.0.0 > $GITHUB_WORKSPACE/upgrade17001800-2.log + php step5.php 17.0.0 18.0.0 > $GITHUB_WORKSPACE/upgrade17001800-3.log + + - name: Result of migration scripts + if: always() + run: | + ls -alrt $GITHUB_WORKSPACE/ + + echo Show content of last file + cat "$(ls -rt $GITHUB_WORKSPACE/ | tail -n1)" + + - name: Enabling new modules + run: | + # Enable modules not enabled into original dump + set -e + cd /var/www/html/install + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE,MAIN_MODULE_EXPENSEREPORT > $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KNOWLEDGEMANAGEMENT,MAIN_MODULE_EVENTORGANIZATION,MAIN_MODULE_PARTNERSHIP >> $GITHUB_WORKSPACE/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_EMAILCOLLECTOR >> $GITHUB_WORKSPACE/enablemodule.log + echo $? + cd - + + - name: Result of migration scripts + if: always() + run: | + echo Show content of enablemodule.log file + cat $GITHUB_WORKSPACE/enablemodule.log + + - name: Unit testing + run: | + # Ensure we catch errors. Set this to +e instead of -e if you want to go to the end to see dolibarr.log file. + set -e + cd /var/www/html + sudo chmod -R a+rwx /var/www/html/documents + includes/bin/phpunit -d memory_limit=-1 -c /var/www/test/phpunit/phpunittest.xml /var/www/test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" + set +e + + - name: Code quality check - Lint + if: github.event_name == 'push' + run: | + htdocs/includes/bin/parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ + --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ + --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --exclude htdocs/includes/webklex --blame . + + - name: Code quality check - phpcs + if: github.event_name == 'push' + run: | + htdocs/includes/bin/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 .; + + - name: Code quality check - var-dump-check + if: github.event_name == 'push' + run: | + htdocs/includes/bin/var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php . + diff --git a/.gitignore b/.gitignore index 3315a7eed88..c01d2a6a788 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,10 @@ package-lock.json doc/install.lock /.asciidoctorconfig.adoc + +# Qodana +.idea/vcs.xml +.idea/modules.xml +.idea/workspace.xml +.idea/inspectionProfiles/Project_Default.xml +.idea/jsLinters/jshint.xml \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5551c6d1605..f1a3c3fb586 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,11 @@ # from Dolibarr GitHub repository. # For syntax, see https://docs.travis-ci.com/user/languages/php/ -# We use dist: bionic = 18.04 +# We use dist: bionic = 18.04, focal = 20.04 os: linux -dist: bionic +dist: focal -language: php +language: generic git: depth: 1 @@ -18,46 +18,25 @@ services: - postgresql -before_install: -- | - echo "Add ondrej PPA" - sudo add-apt-repository -y ppa:ondrej/php - sudo apt-get update - echo "Disabling Xdebug for composer" - export PHP_VERSION_NAME=$(phpenv version-name) - echo $PHP_VERSION_NAME - ls ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/ - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini - phpenv config-rm xdebug.ini - phpenv rehash - echo - -addons: +#addons: # Force postgresql version - postgresql: '10' - apt: - sources: - - sourceline: 'ppa:ondrej/php' - packages: + #postgresql: '10' + #apt: + #sources: + #- sourceline: 'ppa:ondrej/php' + #update: true + #packages: # We need a webserver to test the webservices # Let's install Apache with. - - apache2 + #- apache2 # We need pgloader for import mysql database into pgsql - - pgloader - - php - - php7.1-pgsql - - php7.1-mysqli - - php7.1-xml - - php7.1-intl - - php8.1-pgsql - - php8.1-mysqli - - php8.1-xml - - php8.1-intl - - php8.2-pgsql - - php8.2-mysqli - - php8.2-xml - - php8.2-intl - + #- pgloader + #- php8.1 + #- php8.1-pgsql + #- php8.1-mysqli + #- php8.1-xml + #- php8.1-intl + env: global: # Set to true for very verbose output @@ -71,15 +50,19 @@ jobs: - stage: PHP 7.0-8.1 if: type = push php: '7.1' - env: DB=postgresql + env: + - DB=postgresql + - TRAVIS_PHP_VERSION=7.1 - stage: PHP 7.0-8.1 if: type = pull_request OR type = push php: '8.1' - env: DB=mysql - - stage: PHP Dev - if: type = push AND branch = developdisabled - php: '8.2' - env: DB=mysql + env: + - DB=mysql + - TRAVIS_PHP_VERSION=8.1 + #- stage: PHP Dev + # if: type = push AND branch = developdisabled + # php: '8.2' + # env: DB=mysql notifications: email: @@ -93,22 +76,59 @@ notifications: use_notice: true +before_install: +- | + echo "Remove awful phpenv and install packages" + sudo rm -fr ~/.phpenv + sudo rm -fr /root/.phpenv + sudo add-apt-repository -y ppa:ondrej/php + sudo apt-get update + echo TRAVIS_PHP_VERSION=$TRAVIS_PHP_VERSION + +- | + echo Install packages for PHP + sudo apt-get install -y pgloader memcached + if [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then + sudo apt install unzip apache2 php7.1 php7.1-cli php7.1-curl php7.1-mysql php7.1-pgsql php7.1-gd php7.1-imap php7.1-intl php7.1-ldap php7.1-xml php7.1-mbstring php7.1-xml php7.1-zip libapache2-mod-php7.1 + fi + if [ "$TRAVIS_PHP_VERSION" = '8.1' ]; then + sudo apt install unzip apache2 php8.1 php8.1-cli php8.1-curl php8.1-mysql php8.1-pgsql php8.1-gd php8.1-imap php8.1-intl php8.1-ldap php8.1-xml php8.1-mbstring php8.1-xml php8.1-zip libapache2-mod-php8.1 + fi + +- | + echo Install packages for PHP + if [ "$DB" = 'postgresql' ]; then + psql -U postgres -h 127.0.0.1 -c 'create database travis_ci_test;' + psql -U postgres -h 127.0.0.1 -c 'create database travis;' + fi + install: +- | + if [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then + sudo update-alternatives --set php /usr/bin/php7.1 + fi + if [ "$TRAVIS_PHP_VERSION" = '8.1' ]; then + sudo update-alternatives --set php /usr/bin/php8.1 + fi + php -i | head - + - | echo "Updating Composer config" + curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php + HASH=`curl -sS https://composer.github.io/installer.sig` + echo $HASH + php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" + sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer + sudo chmod -R a+rwx /usr/local/bin/composer composer -V - #rm $TRAVIS_BUILD_DIR/composer.json - #rm $TRAVIS_BUILD_DIR/composer.lock - #composer -n init - #composer -n config vendor-dir htdocs/includes composer -n config -g vendor-dir htdocs/includes echo - | echo "Update Composer version and Install tools - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" - echo "(version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" + echo "(composer version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" if [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then - composer self-update 2.2.18 + sudo composer self-update 2.2.18 composer -n require phpunit/phpunit ^7.5 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -116,7 +136,7 @@ install: squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then - composer self-update 2.2.18 + sudo composer self-update 2.2.18 composer -n require phpunit/phpunit ^7.5 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -125,13 +145,14 @@ install: fi # phpunit 9 is required for php 8 if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer self-update 2.4.4 + sudo composer self-update 2.4.4 composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi + # Remove non expected files rm -fr /home/travis/build/Dolibarr/dolibarr/htdocs/includes/phpunit/php-code-coverage/src/Report/Html/Renderer/Template/js echo @@ -140,7 +161,7 @@ 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 ls $TRAVIS_BUILD_DIR/htdocs/includes/bin echo @@ -153,19 +174,6 @@ before_script: echo Home dir is `echo ~` echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR - - | - echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" - phpenv config-add /tmp/xdebug.ini - echo - - - | - echo "Setting up PHP" - echo - echo "Set timezone" - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - phpenv rehash - echo - - | echo "Versions information" echo @@ -195,11 +203,13 @@ before_script: # Check Database echo "Database version" mysql --version | head - - mysql -e "SELECT VERSION();" | head - psql --version if [ "$DB" = 'postgresql' ]; then echo "Check pgloader version" pgloader --version + ps fauxww | grep postgres + ls /etc/postgresql/13/main/ + sudo cat /etc/postgresql/11/main/pg_hba.conf fi echo @@ -208,7 +218,8 @@ before_script: if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then echo "MySQL" mysql -u root -e 'DROP DATABASE IF EXISTS travis;' - mysql -u root -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -u root -e 'CREATE DATABASE IF NOT EXISTS travis CHARACTER SET = 'utf8';' + mysql -u root -e "CREATE USER 'travis'@'127.0.0.1' IDENTIFIED BY 'password';" mysql -u root -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' mysql -u root -e 'FLUSH PRIVILEGES;' mysql -u root -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -217,10 +228,14 @@ before_script: #psql -c 'create database travis;' -U postgres #psql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql #pgloader mysql://root:pass@127.0.0.1/dolibarr_src postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dest - echo pgloader mysql://root@127.0.0.1/travis postgresql://postgres@/travis - pgloader mysql://root@127.0.0.1/travis postgresql://postgres@/travis + echo sudo pgloader mysql://root@127.0.0.1/travis postgresql://postgres:postgres@127.0.0.1:5432/travis + sudo mkdir -p /tmp/pgloader + sudo chmod -R a+rwx /tmp/pgloader/ + sudo pgloader mysql://root@127.0.0.1/travis postgresql://postgres:postgres@127.0.0.1:5432/travis echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql -U postgres travis echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql -U postgres travis + # Create pgsql compatibility functions + psql -U postgres travis < htdocs/install/pgsql/functions/functions.sql fi echo @@ -256,24 +271,24 @@ before_script: echo - - echo "Setting up Apache + FPM" + - echo "Setting up Apache" # setup link for php legacy - - sudo ln -s ~/.phpenv/versions/$(phpenv version-name)/bin/php /bin/php + #- sudo ln -s ~/.phpenv/versions/$(phpenv version-name)/bin/php /bin/php # install apache web server - - sudo apt-get install apache2 php-fpm php-mysql php-pgsql php-gd php-ldap php-xml php-mbstring libapache2-mod-php + #- sudo apt-get install apache2 php-fpm php-mysql php-pgsql php-gd php-ldap php-xml php-mbstring libapache2-mod-php # enable php-fpm - - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - # Copy the included pool - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf - fi - - sudo a2enmod proxy_fcgi rewrite setenvif cgi alias - - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + #- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf + #- | + # if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = '8.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + # # Copy the included pool + # sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf + # fi + #- sudo a2enmod proxy_fcgi rewrite setenvif cgi alias + #- echo "cgi.fix_pathinfo = 1" >> ~/.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 # start php-fpm - - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm + #- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm # 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 @@ -284,11 +299,11 @@ before_script: script: - | - echo "Checking webserver availability by a wget -O - http://127.0.0.1" + echo "Checking webserver availability by a wget -O - --debug http://127.0.0.1" # Ensure we stop on error with set -e set +e # The wget should return a page with line ' - wget -O - http://127.0.0.1 > test.html + wget -O - --debug http://127.0.0.1 > test.html head test.html sudo cat /var/log/apache2/travis_error_log set +e @@ -298,7 +313,6 @@ script: echo "Checking PHP syntax errors (only 1 version to not overload travis and avoid duplicate tests)" # Ensure we catch errors set -e - #parallel-lint --exclude htdocs/includes --blame . # Exclusions are defined in the ruleset.xml file if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ @@ -459,6 +473,9 @@ script: php upgrade2.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-2.log php step5.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-3.log ls -alrt $TRAVIS_BUILD_DIR/ + echo + #cat $TRAVIS_BUILD_DIR/upgrade17001800.log + #cat $TRAVIS_BUILD_DIR/upgrade17001800-2.log - | echo "Enabling new modules" @@ -468,6 +485,7 @@ script: php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KNOWLEDGEMANAGEMENT,MAIN_MODULE_EVENTORGANIZATION,MAIN_MODULE_PARTNERSHIP >> $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_EMAILCOLLECTOR >> $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e @@ -492,7 +510,7 @@ after_script: sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log echo "After script - Output last lines of apache error.log" sudo ls /var/log/apache2 - sudo tail -n 50 /var/log/apache2/travis_error_log + sudo tail -n 200 /var/log/apache2/travis_error_log after_success: - | @@ -510,14 +528,14 @@ after_failure: done # Show Apache log file echo "Debugging informations for file apache error.log" - sudo tail -n 50 /var/log/apache2/travis_error_log + sudo tail -n 200 /var/log/apache2/travis_error_log if [ "$DEBUG" = true ]; then # Dolibarr log file echo "Debugging informations for file dolibarr.log (latest 50 lines)" - tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + tail -n 200 $TRAVIS_BUILD_DIR/documents/dolibarr.log # Database log file echo "Debugging informations for file mysql error.log" - sudo tail -n 50 /var/log/mysql/error.log + sudo tail -n 200 /var/log/mysql/error.log # TODO: PostgreSQL log file echo fi diff --git a/COPYRIGHT b/COPYRIGHT index 20762c37fe6..2485625914a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -40,13 +40,15 @@ PHPPrintIPP 1.3 GPL-2+ Yes PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar) PSR/simple-cache ? MIT License Yes Library for cache (used by PHPSpreadSheet) Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) -Sabre 3.2.2 BSD Yes DAV support +Sabre 4.0.2 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT License Yes Comprehensive mailing tools for PHP Symfony/var-dumper ??? MIT License Yes Library to make var dump (used by DebugBar) Stripe 10.7.0 MIT Licence Yes Library for Stripe module TCPDF 6.3.2 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement +bacon, dasprid, swiss-qr-bill, kmukku, symfony/validator + JS libraries: Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea. ChartJS 3.7.1 MIT License Yes JS library for graph diff --git a/ChangeLog b/ChangeLog index c8898a2273e..992906c28fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,8 +2,225 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 17.0.2 compared to 17.0.1 ***** +***** ChangeLog for 18.0.0 compared to 17.0.0 ***** + +For uses: +--------- + +NEW: PHP 8.2 compatibility (test not yet completed). +NEW: Module Workstations Management upgraded to stable status. +NEW: Module Webhook upgraded to stable status +NEW: #23436 Group social networks fields +NEW: Accountancy - Add specific page to export accounting data rather than the journals page +NEW: Accountancy - Add sub-account balance FPC22 +NEW: Accountancy - Manage customer retained warranty FPC21+ +NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22 +NEW: Accountancy - iSuiteExpert export model +NEW: Accountancy - Quadratus export with attachments in accountancy export +NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions +NEW: authentication mode: #22740 Add OpenID Connect impl +NEW: authentication mode: Add experimental support for Google OAuth2 connexion +NEW: Add a public virtual card page for each user +NEW: Add a status on supplier price ref (WIP to close a supplier ref) +NEW: add bookmarks in selectable landing pages for users +NEW: Add column ext_payment_site into societe_rib to allow multiple payment mode +NEW: add convertion of images to webp for a single image in website media editor +NEW: Add CRC for currency symbol before amount +NEW: add customer code to invoices listing +NEW: Add Customer Order delivered (ORDER_NEW) in module Notification +NEW: Add date due and labels into customer comm card +NEW: Add filter on nb of generation done in list of recurring invoices +NEW: Add filters and sort on product unit column +NEW: adding button Send Email on the salary file +NEW: Add link to edit VAT list from error message of missing VAT +NEW: add margins in paiement/card.php +NEW: Add mass action delete on VAT +NEW: Add origin info when create a product batch when created from a movement stock +NEW: Add possibility to choose format #21426 +NEW: Add SQL contraint on product_stock table to allow only exsting product and warehouse #23543 +NEW: Add STRIPE_DEBUG, a way to log Stripe IPN +NEW: An external module can modify the quick search fields +NEW: Auto activate some modules on install (Export/Import/Wysiwyg editor) +NEW: Autofill email form with the email template with status "Default" on +NEW: Bank name no more mandatory on creation. Can be generated if empty. +NEW: Bank: Add fields zip, town, country for owner of a bank account +NEW: batch referential objets +NEW: Better responsive for mass actions +NEW: Can add any contact on events if global MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT is set at 1 +NEW: Can add the add now link on date into addfieldvalue() +NEW: Can bin accounting line for a given month +NEW: Can edit account on miscellaneous payment (if not transfered) +NEW: Can edit inline the VAT number from supplier tab +NEW: Can fill date of salary payment with date of start of salary +NEW: Can filter on a custom group of accounts. Perf or ledger list. +NEW: Can go back to draft on shipment when stock change not on validate +NEW: Can modify bank account of sepa payment (if file not sent yet) +NEW: Salary: Can modify the date of payment of a salary (if not reconciled) +NEW: OAuth: Can now edit service name for oauth token +NEW: Reception: Can receive more than qty ordered on reception +NEW: Can select the export format during export of journals +NEW: Can set a checkbox in formconfirm by clicking on the label +NEW: Can set background style with MAIN_LOGIN_BACKGROUND_STYLE +NEW: Can set flag default value on email templates +NEW: Can set the page "List of opportunities" as landing page +NEW: Can show the sql request used on emailing selection +NEW: can stay on edit field when errors occurs +NEW: category of operation for crabe PDF model +NEW: comment in api_mymodule for seperate methods +NEW: constant PROPALE_ADDON_NOTE_PUBLIC_DEFAULT +NEW: create email substitution variable for intervention signature URL +NEW: Date for salary payment includes the hour/min +NEW: Debug the custom CSS feature to avoid a directory search/scan at +NEW: dev name +NEW: Disable bad reputation product price +NEW: dolExplodeIntoArray can accept regex +NEW: dol_sort_array can sort on alphabetical order even if val is num +NEW: Email: don't have closed contact proposed as receiver for the mails +NEW: element time integration code + SQL +NEW: Email-Collector: Add field reply-to in email collector as possible filter +NEW: Email-Collector: substitute date now in email collector +NEW: events list with color +NEW: expend/collapse list of social networks +NEW: Filter on amount and qty on list of service's contracts +NEW: formconfirm can support field with format datetime +NEW: getCommonSubstitutionArray to have more substitute keys +NEW: GeoIP: Can test a geoip conversion from the geoip setup page +NEW: GUI: add a CSS editor into the admin GUI +NEW: GUI: add dropdown button actions (example on Create button on project) +NEW: GUI: color for start date and owner +NEW: GUI: new tab for reception and shipment +NEW: GUI: better design for the page of discounts of a thirdparty +NEW: Help: Tooltip to explain how to add a photo on a product +NEW: Help: Possibility to link to German pages in help +NEW: helper functions for dates + small demo case +NEW: hook printFieldListFrom in contact list +NEW: Import: filter on entity in import +NEW: inc.php: handle parameters from argv +NEW: Invoice - show category of operations +NEW: Keep a link between user created from recruitment and application +NEW: List product in orders +NEW: map table to element for get entity in import +NEW: Members: add numbering modules for members +NEW: Members: add widget box_members_by_tags.php +NEW: Members: Captcha for public member's subscription form +NEW: migration script + delete old table + rename fields and indexes +NEW: MRP MO: Dynamic choice of warehouse and batch in MO production. +NEW: Multicurrency REST API to create, update, delete, update rate... +NEW: Multiselect for filter on prospection status +NEW: [Bulk delete Project tasks] +NEW: No overwrite of optionals during put() contact +NEW: Notification for Sign or Refused Propal from Online Page +NEW: notify also the contributor affected to a ticket if a new message public is post (add global TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ALSO_CONTRIBUTOR) +NEW: Now we can edit amount on VAT and salaries clone action +NEW: only get openned contact from liste_contact function, to not have acces to closed contact as mail receiver +NEW: operation type in email collector to load or create contact +NEW: option filter for NoSalesRepresentativeAffected in proposals list +NEW: Option to manage deposit slips for more payment modes (not only +NEW: Option to show column for field and line selection on the left +NEW: Orders: add sub total in order list det +NEW: Orders export: allow to export field 'shipment method'. +NEW: payment default values when supplier order created from reception +NEW: Payment : manage contracts +NEW: presend mass action in contact list +NEW: Print PDF: Name and date to print on PDF Sign +NEW: Print PDF: Use the more recent PDF templates for documents by default on a fresh install +NEW: product images on popup are cached +NEW: Products: Add statistics by amount on statistics of products. +NEW: Proposals: filter for Signed+Billed in proposals +NEW: Proposals: can modify margin rates in offers like VAT rates +NEW: Provide the oldcopy value when calling setValueFrom() function with a trigger key +NEW: referential objects of batch +NEW: remove default percentage for event creation url +NEW: remove keys whose table element is the same as element in map list +NEW: repair script skip views +NEW: Security: Save date to invalidate other session into user table +NEW: Security: Invalidate all sessions of a user when password is modified. +NEW: search on time spent duration range +NEW: sepaStripe now creates the payment mode with type pm_ using new API +NEW: set payment default values when supplier order created from reception +NEW: set today start time at beginning +NEW: Setup emailcollector easier. Can also use ! for negative search. +NEW: Show counter of access of website in website list +NEW: Show main currency in company info user tooltip +NEW: Show module into list of emails templates +NEW: Show picto into the combobox of widgets +NEW: Show supplier invoice ref of direct debit transfer tab invoices +NEW: show supplier name in getNomUrl of supplier order +NEW: sort of column of custom group of account +NEW: Supplier Invoices: add ability of ODT support to supplier invoices +NEW: Stock limit for alert and desired optimal stock by product and warehouse import +NEW: Stock: Add warehouse create and modify triggers. +NEW: Stock: Can select several warehouses into the view stock at date in past +NEW: Support different bank account for several direct debit payments +NEW: Support multiselect in the warehouse selection combo box +NEW: Support option MAIN_SECURITY_MAXFILESIZE_DOWNLOADED #yogosha10660 +NEW: Survey: Comment on survey is possible only after vote. +NEW: table llx_element_time to store time spent on several elements (mo, ticket...) +NEW: TakePOS: adapt category and product pictures sizes on TakePOS +NEW: TakePOS: limit load products in TakePOS +NEW: The batch for remind on due date can be setup for using validation date +NEW: The refresh link for imap collector is always visible +NEW: The upgrade process can be done by creating a file upgrade.unlock +NEW: Tickets: --Send an email when ticket assigned-- +NEW: Tickets: Send a notification email when ticket assigned +NEW: Tickets: set ticket status to answered if the client has answered from the public interface +NEW: Tickets: added an option to display the progress of tickets on the public interface +NEW: Tickets: add link to thirdparty tickets history +NEW: Use a cache file for external RSS in calendar +NEW: Use by default the domain $dolibarr_main_url_root for SMTP HELO +NEW: use more recent model by default +NEW: VAT can be modified during add of line +NEW: Website Module: Increment website counter on each page access in website module +NEW: write all fields and their properties in asciidoc format +NEW: Can add an array of several links in date selector +NEW: Option PDF_SHOW_PHONE_AFTER_USER_CONTACT to show phone after specific assigned contact on PDF +NEW: Option PDF_SHOW_EMAIL_AFTER_USER_CONTACT to show email after specific assigned contact on PDF +NEW: Widgets: Implement MAIN_ACTIVATE_FILECACHE on birthday widget +NEW: Widgets: Add widget "The next upcoming events" +NEW: Widgets: Add widget of open opportunities +NEW: Use an ajax component to swith prospection status on thirdparty list +NEW: Add partial payment reason "withholding tax" + + + +For developers or integrators: +------------------------------ + +NEW: Make it possible to select hours and minutes in form_confirm +NEW: add triggers on mailing +NEW: Add a trigger when create a shipping line batch and fix propagate missing errors +NEW: add function for listiong objects from directory +NEW: add helplist property to describe fields of objects +NEW: add hook in loadLotStock() in html.formproduct.class.php file, add hook 'llxFooter', Add hook online sign +NEW: Update lib parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0, jquery, Stripe. +NEW: Support contact in post() document API +NEW: More APIs (update currency rate, upload of supplier documents, ...) +NEW: ModuleBuilder: updating in modulbuilder on tab Menu when adding object +NEW: ModuleBuilder: add/edit permissions +NEW: ModuleBuilder: better generated documentation +NEW: add sent info in the parameters provided to the hook sendMailAfter +NEW: add setAsSelectUser into factory for generic setup page +NEW: add option keepspace into dol_string_nospecialchar() + + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Minimal PHP version is now PHP 7.1 instead of PHP 7.0 +* The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead. +* The method "nb_expedition()" has been renamed into "countNbOfShipments()" +* Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated). +* Deprecated property libelle removed from entrepot class. +* The type 'text' in ->fields property does not accept html content anymore. Use the type 'html' for that. +* The module for WebService SOAP API have been deprecated. Use instead the Webservice REST API module. +* The method htmlPrintOnlinePaymentFooter() used for public footer pages has been renamed into htmlPrintOnlineFooter() and moved into company.lib.php +* The method getCheckOption() and deleteCPUser() of class Holiday has been removed (it was not used) + + +***** ChangeLog for 17.0.2 compared to 17.0.1 ***** +FIX: Change strpos for expedition and receipt in files.lib $haystack and $needle inversion +FIX: Add hidden conf to add extrafields in canelle template : INVOICE_ADD_EXTRAFIELD_IN_NOTE FIX: #24414 FIX: #24798 Deleting member subscription is not possible FIX: add a test for updating date on task update in tab time consummed pro… @@ -84,219 +301,6 @@ FIX: Warehouse total line FIX: When salary module is not enabled, bad permission check on user list FIX: wrong colspan for tasks list -***** ChangeLog for 18.0.0 compared to 17.0.0 ***** - -For uses: ---------- - -NEW: PHP 8.2 compatibility (test not yet completed). -NEW: Module Workstations Management upgraded to stable status -NEW: Module Webhook upgraded to stable status -NEW: #23436 Group social networks fields -NEW: Accountancy - Add specific page to export accounting data rather than the journals page -NEW: Accountancy - Add sub-account balance FPC22 -NEW: Accountancy - Manage customer retained warranty FPC21+ -NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22 -NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions -NEW: authentication mode: #22740 Add OpenID Connect impl -NEW: authentication mode: Add experimental support for Google OAuth2 connexion -NEW: adapt category and product pictures sizes on TakePOS -NEW: Supplier Invoices: add ability of ODT support to supplier invoices -NEW: Add a public virtual card page for each user -NEW: Add a status on supplier price ref (WIP to close a supplier ref) -NEW: add bookmarks in selectable landing pages for users -NEW: Add column ext_payment_site into societe_rib to allow multiple payment mode -NEW: add convertion of images to webp for a single image in website media editor -NEW: Add CRC for currency symbol before amount -NEW: add a CSS editor into the admin GUI -NEW: add customer code to invoices listing -NEW: Add Customer Order delivered (ORDER_NEW) in module Notification -NEW: Add date due and labels into customer comm card -NEW: Add dropdown button actions (example on Create button on project) -NEW: Tickets: added an option to display the progress of tickets on the public interface -NEW: Add field reply-to in email collector as possible filter -NEW: Add filter on nb of generation done in list of recurring invoices -NEW: Add filters and sort on product unit column -NEW: adding button Send Email on the salary file -NEW: Add link to edit VAT list from error message of missing VAT -NEW: add link to thirdparty tickets history -NEW: add margins in paiement/card.php -NEW: Add mass action delete on VAT -NEW: Add fields zip, town, country for owner of a bank account -NEW: Members: add numbering modules for members -NEW: Add origin info when create a product batch when created from a movement stock -NEW: Add possibility to choose format #21426 -NEW: Add SQL contraint on product_stock table to allow only exsting product and warehouse#23543 -NEW: Add statistics by amount on statistics of products. -NEW: Add STRIPE_DEBUG, a way to log Stripe IPN -NEW: Add sub total in order list det -NEW: Add warehouse create and modify triggers. -NEW: Add widget box_members_by_tags.php -NEW: An external module can modify the quick search fields -NEW: Auto activate some modules on install (Export/Import/Wysiwyg editor) -NEW: Autofill email form with the email template with status "Default" on -NEW: Bank name no more mandatory on creation. Can be generated if empty. -NEW: batch referential objets -NEW: Better responsive for mass actions -NEW: Can add any contact on events if global MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT is set at 1 -NEW: Can add the add now link on date into addfieldvalue() -NEW: Can bin accounting line for a given month -NEW: Can edit account on miscellaneous payment (if not transfered) -NEW: Can edit inline the VAT number from supplier tab -NEW: Can fill date of salary payment with date of start of salary -NEW: Can filter on a custom group of accounts. Perf or ledger list. -NEW: Can go back to draft on shipment when stock change not on validate -NEW: Can modify bank account of sepa payment (if file not sent yet) -NEW: Proposals: Can modify margin rates in offers like VAT rates. -NEW: Salary: Can modify the date of payment of a salary (if not reconciled) -NEW: OAuth: Can now edit service name for oauth token -NEW: Reception: Can receive more than qty ordered on reception -NEW: Can select several warehouses into the view stock at date in past -NEW: Can select the export format during export of journals -NEW: Can set a checkbox in formconfirm by clicking on the label -NEW: Can set background style with MAIN_LOGIN_BACKGROUND_STYLE -NEW: Can set flag default value on email templates -NEW: Can set the page "List of opportunities" as landing page -NEW: Can show the sql request used on emailing selection -NEW: can stay on edit field when errors occurs -NEW: GeoIP: Can test a geoip conversion from the geoip setup page -NEW: Members: Captcha for public member's subscription form -NEW: category of operation for crabe PDF model -NEW: color for start date and owner -NEW: comment in api_mymodule for seperate methods -NEW: constant PROPALE_ADDON_NOTE_PUBLIC_DEFAULT -NEW: create email substitution variable for intervention signature URL -NEW: Date for salary payment includes the hour/min -NEW: Debug the custom CSS feature to avoid a directory search/scan at -NEW: dev name -NEW: Disable bad reputation product price -NEW: dolExplodeIntoArray can accept regex -NEW: dol_sort_array can sort on alphabetical order even if val is num -NEW: don't have closed contact proposed as receiver for the mails -NEW: MO: Dynamic choice of warehouse and batch in MO production. -NEW: element time integration code + sql -NEW: events list with color -NEW: expend/collapse list of social networks -NEW: Proposals: filter for Signed+Billed in proposals -NEW: Filter on amount and qty on list of service's contracts -NEW: Import: filter on entity in import -NEW: formconfirm can support field with format datetime -NEW: getCommonSubstitutionArray to have more substitute keys -NEW: helper functions for dates + small demo case -NEW: hook printFieldListFrom in contact list -NEW: inc.php: handle parameters from argv -NEW: Website Module: Increment website counter on each page access in website module -NEW: Invalidate all sessions of a user when password is modified. -NEW: Invoice - show category of operations -NEW: iSuiteExpert export model -NEW: Keep a link between user created from recruitment and application -NEW: limit load products in TakePOS -NEW: List product in orders -NEW: map table to element for get entity in import -NEW: migration script + delete old table + rename fields and indexes -NEW: Multicurrency REST API to create, update, delete, update rate... -NEW: Multiselect for filter on prospection status -NEW: Name and date to print on PDF Sign -NEW: [Bulk delete Project tasks] -NEW: No overwrite of optionals during put() contact -NEW: Notification for Sign or Refused Propal from Online Page -NEW: notify also the contributor affected to a ticket if a new message public is post (add global TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ALSO_CONTRIBUTOR) -NEW: Now we can edit amount on vat and salaries clone action -NEW: only get openned contact from liste_contact function, to not have acces to closed contact as mail receiver -NEW: operation type in email collector to load or create contact -NEW: option filter for NoSalesRepresentativeAffected in proposals list -NEW: Option to manage deposit slips for more payment modes (not only -NEW: Option to show column for field and line selection on the left -NEW: Order export : allow to export field 'shipment method'. -NEW: payment default values when supplier order created from reception -NEW: Payment : manage contracts -NEW: Possibility to link to German pages in help -NEW: presend mass action in contact list -NEW: product images on popup are cached -NEW: Provide the oldcopy value when calling setValueFrom() function with a trigger key -NEW: Accountancy: Quadratus export with attachments in accountancy export -NEW: referential objects of batch -NEW: remove default percentage for event creation url -NEW: remove keys whose table element is the same as element in map list -NEW: repair script skip views -NEW: Save date to invalidate other session into user table -NEW: search on time spent duration range -NEW: Send an email when ticket assigned -NEW: Send a notification email when ticket assigned -NEW: sepaStripe now creates the payment mode with type pm_ using new API -NEW: set payment default values when supplier order created from reception -NEW: Tickets: set ticket status to answered if the client has answered from the public interface -NEW: set today start time at beginning -NEW: Setup emailcollector easier. Can also use ! for negative search. -NEW: Show counter of access of website in website list -NEW: Show main currency in company info user tooltip -NEW: Show module into list of emails templates -NEW: Show picto into the combobox of widgets -NEW: Show supplier invoice ref of direct debit transfer tab invoices -NEW: show supplier name in getNomUrl of supplier order -NEW: sort of column of custom group of account -NEW: Stock limit for alert and desired optimal stock by product and warehouse import -NEW: substitute date now in email collector -NEW: Support different bank account for several direct debit payments -NEW: Support multiselect in the warehouse selection combo box -NEW: Support option MAIN_SECURITY_MAXFILESIZE_DOWNLOADED #yogosha10660 -NEW: table llx_element_time to store time spent on several elements (mo, ticket...) -NEW: The batch for remind on due date can be setup for using validation date -NEW: The refresh link for imap collector is always visible -NEW: The upgrade process can be done by creating a file upgrade.unlock -NEW: Tooltip to explain how to add a photo on a product -NEW: Use a cache file for external RSS in calendar -NEW: Use by default the domain $dolibarr_main_url_root for SMTP HELO -NEW: use more recent model by default -NEW: VAT can be modified during add of line -NEW: write all fields and their properties in asciidoc format -NEW: Can add an array of several links in date selector -NEW: Add option PDF_SHOW_PHONE_AFTER_USER_CONTACT to show phone after specific assigned contact on PDF -NEW: Add option PDF_SHOW_EMAIL_AFTER_USER_CONTACT to show email after specific assigned contact on PDF -NEW: Widgets: Implement MAIN_ACTIVATE_FILECACHE on birthday widget -NEW: Widgets: Add widget "The next upcoming events" -NEW: Widgets: Add widget of open opportunities -NEW: Use an ajax component to swith prospection status on thidparty list -NEW: Comment on survey is possible only after vote. -NEW: Add partial payment reason "withholding tax" -NEW: A new tab for reception and shipment -NEW: Use the more recent PDF templates for documents by default on a fresh install -NEW: Better design for the page of discounts of a thirdparty - -For developers or integrators: ------------------------------- - -NEW: Make it possible to select hours and minutes in form_confirm -NEW: add triggers on mailing -NEW: Add a trigger when create a shipping line batch and fix propagate missing errors -NEW: add function for listiong objects from directory -NEW: add helplist property to describe fields of objects -NEW: add hook in loadLotStock() in html.formproduct.class.php file, add hook 'llxFooter', Add hook online sign -NEW: Update lib parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0, jquery, Stripe. -NEW: Support contact in post() document API -NEW: More APIs (update currency rate, upload of supplier documents, ...) -NEW: ModuleBuilder: updating in modulbuilder on tab Menu when adding object -NEW: ModuleBuilder: add/edit permissions -NEW: ModuleBuilder: better generated documentation -NEW: add sent info in the parameters provided to the hook sendMailAfter -NEW: add setAsSelectUser into factory for generic setup page -NEW: add option keepspace into dol_string_nospecialchar() - - -WARNING: - -Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* Minimal PHP version is now PHP 7.1 instead of PHP 7.0 -* The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead. -* The method "nb_expedition()" has been renamed into "countNbOfShipments()" -* Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated). -* Deprecated property libelle removed from entrepot class. -* The type 'text' in ->fields property dos not accept html content anymore. Use the type 'html' for that. -* The module for WebService SOAP API have been deprecated. Use instead the Webservice REST API module. -* The method htmlPrintOnlinePaymentFooter() used for public footer pages has been renamed into htmlPrintOnlineFooter() and moved into company.lib.php - - - ***** ChangeLog for 17.0.1 compared to 17.0.0 ***** FIX: 17.0 PHP Warning invalid argument supplied for foreach diff --git a/SECURITY.md b/SECURITY.md index 1c281099885..673d75a3cd2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -57,13 +57,13 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only. * CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. -* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) +* The modules DebugBar and ModuleBuilder must NOT be enabled. (by default, these modules are not enabled. They are developer tools) * Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user. * Fail2ban rules for rate limit on the login page,password forgotten page and all public pages (/public/*) must be installed as recommendend into the section "About - Admin tools - Section Access limits and mitigation". Scope is the web application (back office) and the APIs. -## Example of vulnerabilities Qualified for reporting. +## Examples of vulnerabilities that are Qualified for reporting. * Remote code execution (RCE) * Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA) @@ -72,14 +72,14 @@ Scope is the web application (back office) and the APIs. * Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users) * Open redirect * Broken authentication & session management -* Insecure direct object references -* CORS with real security impact +* Insecure direct object references (IDOR) +* Cross-Origin Resource Sharing (CORS) with real security impact * Horizontal and vertical privilege escalation * "HTTP Host Header" XSS * Software version disclosure (for non admin users only) * Stack traces or path disclosure (for non admin users only) -## Example of vulnerabilities non Non-qualified for reporting. +## Examples of vulnerabilities that are Non-qualified for reporting. * "Self" XSS * SSL/TLS best practices @@ -93,7 +93,7 @@ Scope is the web application (back office) and the APIs. * Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated * Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC) * Reports on features flagged as "experimental" or "development" -* Software version or private IP disclosure when logged user is admin -* Stack traces or path disclosure when logged user is admin +* Software version or private IP disclosure when logged-in user is admin +* Stack traces or path disclosure when logged-in user is admin * Any vulnerabilities due to a configuration different than the one defined into chapter "Scope for qualified vulnerabilities". * Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the fail2ban recommended fail2ban rules were not installed. diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf index 60a4095c34a..1d8b5d33923 100644 --- a/build/travis-ci/apache.conf +++ b/build/travis-ci/apache.conf @@ -9,14 +9,14 @@ # Wire up Apache to use Travis CI's php-fpm. - - AddHandler php5-fcgi .php - Action php5-fcgi /php5-fcgi - Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi - FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization - - - Require all granted - - + # + # AddHandler php5-fcgi .php + # Action php5-fcgi /php5-fcgi + # Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi + # FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization + # + # + # Require all granted + # + # diff --git a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql index 20112e77bb6..c4af061da20 100644 --- a/dev/initdemo/mysqldump_dolibarr_17.0.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_17.0.0.sql @@ -1962,6 +1962,7 @@ CREATE TABLE `llx_c_holiday_types` ( `delay` int(11) NOT NULL, `newbymonth` double(8,5) NOT NULL DEFAULT 0.00000, `fk_country` int(11) DEFAULT NULL, + `block_if_negative` int(11) NOT NULL DEFAULT 0, `active` int(11) DEFAULT 1, `sortorder` smallint(6) DEFAULT NULL, PRIMARY KEY (`rowid`), @@ -1975,7 +1976,11 @@ CREATE TABLE `llx_c_holiday_types` ( LOCK TABLES `llx_c_holiday_types` WRITE; /*!40000 ALTER TABLE `llx_c_holiday_types` DISABLE KEYS */; -INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,1,NULL),(2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,1,NULL),(3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,1,NULL),(4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,NULL),(5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (1,'LEAVE_SICK','Sick leave',0,0,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (2,'LEAVE_OTHER','Other leave',0,0,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (3,'LEAVE_PAID','Paid vacation',1,7,0.00000,NULL,0,1,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (4,'LEAVE_RTT_FR','RTT',1,7,0.83000,1,0,0,NULL); +INSERT INTO `llx_c_holiday_types` VALUES (5,'LEAVE_PAID_FR','Paid vacation',1,30,2.08334,1,0,0,NULL); /*!40000 ALTER TABLE `llx_c_holiday_types` ENABLE KEYS */; UNLOCK TABLES; diff --git a/dev/setup/fail2ban/jail.local b/dev/setup/fail2ban/jail.local index bd1f7959f08..af74ed16671 100644 --- a/dev/setup/fail2ban/jail.local +++ b/dev/setup/fail2ban/jail.local @@ -24,8 +24,8 @@ filter = web-dolibarr-rulesbruteforce logpath = /mypath/documents/documents/dolibarr.log action = %(action_mw)s bantime = 86400 ; 1 day -findtime = 3600 ; 1 hour -maxretry = 10 +findtime = 14400 ; 4 hours +maxretry = 20 [web-dol-limitpublic] diff --git a/doc/user/README b/doc/user/README index ecde765cde3..c650ef09ea6 100644 --- a/doc/user/README +++ b/doc/user/README @@ -3,6 +3,7 @@ README (english) User guide -------------------------------- -* All Dolibarr guides are available, on line, on the Dolibarr Web site: +* All Dolibarr guides are available, online, on the Dolibarr Websites: https://www.dolibarr.org +https://wiki.dolibarr.org diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 1670776ab6e..319ac308802 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -161,11 +161,11 @@ if (empty($reshook)) { if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; @@ -177,7 +177,7 @@ if (empty($reshook)) { } else { $filter['t.numero_compte>='] = $search_accountancy_code_start; } - $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { if ($type == 'sub') { @@ -185,7 +185,7 @@ if (empty($reshook)) { } else { $filter['t.numero_compte<='] = $search_accountancy_code_end; } - $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; @@ -375,10 +375,12 @@ if ($action != 'export_csv') { } $moreforfilter .= ''; - $moreforfilter .= '
'; - $moreforfilter .= ': '; - $moreforfilter .= ''; - $moreforfilter .= '
'; + if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { + $moreforfilter .= '
'; + $moreforfilter .= ': '; + $moreforfilter .= ''; + $moreforfilter .= '
'; + } if (!empty($moreforfilter)) { print '
'; @@ -395,6 +397,14 @@ if ($action != 'export_csv') { print ''; print ''; + + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ''; @@ -404,13 +414,18 @@ if ($action != 'export_csv') { print $hookmanager->resPrint; // Action column - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''."\n"; print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + } print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); // TODO : Retrieve the type of third party: Customer / Supplier / Employee //if ($type == 'sub') { @@ -428,7 +443,9 @@ if ($action != 'export_csv') { $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + } print ''."\n"; $total_debit = 0; @@ -532,6 +549,14 @@ if ($action != 'export_csv') { } print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + // Accounting account if ($type == 'sub') { print ''; @@ -581,9 +606,14 @@ if ($action != 'export_csv') { } else { print ''; } - print ''; + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print "\n"; // Records the sub-total @@ -593,7 +623,12 @@ if ($action != 'export_csv') { } if (!empty($show_subgroup)) { - print ''; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print "\n"; + } + print ''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print ''; } @@ -604,11 +639,19 @@ if ($action != 'export_csv') { } else { print ''; } - print "\n"; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print "\n"; + } print ''; } - print ''; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print "\n"; + } + print ''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print ''; } @@ -619,7 +662,10 @@ if ($action != 'export_csv') { } else { print ''; } - print "\n"; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print "\n"; + } print ''; $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 585d5b664cb..53650a3cd28 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -720,7 +720,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) { // List of mass actions available $arrayofmassactions = array(); -if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { $arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto'); $arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto'); $arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual'); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 9031c73624b..60de7a205ab 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -381,7 +381,7 @@ if (empty($reshook)) { $param = '&type='.$type.$param; } - //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + //if ($action == 'delbookkeepingyearconfirm' && $user->hasRight('accounting', 'mouvements', 'supprimer')_tous) { // $delmonth = GETPOST('delmonth', 'int'); // $delyear = GETPOST('delyear', 'int'); // if ($delyear == -1) { @@ -1297,7 +1297,7 @@ print "
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print $link; + print ''.$line->subledger_account.' ('.$line->subledger_label.')'.price(price2num($line->debit - $line->credit, 'MT')).''; - print $link; - print ''; + print $link; + print '
'.$langs->trans("SubTotal").':
'.$langs->trans("SubTotal").':'.price(price2num($sous_total_opening_balance, 'MT')).'' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '
'.$langs->trans("AccountBalance").':
'.$langs->trans("AccountBalance").':'.price(price2num($total_opening_balance, 'MT')).'' . price(price2num($total_debit - $total_credit, 'MT')) . '
"; print '
'; // TODO Replace this with mass delete action -//if ($user->rights->accounting->mouvements->supprimer_tous) { +//if ($user->hasRight('accounting', 'mouvements, 'supprimer_tous')) { // print '
'."\n"; // print ''.$langs->trans("DeleteMvt").''; // print '
'; diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index c1dc454b675..43a70c64c45 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -167,7 +167,7 @@ $y = $year_current; $buttonvalidate = ''.$langs->trans("ValidateMovements").''; -print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 1); +print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 0); print '
'; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 987d35512a5..8c46be39826 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -166,7 +166,7 @@ if (empty($reshook)) { } -if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { +if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { $msg = ''; //print '
' . $langs->trans("Processing") . '...
'; @@ -446,7 +446,7 @@ if ($result) { //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); - //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); + //if ($user->hasRight('mymodule', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if ($massaction !== 'set_default_account') { $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 0255e019138..880e696354d 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -48,7 +48,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -57,7 +57,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if ($action == 'ventil' && $user->rights->accounting->bind->write) { +if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { if (!$cancel) { if ($codeventil < 0) { $codeventil = 0; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index ba98ebcaaa7..9f1fe74d0ea 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -87,7 +87,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -118,7 +118,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_end = ''; } -if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) { +if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) { $error = 0; if (!(GETPOST('account_parent', 'int') >= 0)) { diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 253879eb462..5a417cef7a9 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -104,7 +104,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -158,7 +158,7 @@ if (empty($reshook)) { } -if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { +if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { $msg = ''; if (!empty($mesCasesCochees)) { diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 41c88e00c4f..68e8b5c94ef 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -90,7 +90,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 514edeb4528..bed71d9d27b 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -64,7 +64,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 5e30325d2c7..6d6c875cf85 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -68,7 +68,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -109,14 +109,14 @@ $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva $sql .= " p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " spe.accountancy_code_customer as code_compta,"; $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,"; } else { $sql .= " s.code_compta as code_compta,"; $sql .= " s.code_compta_fournisseur,"; } -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " ppe.accountancy_code_buy,"; } else { $sql .= " p.accountancy_code_buy,"; @@ -124,20 +124,20 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " WHERE f.fk_statut > 0"; $sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy -if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { +if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) { $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")"; } else { $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; @@ -146,8 +146,8 @@ if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } // Define begin binding date -if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; +if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } // Already in bookkeeping or not if ($in_bookkeeping == 'already') { @@ -177,10 +177,10 @@ if ($result) { $num = $db->num_rows($result); // Variables - $cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; - $cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; - $rcctva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT : 'NotDefined'; - $rcdtva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT : 'NotDefined'; + $cptfour = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); + $cpttva = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined'); + $rcctva = getDolGlobalString('ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT', 'NotDefined'); + $rcdtva = getDolGlobalString('ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT', 'NotDefined'); $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC'] $i = 0; @@ -193,9 +193,9 @@ if ($result) { $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) { - $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; + $compta_prod = getDolGlobalString('ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'NotDefined'); } else { - $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; + $compta_prod = getDolGlobalString('ACCOUNTING_SERVICE_BUY_ACCOUNT', 'NotDefined'); } } @@ -203,7 +203,7 @@ if ($result) { $compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); $compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); $compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); - $compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined'; + $compta_counterpart_tva_npr = getDolGlobalString('ACCOUNTING_COUNTERPART_VAT_NPR', 'NotDefined'); // Define array to display all VAT rates that use this accounting account $compta_tva if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) { @@ -241,7 +241,7 @@ if ($result) { } // VAT Reverse charge - if (($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) { + if (($mysoc->country_code == 'FR' || getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) { $rcvatdata = getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ? ' (' . $obj->product_buy_default_vat_code . ')' : ''), $mysoc, $mysoc, 0); $rcc_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva); $rcd_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva); @@ -340,7 +340,7 @@ if ($action == 'writebookkeeping') { $invoicestatic = new FactureFournisseur($db); $accountingaccountsupplier = new AccountingAccount($db); - $accountingaccountsupplier->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); + $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -404,7 +404,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); $bookkeeping->label_compte = $accountingaccountsupplier->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount"); @@ -462,7 +462,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; - if (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT)) { + if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) { if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; @@ -523,7 +523,7 @@ if ($action == 'writebookkeeping') { } // VAT Reverse charge - if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + if ($mysoc->country_code == 'FR' || getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { $has_vat = false; foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { @@ -704,7 +704,7 @@ $form = new Form($db); // Export if ($action == 'exportcsv') { // ISO and not UTF8 ! - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'journal'; $type_export = 'journal'; @@ -752,7 +752,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"'.$val["refsologest"].'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER).'"'.$sep; + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep; @@ -796,7 +796,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! } // VAT Reverse charge - if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + if ($mysoc->country_code == 'FR' || getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { $has_vat = false; foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { @@ -871,7 +871,7 @@ if (empty($action) || $action == 'view') { $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescJournalOnlyBindedVisible").'
'; - if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) { $description .= $langs->trans("DepositsAreNotIncluded"); } else { $description .= $langs->trans("DepositsAreIncluded"); @@ -886,7 +886,8 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); // Button to write into Ledger - if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + $acctSupplierNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), ['','-1']); + if ($acctSupplierNotConfigured) { print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -894,10 +895,10 @@ if (empty($action) || $action == 'view') { print '
'; } print '
'; - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { + if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { print ''; } - if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + if ($acctSupplierNotConfigured) { print ''; } else { if ($in_bookkeeping == 'notyet') { @@ -1023,7 +1024,7 @@ if (empty($action) || $action == 'view') { print "
"; // Account print ""; // Subledger account print ""; // Account print ""; // Account print ""; // Subledger account print "'; + print ''; } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index aaef5aa96a7..44b2fb349d6 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -1008,7 +1008,7 @@ class AdherentType extends CommonObject //$return .= ''; - if ($user->rights->adherent->configurer) { + if ($user->hasRight('adherent', 'configurer')) { $return .= 'ref).'">'.img_edit().''; } else { $return .= ' '; diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index f126403f597..8a26cd5d070 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -55,10 +55,10 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param int $id ID of member - * @return array|mixed data without useless information + * @param int $id ID of member + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index aa1ccf12f90..da43514a1d0 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -48,10 +48,10 @@ class MembersTypes extends DolibarrApi * * Return an array with member type informations * - * @param int $id ID of member type - * @return array|mixed data without useless information + * @param int $id ID of member type + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 68109ae4420..a60078769a0 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -51,10 +51,10 @@ class Subscriptions extends DolibarrApi * * Return an array with subscription informations * - * @param int $id ID of subscription - * @return Object data without useless information + * @param int $id ID of subscription + * @return Object Object with cleaned properties * - * @throws RestException + * @throws RestException */ public function get($id) { diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index d6409c802cb..ed2eddc104a 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -96,10 +96,13 @@ class Subscription extends CommonObject public $amount; /** - * @var int ID + * @var int ID of bank in llx_bank */ public $fk_bank; + /** + * @var array Array with all fields into database and their property. Do not use it as a static var. It may be modified by constructor. + */ public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), @@ -128,7 +131,7 @@ class Subscription extends CommonObject /** - * Function who permitted cretaion of the subscription + * Function who permitted creation of the subscription * * @param User $user User that create * @param bool $notrigger false=launch triggers after, true=disable triggers @@ -151,7 +154,6 @@ class Subscription extends CommonObject $this->datec = $now; } - $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; @@ -217,7 +219,7 @@ class Subscription extends CommonObject $sql .= " datef,"; $sql .= " subscription, note as note_public, fk_bank"; $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql .= " WHERE rowid=".((int) $rowid); + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); @@ -274,11 +276,11 @@ class Subscription extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql .= " fk_type = ".((int) $this->fk_type).","; $sql .= " fk_adherent = ".((int) $this->fk_adherent).","; - $sql .= " note=".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null').","; + $sql .= " note = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null').","; $sql .= " subscription = ".price2num($this->amount).","; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " dateadh = '".$this->db->idate($this->dateh)."',"; + $sql .= " datef = '".$this->db->idate($this->datef)."',"; + $sql .= " datec = '".$this->db->idate($this->datec)."',"; $sql .= " fk_bank = ".($this->fk_bank ? ((int) $this->fk_bank) : 'null'); $sql .= " WHERE rowid = ".((int) $this->id); diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index c466ff7ff9d..e4fbb178e0a 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -55,9 +55,9 @@ if ($id > 0 || !empty($ref)) { // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && !empty($user->rights->user->self->creer)) + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); } } diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 4d3bc4dd638..f4f72fc93fa 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -85,7 +85,8 @@ $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index d800c181c18..c2a5e9dc2d0 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -41,11 +41,12 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other')); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$id = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); +$contextpage = GETPOST('contextpage', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('rowid', 'int') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); $rowid = $id; $ref = GETPOST('ref', 'alphanohtml'); $typeid = GETPOST('typeid', 'int'); @@ -134,7 +135,7 @@ if ($reshook < 0) { } // Create third party from a member -if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { +if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) { if ($result > 0) { // Creation of thirdparty $company = new Societe($db); @@ -151,7 +152,7 @@ if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'ye } } -if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->hasRight('user', 'user', 'creer'))) { +if (empty($reshook) && $action == 'setuserid' && ($user->hasRight('user', 'self', 'creer') || $user->hasRight('user', 'user', 'creer'))) { $error = 0; if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only if (GETPOST("userid", 'int') != $user->id && GETPOST("userid", 'int') != $object->user_id) { @@ -461,755 +462,754 @@ if ($optioncss != '') { //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -if ($rowid > 0) { - $res = $object->fetch($rowid); - if ($res < 0) { - dol_print_error($db, $object->error); - exit; - } - - $adht->fetch($object->typeid); - - $head = member_prepare_head($object); - - $rowspan = 10; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $rowspan++; - } - if (isModEnabled('societe')) { - $rowspan++; - } - - print ''; - print ''; - print ''; - - print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = ''; - $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); - $morehtmlref .= ''; - - dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); - - print '
'; - print '
'; - - print '
'; - print '
".$invoicestatic->getNomUrl(1).""; - $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER); + $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForSuppliersNotDefined").''; } else { @@ -1067,7 +1068,7 @@ if (empty($action) || $action == 'view') { print ""; - if (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT)) { + if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) { if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) { print length_accounta($tabcompany[$key]['code_compta']); } @@ -1097,7 +1098,7 @@ if (empty($action) || $action == 'view') { } // VAT Reverse charge - if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) { + if ($mysoc->country_code == 'FR' || getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { $has_vat = false; foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index e8178ad63d3..7cae93566c6 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -70,7 +70,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -109,7 +109,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " spe.accountancy_code_customer as code_compta,"; $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,"; } else { @@ -117,26 +117,26 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " s.code_compta_fournisseur,"; } $sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " ppe.accountancy_code_sell"; } else { $sql .= " p.accountancy_code_sell"; } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { +if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing $sql .= " AND f.fk_statut > 0"; -if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup +if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { // Non common setup $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; @@ -146,8 +146,8 @@ if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } // Define begin binding date -if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { - $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; +if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { + $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; } // Already in bookkeeping or not if ($in_bookkeeping == 'already') { @@ -177,8 +177,8 @@ if ($result) { $num = $db->num_rows($result); // Variables - $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'; - $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; + $cptcli = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); + $cpttva = getDolGlobalString('ACCOUNTING_VAT_SOLD_ACCOUNT', 'NotDefined'); $i = 0; while ($i < $num) { @@ -190,9 +190,9 @@ if ($result) { $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) { - $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; + $compta_prod = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'NotDefined'); } else { - $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; + $compta_prod = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'NotDefined'); } } @@ -257,7 +257,7 @@ if ($result) { // It also seems that credit notes on situation invoices are correctly saved (but it depends on the version used in fact). // For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes. $total_ttc = $obj->total_ttc * $situation_ratio; - if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) { + if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) { $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty; $total_ttc -= $retained_warranty; @@ -315,11 +315,11 @@ if ($action == 'writebookkeeping') { $invoicestatic = new Facture($db); $accountingaccountcustomer = new AccountingAccount($db); - $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); + $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); $accountingaccountcustomerwarranty = new AccountingAccount($db); - $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true); + $accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true); foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -381,7 +381,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY; + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'); $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty"); @@ -430,7 +430,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); $bookkeeping->label_compte = $accountingaccountcustomer->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount"); @@ -488,7 +488,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; - if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) { if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; @@ -657,7 +657,7 @@ $form = new Form($db); // Export if ($action == 'exportcsv') { // ISO and not UTF8 ! - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'journal'; $type_export = 'journal'; @@ -704,7 +704,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"'.$val["ref"].'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep; + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; @@ -723,7 +723,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print '"'.$val["ref"].'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER).'"'.$sep; + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.$langs->trans("Thirdparty").'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep; @@ -800,7 +800,7 @@ if (empty($action) || $action == 'view') { $exportlink = ''; $builddate = dol_now(); $description = $langs->trans("DescJournalOnlyBindedVisible").'
'; - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { $description .= $langs->trans("DepositsAreNotIncluded"); } else { $description .= $langs->trans("DepositsAreIncluded"); @@ -815,7 +815,8 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); // Button to write into Ledger - if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + $acctCustomerNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), ['','-1']); + if ($acctCustomerNotConfigured) { print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); $desc = str_replace('{link}', ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $desc); @@ -823,10 +824,10 @@ if (empty($action) || $action == 'view') { print '
'; } print '
'; - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { + if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { print ''; } - if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + if ($acctCustomerNotConfigured) { print ''; } else { if ($in_bookkeeping == 'notyet') { @@ -950,7 +951,7 @@ if (empty($action) || $action == 'view') { print "
".$invoicestatic->getNomUrl(1).""; - $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY); + $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForCustomersNotDefined").''; } else { @@ -980,7 +981,7 @@ if (empty($action) || $action == 'view') { print "".$invoicestatic->getNomUrl(1).""; - $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER); + $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')); if (($accountoshow == "") || $accountoshow == 'NotDefined') { print ''.$langs->trans("MainAccountForCustomersNotDefined").''; } else { @@ -1024,7 +1025,7 @@ if (empty($action) || $action == 'view') { print ""; - if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) { if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { print length_accounta($tabcompany[$key]['code_compta']); } diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index 621683ea4cb..a2e9d362aad 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -90,7 +90,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 306b88d11ea..bc7393c4bbd 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -48,7 +48,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -57,7 +57,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if ($action == 'ventil' && $user->rights->accounting->bind->write) { +if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { if (!$cancel) { if ($codeventil < 0) { $codeventil = 0; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 5d212e57ccf..8fdff8628d2 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -45,7 +45,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->bind->write)) { +if (!$user->hasRight('accounting', 'bind', 'write')) { accessforbidden(); } @@ -82,7 +82,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -91,7 +91,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { +if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { // Clean database $db->begin(); $sql1 = "UPDATE ".$db->prefix()."facture_fourn_det as fd"; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 2c4fece83f0..cd3269431ad 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -97,7 +97,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -133,7 +133,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_tvaintra = ''; } -if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) { +if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) { $error = 0; if (!(GETPOST('account_parent', 'int') >= 0)) { diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2b8fea60e51..8d227b7ce1b 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -169,7 +169,7 @@ if (empty($reshook)) { } -if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { +if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { $msg = ''; if (!empty($mesCasesCochees)) { @@ -453,7 +453,7 @@ if ($result) { //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); - //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); + //if ($user->hasRight('mymodule', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if ($massaction !== 'set_default_account') { $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); diff --git a/htdocs/adherents/admin/member_emails.php b/htdocs/adherents/admin/member_emails.php index 2bfd3a1d630..cc7b60f6233 100644 --- a/htdocs/adherents/admin/member_emails.php +++ b/htdocs/adherents/admin/member_emails.php @@ -56,16 +56,16 @@ $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL_ // Editing global variables not related to a specific theme $constantes = array( 'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))), - 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_EMAIL_TEMPLATE_EXCLUSION' =>array('type'=>'emailtemplate:member'), - 'ADHERENT_MAIL_FROM' =>array('type'=>'string'), - 'ADHERENT_CC_MAIL_FROM' =>array('type'=>'string'), - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT' =>array('type'=>'string'), - 'ADHERENT_AUTOREGISTER_NOTIF_MAIL' =>array('type'=>'html', 'tooltip'=>$helptext) + 'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_EMAIL_TEMPLATE_EXCLUSION' =>array('type'=>'emailtemplate:member','label'=>''), + 'ADHERENT_MAIL_FROM' =>array('type'=>'string','label'=>''), + 'ADHERENT_CC_MAIL_FROM' =>array('type'=>'string','label'=>''), + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT' =>array('type'=>'string','label'=>''), + 'ADHERENT_AUTOREGISTER_NOTIF_MAIL' =>array('type'=>'html', 'tooltip'=>$helptext,'label'=>'') ); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 867f4f47025..90f36033f71 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -173,7 +173,7 @@ if ($object->id > 0) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).($object->id > 0 ? '?id='.$object->id : '').'&origin=member&originid='.$id); } - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index eda6f52deb3..84ae98ac3c5 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -216,7 +216,7 @@ abstract class ActionsAdherentCardCommon $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); - $this->tpl['note'] = nl2br($this->object->note); + $this->tpl['note'] = $this->object->note_private; } if ($action == 'create_user') { @@ -241,7 +241,7 @@ abstract class ActionsAdherentCardCommon /** * Assign POST values into object * - * @return string HTML output + * @return void */ private function assign_post() { @@ -251,7 +251,8 @@ abstract class ActionsAdherentCardCommon $this->object->old_name = GETPOST("old_name"); $this->object->old_firstname = GETPOST("old_firstname"); - $this->object->fk_soc = GETPOST("fk_soc"); + $this->object->fk_soc = GETPOST("fk_soc", 'int'); + $this->object->socid = GETPOST("fk_soc", 'int'); $this->object->lastname = GETPOST("lastname"); $this->object->firstname = GETPOST("firstname"); $this->object->civility_id = GETPOST("civility_id"); @@ -262,8 +263,8 @@ abstract class ActionsAdherentCardCommon $this->object->state_id = GETPOST("state_id", 'int'); $this->object->phone_perso = GETPOST("phone_perso"); $this->object->phone_mobile = GETPOST("phone_mobile"); - $this->object->email = GETPOST("email", 'alphawithlgt'); - $this->object->note = GETPOST("note", 'restricthtml'); + $this->object->email = GETPOST("email", 'alphawithlgt'); + $this->object->note_private = GETPOST("note", 'restricthtml'); $this->object->canvas = GETPOST("canvas"); // We set country_id, and country_code label of the chosen country diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5816c5c4ea1..820e9455efb 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -316,7 +316,7 @@ if (empty($reshook)) { $object->birth = $birthdate; $object->default_lang = GETPOST('default_lang', 'alpha'); $object->typeid = GETPOST("typeid", 'int'); - //$object->note = trim(GETPOST("comment","alpha")); + //$object->note = trim(GETPOST("comment", "restricthtml")); $object->morphy = GETPOST("morphy", 'alpha'); if (GETPOST('deletephoto', 'alpha')) { @@ -1336,7 +1336,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!$value['active']) { break; } - print '
'.$langs->trans($value['label']).'
'.$langs->trans($value['label']).'
'; - - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } - - // Type - print ''; - print '\n"; - - // Morphy - print ''; - print ''; - print ''; - - // Company - print ''; - - // Civility - print ''; - print ''; - - // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } - - // Date end subscription - print ''; - - print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.dol_escape_htmltag($object->login).'
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib('', 1).'
'.$langs->trans("Company").''.dol_escape_htmltag($object->company).'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().'
'.$langs->trans("Password").''; - if ($object->pass) { - print preg_replace('/./i', '*', $object->pass); - } else { - if ($user->admin) { - print ''; - } - print ''.$langs->trans("Hidden").''; - } - if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore) - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); - } - print '
'.$langs->trans("SubscriptionEndDate").''; - if ($object->datefin) { - print dol_print_date($object->datefin, 'day'); - if ($object->hasDelay()) { - print " ".img_warning($langs->trans("Late")); - } - } else { - if ($object->need_subscription == 0) { - print $langs->trans("SubscriptionNotNeeded"); - } elseif (!$adht->subscription) { - print $langs->trans("SubscriptionNotRecorded"); - if (Adherent::STATUS_VALIDATED == $object->statut) { - print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated - } - } else { - print $langs->trans("SubscriptionNotReceived"); - if (Adherent::STATUS_VALIDATED == $object->statut) { - print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated - } - } - } - print '
'; - - print '
'; - - print '
'; - print '
'; - - print ''; - - // Tags / Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { - print ''; - print ''; - } - - // Birth Date - print ''; - - // Default language - if (getDolGlobalInt('MAIN_MULTILANGS')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print ''; - } - - // Public - print ''; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - // Third party Dolibarr - if (isModEnabled('societe')) { - print ''; - } - - // Login Dolibarr - Link to user - print ''; - - print "
'.$langs->trans("Categories").''; - print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); - print '
'.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').'
'.$langs->trans("DefaultLang").''; - //$s=picto_from_langcode($object->default_lang); - //print ($s?$s.' ':''); - $langs->load("languages"); - $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); - print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); - print $labellang; - print '
'.$langs->trans("Public").''.yn($object->public).'
'; - print ''; - if ($action != 'editthirdparty' && $user->hasRight('adherent', 'creer')) { - print ''; - } - print '
'; - print $langs->trans("LinkedToDolibarrThirdParty"); - print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'
'; - print '
'; - if ($action == 'editthirdparty') { - $htmlname = 'socid'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $form->select_company($object->fk_soc, 'socid', '', 1); - print '
'; - } else { - if ($object->fk_soc) { - $company = new Societe($db); - $result = $company->fetch($object->fk_soc); - print $company->getNomUrl(1); - - // Show link to invoices - $tmparray = $company->getOutstandingBills('customer'); - if (!empty($tmparray['refs'])) { - print ' - '.img_picto($langs->trans("Invoices"), 'bill', 'class="paddingright"').''.$langs->trans("Invoices").' ('.count($tmparray['refs']).')'; - // TODO Add alert if warning on at least one invoice late - print ''; - } - } else { - print ''.$langs->trans("NoThirdPartyAssociatedToMember").''; - } - } - print '
'; - print ''; - if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) { - print ''; - } - print '
'; - print $langs->trans("LinkedToDolibarrUser"); - print ''; - if ($user->hasRight("user", "user", "creer")) { - print 'id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).''; - } - print '
'; - print '
'; - if ($action == 'editlogin') { - $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); - } else { - if ($object->user_id) { - $linkeduser = new User($db); - $linkeduser->fetch($object->user_id); - print $linkeduser->getNomUrl(-1); - } else { - print ''.$langs->trans("NoDolibarrAccess").''; - } - } - print '
\n"; - - print "
\n"; - print '
'; - - print dol_get_fiche_end(); - - - /* - * Action bar - */ - - // Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2) - if ($user->hasRight('adherent', 'cotisation', 'creer')) { - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - print '
'; - - if ($object->statut > 0) { - print '
'.$langs->trans("AddSubscription")."
"; - } else { - print '
'.$langs->trans("AddSubscription").'
'; - } - - print '
'; - } - } - - /* - * List of subscriptions - */ - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; - $sql .= " c.rowid as crowid, c.subscription,"; - $sql .= " c.datec, c.fk_type as cfk_type,"; - $sql .= " c.dateadh as dateh,"; - $sql .= " c.datef,"; - $sql .= " c.fk_bank,"; - $sql .= " b.rowid as bid,"; - $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid); - $sql .= $db->order($sortfield, $sortorder); - - $result = $db->query($sql); - if ($result) { - $subscriptionstatic = new Subscription($db); - - $num = $db->num_rows($result); - - print ''."\n"; - - print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (isModEnabled('banque')) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print "\n"; - - $accountstatic = new Account($db); - $adh = new Adherent($db); - $adht = new AdherentType($db); - - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - - $adh->id = $objp->rowid; - $adh->typeid = $objp->type; - - $subscriptionstatic->ref = $objp->crowid; - $subscriptionstatic->id = $objp->crowid; - - $typeid = $objp->cfk_type; - if ($typeid > 0) { - $adht->fetch($typeid); - } - - print ''; - print ''; - print '\n"; - print ''; - print '\n"; - print '\n"; - print ''; - if (isModEnabled('banque')) { - print ''; - } - print ""; - $i++; - } - - if (empty($num)) { - $colspan = 6; - if (isModEnabled('banque')) { - $colspan++; - } - print ''; - } - - print "
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).''; - if ($objp->bid) { - $accountstatic->label = $objp->label; - $accountstatic->id = $objp->baid; - $accountstatic->number = $objp->number; - $accountstatic->account_number = $objp->account_number; - $accountstatic->currency_code = $objp->currency_code; - - if (isModEnabled('accounting') && $objp->fk_accountancy_journal > 0) { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); - - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } - - $accountstatic->ref = $objp->ref; - print $accountstatic->getNomUrl(1); - } else { - print ' '; - } - print '
'.$langs->trans("None").'
"; - } else { - dol_print_error($db); - } - } - - - if (($action != 'addsubscription' && $action != 'create_thirdparty')) { - // Shon online payment link - $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); - - if ($useonlinepayment) { - print '
'; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); - print '
'; - } - } - - /* - * Add new subscription form - */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) { - print '
'; - - print load_fiche_titre($langs->trans("NewCotisation")); - - // Define default choice for complementary actions - $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice - $invoiceonly = 0; // 1 means option by default is invoice only - $bankviainvoice = 0; // 1 means option by default is write to bank via invoice - if (GETPOST('paymentsave')) { - if (GETPOST('paymentsave') == 'bankdirect') { - $bankdirect = 1; - } - if (GETPOST('paymentsave') == 'invoiceonly') { - $invoiceonly = 1; - } - if (GETPOST('paymentsave') == 'bankviainvoice') { - $bankviainvoice = 1; - } - } else { - if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { - $bankviainvoice = 1; - } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && isModEnabled('banque')) { - $bankdirect = 1; - } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { - $invoiceonly = 1; - } - } - - print "\n\n\n"; - - if ($conf->use_javascript_ajax) { - //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); - print "\n".''."\n"; - } - - - // Confirm create third party - if ($action == 'create_thirdparty') { - $companyalias = ''; - $fullname = $object->getFullName($langs); - - if ($object->morphy == 'mor') { - $companyname = $object->company; - if (!empty($fullname)) { - $companyalias = $fullname; - } - } else { - $companyname = $fullname; - if (!empty($object->company)) { - $companyalias = $object->company; - } - } - - // Create a form array - $formquestion = array( - array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), - array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') - ); - // If customer code was forced to "required", we ask it at creation to avoid error later - if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { - $tmpcompany = new Societe($db); - $tmpcompany->name = $companyname; - $tmpcompany->get_codeclient($tmpcompany, 0); - $customercode = $tmpcompany->code_client; - $formquestion[] = array( - 'label' => $langs->trans("CustomerCode"), - 'type' => 'text', - 'name' => 'customercode', - 'value' => $customercode, - 'morecss' => 'minwidth300', - 'moreattr' => 'maxlength="128"', - ); - } - // @todo Add other extrafields mandatory for thirdparty creation - - print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 1); - } - - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - print dol_get_fiche_head(''); - - print "\n"; - print ''; - - $today = dol_now(); - - // Date payment - if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { - $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); - } - - print ''; - // Date start subscription - $currentyear = dol_print_date(time(), "%Y"); - $currentmonth = dol_print_date(time(), "%m"); - print '"; - - // Date end subscription - if (GETPOST('endday')) { - $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - } - if (!$dateto) { - if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) { - $dateto = dol_get_last_day($currentyear, $currentmonth); - } elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) { - $dateto = dol_get_last_day($currentyear); - } else { - $dateto = -1; // By default, no date is suggested - } - } - print '"; - - if ($adht->subscription) { - // Amount - print ''; - - // Label - print ''; - print ''; - - // Complementary action - if ((isModEnabled('banque') || isModEnabled('facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { - $company = new Societe($db); - if ($object->fk_soc) { - $result = $company->fetch($object->fk_soc); - } - - // Title payments - //print ''; - - // No more action - print ''; - print ''; - - // Bank account - print '\n"; - - // Payment mode - print '\n"; - - // Date of payment - print '\n"; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - } - } - - print ''; - - print ''; - print ''; - print ''; - print '
'.$langs->trans("DateSubscription").''; - if (GETPOST('reday')) { - $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - } - if (!$datefrom) { - $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); - } else { - $datefrom = dol_get_first_day($currentyear); - } - } - print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); - print "
'.$langs->trans("DateEndSubscription").''; - print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); - print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency) .'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); - print ''; - print ''; - print '
'; - // Add entry into bank accoun - if (isModEnabled('banque')) { - print '
'; - } - // Add invoice with no payments - if (isModEnabled('societe') && isModEnabled('facture')) { - print 'fk_soc)) print ' disabled'; - print '>
'; - } - // Add invoice with payments - if (isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { - print 'fk_soc)) print ' disabled'; - print '>
'; - } - print '
'.$langs->trans("FinancialAccount").''; - print img_picto('', 'bank_account'); - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); - print "
'.$langs->trans("PaymentMode").''; - print $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200', 1); - print "
'.$langs->trans("DatePayment").''; - print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); - print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
'.$langs->trans("SendAcknowledgementByMail").''; - if (!$object->email) { - print $langs->trans("NoEMail"); - } else { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - // Send subscription email - $subject = ''; - $msg = ''; - - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - } - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - - $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; - $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; - $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; - if ($subjecttosend) { - $helpcontent .= $subjecttosend."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - $helpcontent .= "
"; - $helpcontent .= ''.$langs->trans("MailText").':
'; - if ($texttosend) { - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); - } - print '
'; - - print dol_get_fiche_end(); - - print '
'; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); - if (empty($reshook)) { - print ''; - print '     '; - print ''; - } - print '
'; - - print '
'; - - print "\n\n\n"; - } - - //print ''; - //print ''; -} else { +if (! ($object->id > 0)) { $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } +/*$res = $object->fetch($rowid); + if ($res < 0) { + dol_print_error($db, $object->error); + exit; + } +*/ + +$adht->fetch($object->typeid); + +$head = member_prepare_head($object); + +$rowspan = 10; +if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + $rowspan++; +} +if (isModEnabled('societe')) { + $rowspan++; +} + +print '
'; +print ''; +print ''; + +print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); + +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref = ''; +$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); +$morehtmlref .= ''; + +dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + +print '
'; +print '
'; + +print '
'; +print ''; + +// Login +if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; +} + +// Type +print ''; +print '\n"; + +// Morphy +print ''; +print ''; +print ''; + +// Company +print ''; + +// Civility +print ''; +print ''; + +// Password +if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; +} + +// Date end subscription +print ''; + +print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.dol_escape_htmltag($object->login).'
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib('', 1).'
'.$langs->trans("Company").''.dol_escape_htmltag($object->company).'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().'
'.$langs->trans("Password").''; + if ($object->pass) { + print preg_replace('/./i', '*', $object->pass); + } else { + if ($user->admin) { + print ''; + } + print ''.$langs->trans("Hidden").''; + } + if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore) + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + } + print '
'.$langs->trans("SubscriptionEndDate").''; +if ($object->datefin) { + print dol_print_date($object->datefin, 'day'); + if ($object->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } +} else { + if ($object->need_subscription == 0) { + print $langs->trans("SubscriptionNotNeeded"); + } elseif (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if (Adherent::STATUS_VALIDATED == $object->statut) { + print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated + } + } else { + print $langs->trans("SubscriptionNotReceived"); + if (Adherent::STATUS_VALIDATED == $object->statut) { + print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated + } + } +} +print '
'; + +print '
'; + +print '
'; +print '
'; + +print ''; + +// Tags / Categories +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { + print ''; + print ''; +} + +// Birth Date +print ''; + +// Default language +if (getDolGlobalInt('MAIN_MULTILANGS')) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print ''; +} + +// Public +print ''; + +// Other attributes +$cols = 2; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + +// Third party Dolibarr +if (isModEnabled('societe')) { + print ''; +} + +// Login Dolibarr - Link to user +print ''; + +print "
'.$langs->trans("Categories").''; + print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); + print '
'.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').'
'.$langs->trans("DefaultLang").''; + //$s=picto_from_langcode($object->default_lang); + //print ($s?$s.' ':''); + $langs->load("languages"); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; + print '
'.$langs->trans("Public").''.yn($object->public).'
'; + print ''; + if ($action != 'editthirdparty' && $user->hasRight('adherent', 'creer')) { + print ''; + } + print '
'; + print $langs->trans("LinkedToDolibarrThirdParty"); + print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'
'; + print '
'; + if ($action == 'editthirdparty') { + $htmlname = 'socid'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->select_company($object->fk_soc, 'socid', '', 1); + print '
'; + } else { + if ($object->fk_soc) { + $company = new Societe($db); + $result = $company->fetch($object->fk_soc); + print $company->getNomUrl(1); + + // Show link to invoices + $tmparray = $company->getOutstandingBills('customer'); + if (!empty($tmparray['refs'])) { + print ' - '.img_picto($langs->trans("Invoices"), 'bill', 'class="paddingright"').''.$langs->trans("Invoices").' ('.count($tmparray['refs']).')'; + // TODO Add alert if warning on at least one invoice late + print ''; + } + } else { + print ''.$langs->trans("NoThirdPartyAssociatedToMember").''; + } + } + print '
'; +print ''; +if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) { + print ''; +} +print '
'; +print $langs->trans("LinkedToDolibarrUser"); +print ''; + if ($user->hasRight("user", "user", "creer")) { + print 'id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).''; + } + print '
'; +print '
'; +if ($action == 'editlogin') { + $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); +} else { + if ($object->user_id) { + $linkeduser = new User($db); + $linkeduser->fetch($object->user_id); + print $linkeduser->getNomUrl(-1); + } else { + print ''.$langs->trans("NoDolibarrAccess").''; + } +} +print '
\n"; + +print "
\n"; +print '
'; + +print dol_get_fiche_end(); + + +/* + * Action bar + */ + +// Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2) +if ($user->hasRight('adherent', 'cotisation', 'creer')) { + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + print '
'; + + if ($object->statut > 0) { + print '"; + } else { + print ''; + } + + print '
'; + } +} + +/* + * List of subscriptions + */ +if ($action != 'addsubscription' && $action != 'create_thirdparty') { + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; + $sql .= " c.rowid as crowid, c.subscription,"; + $sql .= " c.datec, c.fk_type as cfk_type,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef,"; + $sql .= " c.fk_bank,"; + $sql .= " b.rowid as bid,"; + $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid); + $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) { + $subscriptionstatic = new Subscription($db); + + $num = $db->num_rows($result); + + print ''."\n"; + + print ''; + print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (isModEnabled('banque')) { + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + print "\n"; + + $accountstatic = new Account($db); + $adh = new Adherent($db); + $adht = new AdherentType($db); + + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + + $adh->id = $objp->rowid; + $adh->typeid = $objp->type; + + $subscriptionstatic->ref = $objp->crowid; + $subscriptionstatic->id = $objp->crowid; + + $typeid = $objp->cfk_type; + if ($typeid > 0) { + $adht->fetch($typeid); + } + + print ''; + print ''; + print '\n"; + print ''; + print '\n"; + print '\n"; + print ''; + if (isModEnabled('banque')) { + print ''; + } + print ""; + $i++; + } + + if (empty($num)) { + $colspan = 6; + if (isModEnabled('banque')) { + $colspan++; + } + print ''; + } + + print "
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).''; + if ($objp->bid) { + $accountstatic->label = $objp->label; + $accountstatic->id = $objp->baid; + $accountstatic->number = $objp->number; + $accountstatic->account_number = $objp->account_number; + $accountstatic->currency_code = $objp->currency_code; + + if (isModEnabled('accounting') && $objp->fk_accountancy_journal > 0) { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); + + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + + $accountstatic->ref = $objp->ref; + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print '
'.$langs->trans("None").'
"; + } else { + dol_print_error($db); + } +} + + +if (($action != 'addsubscription' && $action != 'create_thirdparty')) { + // Shon online payment link + $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); + + if ($useonlinepayment) { + print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + print '
'; + } +} + +/* + * Add new subscription form + */ +if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) { + print '
'; + + print load_fiche_titre($langs->trans("NewCotisation")); + + // Define default choice for complementary actions + $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice + $invoiceonly = 0; // 1 means option by default is invoice only + $bankviainvoice = 0; // 1 means option by default is write to bank via invoice + if (GETPOST('paymentsave')) { + if (GETPOST('paymentsave') == 'bankdirect') { + $bankdirect = 1; + } + if (GETPOST('paymentsave') == 'invoiceonly') { + $invoiceonly = 1; + } + if (GETPOST('paymentsave') == 'bankviainvoice') { + $bankviainvoice = 1; + } + } else { + if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { + $bankviainvoice = 1; + } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && isModEnabled('banque')) { + $bankdirect = 1; + } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { + $invoiceonly = 1; + } + } + + print "\n\n\n"; + + if ($conf->use_javascript_ajax) { + //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); + print "\n".''."\n"; + } + + + // Confirm create third party + if ($action == 'create_thirdparty') { + $companyalias = ''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { + $companyname = $object->company; + if (!empty($fullname)) { + $companyalias = $fullname; + } + } else { + $companyname = $fullname; + if (!empty($object->company)) { + $companyalias = $object->company; + } + } + + // Create a form array + $formquestion = array( + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') + ); + // If customer code was forced to "required", we ask it at creation to avoid error later + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { + $tmpcompany = new Societe($db); + $tmpcompany->name = $companyname; + $tmpcompany->get_codeclient($tmpcompany, 0); + $customercode = $tmpcompany->code_client; + $formquestion[] = array( + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); + } + // @todo Add other extrafields mandatory for thirdparty creation + + print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 1); + } + + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print dol_get_fiche_head(''); + + print '
'; + print ''."\n"; + print ''; + + $now = dol_now(); + + // Date payment + if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { + $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); + } + + print ''; + // Date start subscription + $currentyear = dol_print_date($now, "%Y"); + $currentmonth = dol_print_date($now, "%m"); + print '"; + + // Date end subscription + if (GETPOST('endday')) { + $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int')); + } + if (!$dateto) { + if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) { + $dateto = dol_get_last_day($currentyear, $currentmonth); + } elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) { + $dateto = dol_get_last_day($currentyear); + } else { + $dateto = -1; // By default, no date is suggested + } + } + print '"; + + if ($adht->subscription) { + // Amount + print ''; + + // Label + print ''; + print ''; + + // Complementary action + if ((isModEnabled('banque') || isModEnabled('facture')) && !getDolGlobalString('ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS')) { + $company = new Societe($db); + if ($object->socid) { + $result = $company->fetch($object->socid); + } + + // No more action + print ''; + print ''; + + // Bank account + print '\n"; + + // Payment mode + print '\n"; + + // Date of payment + print '\n"; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + } + } + + print ''; + + print ''; + print ''; + print ''; + print '
'.$langs->trans("DateSubscription").''; + if (GETPOST('reday')) { + $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + } + if (!$datefrom) { + $datefrom = $object->datevalid; + if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } else { + $datefrom = dol_get_first_day($currentyear); + } + } + print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); + print "
'.$langs->trans("DateEndSubscription").''; + print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); + print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency) .'
'.$langs->trans("Label").'
'.$langs->trans('MoreActions'); + print ''; + + print ''; + print '
'; + // Add entry into bank accoun + if (isModEnabled('banque')) { + print '
'; + } + // Add invoice with no payments + if (isModEnabled('societe') && isModEnabled('facture')) { + print 'fk_soc)) print ' disabled'; + print '>
'; + } + // Add invoice with payments + if (isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) { + print 'fk_soc)) print ' disabled'; + print '>
'; + } + print '
'.$langs->trans("FinancialAccount").''; + print img_picto('', 'bank_account'); + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); + print "
'.$langs->trans("PaymentMode").''; + print $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200', 1); + print "
'.$langs->trans("DatePayment").''; + print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); + print "
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
'.$langs->trans("SendAcknowledgementByMail").''; + if (!$object->email) { + print $langs->trans("NoEMail"); + } else { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + // Send subscription email + $subject = ''; + $msg = ''; + + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + + $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; + $helpcontent = ''; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; + $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + $helpcontent .= "
"; + $helpcontent .= ''.$langs->trans("MailText").':
'; + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); + } + print '
'; + print '
'; + + print dol_get_fiche_end(); + + print '
'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); + if (empty($reshook)) { + print ''; + print '     '; + print ''; + } + print '
'; + + print '
'; + + print "\n\n\n"; +} + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index d6ce54a20e9..5ab388e73d0 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -148,7 +148,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('adheren header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); exit; } else { - $mesg = $adh->error; + $errmesg = $adh->error; } } @@ -194,45 +194,51 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') { // Ref print ''.$langs->trans("Ref").''; - print ''; + print ''; print $form->showrefnav($object, 'rowid', $linkback, 1); print ''; // Member $adh->ref = $adh->getFullName($langs); print ''; - print ''.$langs->trans("Member").''.$adh->getNomUrl(1, 0, 'subscription').''; + print ''.$langs->trans("Member").''; + print ''.$adh->getNomUrl(1, 0, 'subscription').''; print ''; // Type print ''; - print ''.$langs->trans("Type").''; + print ''.$langs->trans("Type").''; + print ''; print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid") : $object->fk_type)); print''; // Date start subscription - print ''.$langs->trans("DateSubscription").''; + print ''.$langs->trans("DateSubscription").''; + print ''; print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); print ''; print ''; // Date end subscription - print ''.$langs->trans("DateEndSubscription").''; + print ''.$langs->trans("DateEndSubscription").''; + print ''; print $form->selectDate($object->datef, 'datesubend', 0, 0, 0, 'update', 1); print ''; print ''; // Amount - print ''.$langs->trans("Amount").''; - print ''; + print ''.$langs->trans("Amount").''; + print ''; + print ''; // Label - print ''.$langs->trans("Label").''; - print ''; + print ''.$langs->trans("Label").''; + print ''; + print ''; // Bank line if (isModEnabled("banque") && (!empty($conf->global->ADHERENT_BANK_USE) || $object->fk_bank)) { - print ''.$langs->trans("BankTransactionLine").''; + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { $bankline = new AccountLine($db); $result = $bankline->fetch($object->fk_bank); @@ -324,7 +330,7 @@ if ($rowid && $action != 'edit') { print ''.$langs->trans("Amount").''.price($object->amount).''; // Label - print ''.$langs->trans("Label").''.$object->note.''; + print ''.$langs->trans("Label").''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)).''; // Bank line if (isModEnabled("banque") && (!empty($conf->global->ADHERENT_BANK_USE) || $object->fk_bank)) { diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 9a2243f4fea..5060a0224b6 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -715,7 +715,7 @@ while ($i < $imaxinloop) { // Label if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; + print ''; print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private)); print ''; if (!$i) { diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 52c16a8ce4b..dcf8722fcbe 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -350,7 +350,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { } else { print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - if ($user->rights->adherent->configurer) { + if ($user->hasRight('adherent', 'configurer')) { print 'rowid.'">'.img_edit().''; } } @@ -374,7 +374,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''.yn($objp->vote).''; print ''.$membertype->getLibStatut(5).''; if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - if ($user->rights->adherent->configurer) { + if ($user->hasRight('adherent', 'configurer')) { print 'rowid.'">'.img_edit().''; } } @@ -537,10 +537,12 @@ if ($rowid > 0) { print ''; print ''.$langs->trans("Description").''; - print nl2br($object->note).""; + print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); + print ""; print ''.$langs->trans("WelcomeEMail").''; - print nl2br($object->mail_valid).""; + print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->mail_valid)); + print ""; // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 84acb576407..a0816b0d256 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -755,7 +755,7 @@ if ($mysoc->useLocalTax(1)) { $opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc")); print '
: '; - print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1); + print $form->selectarray("clt1", $opcions, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1')); print ""; print "\n"; @@ -796,7 +796,7 @@ if ($mysoc->useLocalTax(2)) { $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); } print '
: '; - print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2); + print $form->selectarray("clt2", $opcions, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2')); print ""; print "\n"; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index c5a4d1a3463..919a32b4c0e 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -410,7 +410,7 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; - if ($conf->global->CONTRACT_ADDON_PDF == $name) { + if (getDolGlobalString('CONTRACT_ADDON_PDF') == $name) { print 'scandir).'&label='.urlencode($module->name).'&type=order_supplier" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; } else { print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 1b615ddeed1..66df8bd59f1 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -104,7 +104,7 @@ if ($action == 'edit') { if ($key == 'DAV_ALLOW_PRIVATE_DIR') { print $langs->trans("AlwaysActive"); } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { - print $form->selectyesno($key, $conf->global->$key, 1); + print $form->selectyesno($key, getDolGlobalString($key), 1); } else { print ''; } @@ -140,9 +140,9 @@ if ($action == 'edit') { if ($key == 'DAV_ALLOW_PRIVATE_DIR') { print $langs->trans("AlwaysActive"); } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { - print yn($conf->global->$key); + print yn(getDolGlobalString($key)); } else { - print $conf->global->$key; + print getDolGlobalString($key); } print ''; } @@ -189,7 +189,7 @@ $message .= ''; $message .= ajax_autoselect('webdavpublicurl'); $message .= '
'; -if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { +if (!empty(getDolGlobalString('DAV_ALLOW_PUBLIC_DIR'))) { $urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : ''); $url = '' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4cefb9630c5..5d4631cb362 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -605,7 +605,9 @@ foreach ($tabcomplete as $key => $value) { $keytable = ''; if ($id > 0) { $arrayofkeys = array_keys($tabcomplete); - $keytable = $arrayofkeys[$id - 1]; + if (array_key_exists($id -1, $arrayofkeys)) { + $keytable = $arrayofkeys[$id - 1]; + } } // Defaut sortorder @@ -2238,7 +2240,9 @@ if ($id > 0) { $valuetoshow = $obj->{$value}." ".img_picto("", $obj->{$value}); } elseif ($value == 'type_duration') { $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); - $valuetoshow =$TDurationTypes[$obj->{$value}]; + if (!empty($obj->{$value}) && array_key_exists($obj->{$value}, $TDurationTypes)) { + $valuetoshow = $TDurationTypes[$obj->{$value}]; + } } $class .= ($class ? ' ' : '').'tddict'; if ($value == 'note' && $id == 10) { @@ -2428,12 +2432,12 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $withentity = ''; foreach ($fieldlist as $field => $value) { - if ($value == 'entity') { + if ($value == 'entity' && isset($obj->$value)) { $withentity = $obj->$value; continue; } - if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && in_array($obj->type, array('system', 'systemauto'))) { + if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) { $hidden = (!empty($obj->{$value}) ? $obj->{$value}:''); print ''; print ''; @@ -2530,10 +2534,12 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') // Special case for labels if ($tabname == 'c_payment_term') { $langs->load("bills"); - $transkey = "PaymentCondition".strtoupper($obj->code); - if ($langs->trans($transkey) != $transkey) { - $transfound = 1; - print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); + if (isset($obj->code) && !empty($obj->code)) { + $transkey = "PaymentCondition" . strtoupper($obj->code); + if ($langs->trans($transkey) != $transkey) { + $transfound = 1; + print $form->textwithpicto($langs->trans($transkey), $langs->trans("GoIntoTranslationMenuToChangeThis")); + } } } if (!$transfound) { diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 452ae74d614..e140e51337c 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -395,9 +395,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringtarget = ''; // Note: $object->host has been loaded by the fetch - $usessl = 1; - - $connectstringserver = $object->getConnectStringIMAP($usessl); + $connectstringserver = $object->getConnectStringIMAP(); if ($action == 'scan') { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { @@ -645,9 +643,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea console.log("We change a filter"); if (jQuery("#filtertype option:selected").attr("data-noparam")) { jQuery("#rulevalue").attr("placeholder", ""); - jQuery("#rulevalue").text(""); jQuery("#rulevalue").prop("disabled", true); - } - else { jQuery("#rulevalue").prop("disabled", false); } + jQuery("#rulevalue").text(""); + jQuery("#rulevalue").prop("disabled", true); + jQuery("#rulevaluehelp").addClass("unvisible"); + } else { + jQuery("#rulevalue").prop("disabled", false); + jQuery("#rulevaluehelp").removeClass("unvisible"); + } jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder"))); '; /*$noparam = array(); @@ -658,8 +660,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '})'; print ''."\n"; - print ''; - print ''; + print ''; + print '
'; + print ''; + print '
'; + print img_warning($langs->trans("FilterSearchImapHelp"), '', 'pictowarning classfortooltip'); + print '
'; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 0d10602b1c4..2ffb966828b 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -230,7 +230,7 @@ if ($action == 'edit') { print "\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { print $form->selectyesno($constname, getDolGlobalString($constname), 1); diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 1ad9cc67e7d..968fdea81af 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -221,7 +221,7 @@ if ($action != 'edit') { echo '' . $form->selectExpense('', 'fk_c_type_fees', 0, 1, 1) . ''; echo '' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . ''; echo '' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . ''; - echo '' . $form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0) . ''; echo ''; echo '' . $form->selectyesno('restrictive', 0, 1) . ''; echo ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 679ee078f47..e02f28c91b6 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -171,7 +171,7 @@ print ''; print ''; print $langs->trans("ActivateCheckReadKey").''; -print ''; +print ''; if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index a9c0071078d..ba9ab75bc7c 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -49,7 +49,7 @@ if ($action == 'test' || ($action == 'send' && $trackid = 'test')) { $substitutionarrayfortest = array( '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__CHECK_READ__' => '', + '__CHECK_READ__' => '', '__USER_LOGIN__' => $user->login, '__USER_EMAIL__' => $user->email, '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 062aac55962..82d05113b8b 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -42,7 +42,7 @@ if ($action == 'test' || $action == 'send') { $substitutionarrayfortest = array( '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__CHECK_READ__' => '', + '__CHECK_READ__' => '', '__USER_LOGIN__' => $user->login, '__USER_EMAIL__' => $user->email, '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index be86f35e0dc..6976682dc1f 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -182,10 +182,10 @@ $elementList = array(); $elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --'; $elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --'; $elementList['user'] = img_picto('', 'user', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToUser')); -if (isModEnabled('adherent') && !empty($user->rights->adherent->lire)) { +if (isModEnabled('adherent') && $user->hasRight('adherent', 'lire')) { $elementList['member'] = img_picto('', 'object_member', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToMember')); } -if (isModEnabled('recruitment') && !empty($user->rights->recruitment->recruitmentjobposition->read)) { +if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) { $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures')); } if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { @@ -194,13 +194,13 @@ if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) { if (isModEnabled('project')) { $elementList['project'] = img_picto('', 'project', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToProject')); } -if (isModEnabled("propal") && !empty($user->rights->propal->lire)) { +if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $elementList['propal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendProposal')); } -if (isModEnabled('commande') && !empty($user->rights->commande->lire)) { +if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $elementList['order_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendOrder')); } -if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { +if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice')); } if (isModEnabled("expedition")) { @@ -221,7 +221,7 @@ if (isModEnabled("supplier_order") && ($user->hasRight('fournisseur', 'commande' if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice')); } -if (isModEnabled('contrat') && !empty($user->rights->contrat->lire)) { +if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract')); } if (isModEnabled('ticket') && !empty($user->rights->ticket->read)) { @@ -236,7 +236,7 @@ if (isModEnabled('agenda')) { if (isModEnabled('eventorganization') && !empty($user->rights->eventorganization->read)) { $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization')); } -if (!empty($conf->partnership->enabled) && !empty($user->rights->partnership->read)) { +if (isModEnabled('partnership') && !empty($user->rights->partnership->read)) { $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership')); } @@ -1144,7 +1144,7 @@ if ($num) { // If template is for a module, check module is enabled. if ($obj->module) { $tempmodulekey = $obj->module; - if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) { $i++; continue; } @@ -1306,7 +1306,7 @@ if ($num) { // If no record found if ($nbqualified == 0) { - $colspan = 10; + $colspan = 12; print ''.$langs->trans("NoRecordFound").''; } diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 5c0ecdb007d..413b57c9694 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -360,7 +360,7 @@ if ($mode == 'setup' && $user->admin) { if (is_object($tokenobj)) { // Token refresh print ''; - print ''; + print ''; //var_dump($key); print $langs->trans("TOKEN_REFRESH"); print ''; diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 2fd3f13f88b..313898d0667 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -70,7 +70,7 @@ if ($action == 'update') { dolibarr_del_const($db, "INVOICE_ADD_SWISS_QR_CODE", $conf->entity); } if (GETPOSTISSET('INVOICE_ADD_SWISS_QR_CODE')) { - dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INVOICE_ADD_SWISS_QR_CODE", GETPOST("INVOICE_ADD_SWISS_QR_CODE", 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_del_const($db, "INVOICE_ADD_ZATCA_QR_CODE", $conf->entity); } if (GETPOSTISSET('INVOICE_CATEGORY_OF_OPERATION')) { @@ -168,14 +168,14 @@ if (isModEnabled('facture')) { print ''; print ''; - print $form->textwithpicto($langs->trans("INVOICE_ADD_SWISS_QR_CODE"), ''); + print $form->textwithpicto($langs->trans("INVOICE_ADD_SWISS_QR_CODE"), $langs->trans("INVOICE_ADD_SWISS_QR_CODEMore")); print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('INVOICE_ADD_SWISS_QR_CODE'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("INVOICE_ADD_SWISS_QR_CODE", $arrval, $conf->global->INVOICE_ADD_SWISS_QR_CODE); - } + //if ($conf->use_javascript_ajax) { + // print ajax_constantonoff('INVOICE_ADD_SWISS_QR_CODE'); + //} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"), 'bottom' => $langs->trans("AtBottomOfPage").' ('.$langs->trans("Experimental").' - Need PHP 8.1+)'); + print $form->selectarray("INVOICE_ADD_SWISS_QR_CODE", $arrval, $conf->global->INVOICE_ADD_SWISS_QR_CODE); + //} print ''; // Mention category of operations diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 0dad5e887eb..554cb84ce48 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -164,6 +164,8 @@ print ''.$langs->trans("BankToRece print ''; print img_picto('', 'bank_account', 'class="pictofixedwidth"'); print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1, '', 0, 'minwidth200', 1); +// TODO Add plus to add a bank account +print ' '; print ''; /* Moved to bank account data diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 5ea581296af..8bddb3579e7 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -64,8 +64,8 @@ if (GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($action == 'updateform') { $antivircommand = GETPOST('MAIN_ANTIVIRUS_COMMAND', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example c:\Progra~1\ClamWin\bin\clamscan.exe $antivirparam = GETPOST('MAIN_ANTIVIRUS_PARAM', 'restricthtml'); // Use GETPOST restricthtml because we must accept ". Example --database="C:\Program Files (x86)\ClamWin\lib" - $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&")); // Sanitize command - $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&")); // Sanitize params + $antivircommand = dol_string_nospecial($antivircommand, '', array("|", ";", "<", ">", "&", "+")); // Sanitize command + $antivirparam = dol_string_nospecial($antivirparam, '', array("|", ";", "<", ">", "&", "+")); // Sanitize params if ($antivircommand && !empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 052031acd14..e90d0567fbc 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -98,7 +98,7 @@ print '
'; // Module debugbar print '
'; print ''.$langs->trans("DebugBar").': '; -$test = empty($conf->debugbar->enabled); +$test = !isModEnabled('debugbar'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { @@ -110,7 +110,7 @@ print '
'; // Applicative cache print '
'; print ''.$langs->trans("ApplicativeCache").': '; -$test = !empty($conf->memcached->enabled); +$test = isModEnabled('memcached'); if ($test) { if (!empty($conf->global->MEMCACHED_SERVER)) { print $langs->trans("MemcachedAvailableAndSetup"); diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 4229a6def80..7a64b89bccb 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -539,14 +539,14 @@ print '
'; print '
'; print load_fiche_titre($langs->trans("API"), '', 'folder'); -if (empty($conf->api->enabled) && empty($conf->webservices->enabled)) { +if (!isModEnabled('api') && !isModEnabled('webservices')) { print $langs->trans("APIsAreNotEnabled"); } else { - if (!empty($conf->webservices->enabled)) { + if (isModEnabled('webservices')) { print $langs->trans('YouEnableDeprecatedWSAPIsUseRESTAPIsInstead')."
\n"; print '
'; } - if (!empty($conf->api->enabled)) { + if (isModEnabled('api')) { print 'API_ENDPOINT_RULES = '.getDolGlobalString('API_ENDPOINT_RULES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)')."
\n"; print '
'; } @@ -631,6 +631,11 @@ print '
'; print 'MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS = '.getDolGlobalString('MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; +print 'MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; +print '
'; + +// MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS + print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index d903bc2d32f..059801ed13a 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -59,7 +59,7 @@ $action = GETPOST('action', 'aZ09'); // Product On delivery On delivery // Service On invoice On invoice -$tax_mode = empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE; +$tax_mode = getDolGlobalString('TAX_MODE') ? 0 : getDolGlobalInt('TAX_MODE'); if ($action == 'update') { $error = 0; @@ -220,7 +220,7 @@ if (empty($mysoc->tva_assuj)) { // Products print ''.$langs->trans("Product").''; print ''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment') { + if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment') { print $langs->trans("OnPayment"); print ' ('.$langs->trans("SupposedToBePaymentDate").')'; } else { @@ -229,7 +229,7 @@ if (empty($mysoc->tva_assuj)) { } print ''; print ''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { + if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') { print $langs->trans("OnPayment"); print ' ('.$langs->trans("SupposedToBePaymentDate").')'; } else { @@ -241,7 +241,7 @@ if (empty($mysoc->tva_assuj)) { // Services print ''.$langs->trans("Services").''; print ''; - if ($conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') { print $langs->trans("OnPayment"); print ' ('.$langs->trans("SupposedToBePaymentDate").')'; } else { @@ -250,7 +250,7 @@ if (empty($mysoc->tva_assuj)) { } print ''; print ''; - if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { print $langs->trans("OnPayment"); print ' ('.$langs->trans("SupposedToBePaymentDate").')'; } else { diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index c9655afb26d..2df831b9bcc 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -199,7 +199,7 @@ if ($errormsg) { $resultstring = '
'; $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; $resultstring .= $langs->trans("YouCanDownloadBackupFile"); - $resultstring .= '
'; + $resultstring .= '
'; $_SESSION["commandbackupresult"] = $resultstring; } diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 8c109a042b6..00a3c85f8c7 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -226,7 +226,7 @@ if ($action == 'edit') { print "\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { print $form->selectyesno($constname, getDolGlobalString($constname), 1); diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index 314e6d13a91..1aba5f16b59 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -40,11 +40,6 @@ $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions $value = GETPOST('value', 'alpha'); -/*$arrayofparameters = array( - 'WORKSTATION_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), - 'WORKSTATION_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) -);*/ - $error = 0; $setupnotempty = 0; @@ -295,7 +290,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print ''; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if (getDolGlobalString($constforvar) == $file) { + if (getDolGlobalString($constforvar, 'mod_workstation_standard') == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -309,7 +304,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Info $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $htmltooltip .= $langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mytmpinstance); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval @@ -437,10 +432,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Default print ''; $constforvar = 'WORKSTATION_'.strtoupper($myTmpObjectKey).'_ADDON'; - if (getDolGlobalString($constforvar) == $name) { + if (getDolGlobalString($constforvar, 'mod_workstation_standard') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { - print '
scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index bfe6c0e3b39..364d6415e83 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -98,8 +98,8 @@ class DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index ee0ae57e0e2..7372ea88798 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -349,7 +349,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if (!DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } @@ -377,7 +377,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -403,7 +403,7 @@ class Documents extends DolibarrApi throw new RestException(404, 'Purchase order not found'); } - $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); + $upload_dir = $conf->fournisseur->dir_output."/commande/".dol_sanitizeFileName($object->ref); } elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -421,7 +421,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 4251e6b9128..abb09397361 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -68,7 +68,7 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -130,7 +130,7 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -193,7 +193,7 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire') && !DolibarrApiAccess::$user->hasRight('commande', 'lire') && !DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } @@ -310,8 +310,8 @@ class Setup extends DolibarrApi /** * Get region by ID. * - * @param int $id ID of region - * @return array Array of cleaned object properties + * @param int $id ID of region + * @return Object Object with cleaned properties * * @url GET dictionary/regions/{id} * @@ -325,8 +325,8 @@ class Setup extends DolibarrApi /** * Get region by Code. * - * @param string $code Code of region - * @return array Array of cleaned object properties + * @param string $code Code of region + * @return Object Object with cleaned properties * * @url GET dictionary/regions/byCode/{code} * @@ -659,7 +659,7 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -1249,7 +1249,7 @@ class Setup extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->propal->lire && !DolibarrApiAccess::$user->rights->commande->lire && !DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire') && !DolibarrApiAccess::$user->hasRight('commande', 'lire') && !DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 4d0a553d1e6..7b5704b3d7a 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -477,7 +477,7 @@ if ($action == 'edit') { print "\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { print $form->selectyesno($constname, getDolGlobalString($constname), 1); diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index ef9afa10458..35fafc2645b 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -166,7 +166,7 @@ if ($object->id > 0) { $out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; $out .= '&backtopage=' . urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print '' . $langs->trans("AddAction") . ''; } else { print '' . $langs->trans("AddAction") . ''; @@ -191,7 +191,7 @@ if ($object->id > 0) { print '
'; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id=' . $object->id . '&socid=' . $socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage=' . urlencode($contextpage); diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index eae2ff45e2b..a2d283ef94b 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -75,7 +75,8 @@ if ($result < 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/depreciation_options.php b/htdocs/asset/depreciation_options.php index 5d232670105..8a5aa58d1b7 100644 --- a/htdocs/asset/depreciation_options.php +++ b/htdocs/asset/depreciation_options.php @@ -73,7 +73,8 @@ if ($result < 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/disposal.php b/htdocs/asset/disposal.php index 46c5be78a79..e711516132b 100644 --- a/htdocs/asset/disposal.php +++ b/htdocs/asset/disposal.php @@ -66,7 +66,8 @@ if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbi * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php index b39a72bb7a3..54992d56fbe 100644 --- a/htdocs/asset/model/accountancy_codes.php +++ b/htdocs/asset/model/accountancy_codes.php @@ -53,8 +53,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 44a0fa504a3..67aa84f8677 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -82,8 +82,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); @@ -168,7 +168,7 @@ if ($object->id > 0) { $out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; $out .= '&backtopage=' . urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; // if (isModEnabled('agenda')) { - // if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + // if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { // print '' . $langs->trans("AddAction") . ''; // } else { // print '' . $langs->trans("AddAction") . ''; @@ -193,7 +193,7 @@ if ($object->id > 0) { print ''; - // if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + // if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { // $param = '&id=' . $object->id . '&socid=' . $socid; // if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { // $param .= '&contextpage=' . urlencode($contextpage); diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 3eb75eded08..fed3c2ba10f 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -69,9 +69,9 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'delete')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'delete'))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php $permissiondellink = $permissiontoadd; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1]; diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php index e8519e581d9..7df00239cd3 100644 --- a/htdocs/asset/model/depreciation_options.php +++ b/htdocs/asset/model/depreciation_options.php @@ -53,8 +53,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index d87a9ea55c8..76f826ef706 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -121,9 +121,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'delete')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'delete'))); // Security check if (!isModEnabled('asset')) { diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php index 52d7e13e777..e74709d51eb 100644 --- a/htdocs/asset/model/note.php +++ b/htdocs/asset/model/note.php @@ -51,8 +51,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read'))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'write')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'write'))); // Used by the include of actions_addupdatedelete.inc.php $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php // Security check (enable the most restrictive one) @@ -68,7 +68,8 @@ if (!$permissiontoread) accessforbidden(); * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index dd31b723cea..10f1d81f1ae 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -65,7 +65,8 @@ if (!isModEnabled('asset')) accessforbidden(); * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 75f8ae98663..486e65544aa 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -393,7 +393,7 @@ jQuery(document).ready(function() { print ''; print '
'; -if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)) { +if (!empty($user->rights->produit->lire) || $user->hasRight('service', 'lire')) { print ''; print '
'; print '
'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 8d03c029cd6..0b1b83c46ef 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('admin', 'bills', 'blockedlog', 'other')); // Access Control -if ((!$user->admin && empty($user->rights->blockedlog->read)) || empty($conf->blockedlog->enabled)) { +if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || empty($conf->blockedlog->enabled)) { accessforbidden(); } diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index db0faa50cc1..8660ebbbc82 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; $id = GETPOST('id', 'int'); $block = new BlockedLog($db); -if ((!$user->admin && empty($user->rights->blockedlog->read)) || empty($conf->blockedlog->enabled)) { +if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || empty($conf->blockedlog->enabled)) { accessforbidden(); } diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 5e25d788ac7..b84b3df5173 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -210,7 +210,7 @@ if ($object->id > 0) { $objcon = new stdClass(); $out = '&origin='.$object->element.'&originid='.$object->id; - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -235,7 +235,7 @@ if ($object->id > 0) { print '
'; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index f0e993d6eea..41aafb18fa9 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -190,7 +190,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $viewlink = dolGetButtonTitle($langs->trans('GroupByX', $langs->transnoentitiesnoconv("Products")), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); $viewlink .= dolGetButtonTitle($langs->trans('TreeView'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':''))); - print load_fiche_titre($langs->trans("BOMNetNeeds"), $viewlink, ''); + print load_fiche_titre($langs->trans("BOMNetNeeds"), $viewlink, 'product'); /* * Lines diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 188c34c8c05..aba22ade7ca 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -74,7 +74,8 @@ restrictedArea($user, 'bom', $object->id, $object->table_element, '', '', 'rowid * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 67b0baac323..52e6fe90501 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -57,8 +57,8 @@ class Boms extends DolibarrApi * * Return an array with bom informations * - * @param int $id ID of bom - * @return array|mixed data without useless information + * @param int $id ID of bom + * @return Object Object with cleaned properties * * @url GET {id} * @throws RestException diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index f21d88fa02a..743eb5cb3b7 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -162,7 +162,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { @@ -216,7 +216,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -241,7 +241,7 @@ if ($object->id > 0) { print ''; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index ca9fd3bf8db..6d21b777405 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -346,7 +346,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index 8dfa04288f7..cef8bd0367c 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -144,7 +144,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index 96700096ee6..301ccdc2eae 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -140,7 +140,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index 27cdbbce880..dea5fee7625 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -118,7 +118,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php index da4c9936860..af078bff0e1 100644 --- a/htdocs/bookcal/booking_agenda.php +++ b/htdocs/bookcal/booking_agenda.php @@ -162,7 +162,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { @@ -216,7 +216,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -241,7 +241,7 @@ if ($object->id > 0) { print ''; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php index 623bf142e60..fd8ddbc4614 100644 --- a/htdocs/bookcal/booking_card.php +++ b/htdocs/bookcal/booking_card.php @@ -342,7 +342,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php index ceec965f5b2..e1954ce07a3 100644 --- a/htdocs/bookcal/booking_contact.php +++ b/htdocs/bookcal/booking_contact.php @@ -144,7 +144,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php index aadcb0f14c9..83031edec2b 100644 --- a/htdocs/bookcal/booking_document.php +++ b/htdocs/bookcal/booking_document.php @@ -140,7 +140,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php index 5b00686fc27..a194d084fe1 100644 --- a/htdocs/bookcal/booking_note.php +++ b/htdocs/bookcal/booking_note.php @@ -118,7 +118,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (! empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index e8075833d22..7bebdcb2af7 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -332,7 +332,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) { // Remove if ($permissiontodelete && $action != 'edit') { - print ''.$langs->trans("Delete").''."\n"; + print ''.$langs->trans("Delete").''."\n"; } print ''; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index c94e464a762..65fdcc96fa0 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -38,7 +38,7 @@ $langs->load("categories"); // Security check $socid = (int) GETPOST('socid', 'int'); -if (!$user->rights->categorie->lire) { +if (!$user->hasRight('categorie', 'lire')) { accessforbidden(); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 0a9ea52acd1..9714195c5bc 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -286,8 +286,8 @@ class Categorie extends CommonObject $mapCode = $mapList['code']; self::$MAP_ID_TO_CODE[$mapId] = $mapCode; $this->MAP_ID[$mapCode] = $mapId; - $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; - $this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table']; + $this->MAP_CAT_FK[$mapCode] = isset($mapList['cat_fk']) ? $mapList['cat_fk'] : null; + $this->MAP_CAT_TABLE[$mapCode] = isset($mapList['cat_table']) ? $mapList['cat_table'] : null; $this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class']; $this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table']; } diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index caacc986cc5..b21d0a1c27c 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -166,7 +166,7 @@ print ''; print ''.$langs->trans("Description").''; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, ROWS_6, '90%'); +$doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, isModEnabled('fckeditor'), ROWS_6, '90%'); $doleditor->Create(); print ''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 21be2954d3f..69747248906 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -49,7 +49,7 @@ if (is_numeric($type)) { // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categoryindex')); -if (!$user->rights->categorie->lire) { +if (!$user->hasRight('categorie', 'lire')) { accessforbidden(); } diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 81685a51e7b..f5f63091f9c 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; -if (!$user->rights->categorie->lire) { +if (!$user->hasRight('categorie', 'lire')) { accessforbidden(); } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index f0f40b4401b..b63431780e7 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -233,7 +233,7 @@ print dol_get_fiche_end(); print "\n
\n"; if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''.$langs->trans('Add').''; if ($cnt_trans > 0) { print ''.$langs->trans('Update').''; @@ -309,7 +309,7 @@ if ($action == 'edit') { * Form to add a new translation */ -if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'add' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a262e8d8885..9501d38ccef 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -107,16 +107,16 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Remove element from category if ($id > 0 && $removeelem > 0 && $action == 'unlink') { - if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $tmpobject = new Product($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'product'; - } elseif ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { + } elseif ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'supplier'; - } elseif ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { + } elseif ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'customer'; @@ -125,7 +125,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') { $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'member'; - } elseif ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { + } elseif ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); @@ -140,7 +140,7 @@ if ($id > 0 && $removeelem > 0 && $action == 'unlink') { $tmpobject = new Project($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { + } elseif ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); $result = $tmpobject->fetch($removeelem); @@ -173,14 +173,14 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } if ($elemid && $action == 'addintocategory' && - (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || - ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || - ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) || + (($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) || + ($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) || + ($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) || ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) || ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) || ($type == Categorie::TYPE_MEMBER && $user->hasRight('adherent', 'creer')) || - ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) || - ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) || + ($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) || + ($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) || ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) )) { if ($type == Categorie::TYPE_PRODUCT) { @@ -493,7 +493,7 @@ $typeid = $type; // List of products or services (type is type of category) if ($type == Categorie::TYPE_PRODUCT) { if ($user->hasRight("product", "read")) { - $permission = ($user->rights->produit->creer || $user->rights->service->creer); + $permission = ($user->rights->produit->creer || $user->hasRight('service', 'creer')); $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($prods < 0) { @@ -911,7 +911,7 @@ if ($type == Categorie::TYPE_ACCOUNT) { if ($user->hasRight("banque", "read")) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $permission = $user->rights->banque->creer; + $permission = $user->hasRight('banque', 'creer'); $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($accounts < 0) { @@ -1127,7 +1127,7 @@ if ($type == Categorie::TYPE_USER) { // Link to delete from category print ''; - if ($user->rights->user->user->creer) { + if ($user->hasRight('user', 'user', 'creer')) { print "id."'>"; print $langs->trans("DeleteFromCat"); print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 17f77a6f644..b2a149ead79 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -155,7 +155,7 @@ $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month') $result = restrictedArea($user, 'agenda', $object, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); /* @@ -215,7 +215,7 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt // Link to a project if (empty($reshook) && $action == 'classin' && ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')))) { //$object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } @@ -970,7 +970,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes $object->fetch_userassigned(); $object->oldcopy = dol_clone($object); - if ($user->rights->agenda->myactions->delete + if ($user->hasRight('agenda', 'myactions', 'delete') || $user->rights->agenda->allactions->delete) { $result = $object->delete(); @@ -1089,7 +1089,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); -$permissiontoadd = ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); +$permissiontoadd = ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'read'))); if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -2016,7 +2016,7 @@ if ($id > 0) { print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, isModEnabled('fckeditor'), ROWS_4, '90%'); $doleditor->Create(); print ''; @@ -2415,7 +2415,7 @@ if ($id > 0) { } // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); print ''; @@ -2478,21 +2478,21 @@ if ($id > 0) { if (empty($reshook)) { if ($action != 'edit') { if ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { print ''; } else { print ''; } if ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { print ''; } else { print ''; } if ($user->rights->agenda->allactions->delete || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) { + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'delete'))) { print ''; } else { print ''; @@ -2514,8 +2514,8 @@ if ($id > 0) { $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->agenda->myactions->read; - $delallowed = $user->rights->agenda->myactions->create; + $genallowed = $user->hasRight('agenda', 'myactions', 'read'); + $delallowed = $user->hasRight('agenda', 'myactions', 'create'); print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang()); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8879e48edd6..1291f195e30 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1407,7 +1407,7 @@ class ActionComm extends CommonObject if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; } - if (empty($user->rights->agenda->allactions->read)) { + if (!$user->hasRight('agenda', 'allactions', 'read')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".((int) $user->id); } $sql .= " WHERE 1 = 1"; @@ -1421,7 +1421,7 @@ class ActionComm extends CommonObject if ($user->socid) { $sql .= " AND a.fk_soc = ".((int) $user->socid); } - if (empty($user->rights->agenda->allactions->read)) { + if (!$user->hasRight('agenda', 'allactions', 'read')) { $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id); $sql .= " OR ar.fk_element = ".((int) $user->id); $sql .= ")"; @@ -1669,10 +1669,10 @@ class ActionComm extends CommonObject if ($user->hasRight('agenda', 'myactions', 'read') && ($this->authorid == $user->id || $this->userownerid == $user->id)) { $canread = 1; // Can read my event } - if (!empty($user->rights->agenda->myactions->read) && array_key_exists($user->id, $this->userassigned)) { + if ($user->hasRight('agenda', 'myactions', 'read') && array_key_exists($user->id, $this->userassigned)) { $canread = 1; // Can read my event i am assigned } - if (!empty($user->rights->agenda->allactions->read)) { + if ($user->hasRight('agenda', 'allactions', 'read')) { $canread = 1; // Can read all event of other } if (!$canread) { @@ -1718,8 +1718,8 @@ class ActionComm extends CommonObject $tooltip .= '
'; //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; $tooltip .= '
'.$langs->trans('MailTopic').': '.dol_escape_htmltag($this->email_subject); - $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); - $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), !empty($this->email_from) ? $this->email_from : ''); + $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), !empty($this->email_to) ? $this->email_to : ''); if (!empty($this->email_tocc)) { $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); } @@ -1860,11 +1860,11 @@ class ActionComm extends CommonObject $imgpicto = img_picto('', 'object_phoning', $color, false, 0, 0, '', 'paddingright'); } elseif ($this->type_code == 'AC_FAX') { $imgpicto = img_picto('', 'object_phoning_fax', $color, false, 0, 0, '', 'paddingright'); - } elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN' || preg_match('/_SENTBYMAIL/', $this->code)) { + } elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN' || (!empty($this->code) && preg_match('/_SENTBYMAIL/', $this->code))) { $imgpicto = img_picto('', 'object_email', $color, false, 0, 0, '', 'paddingright'); } elseif ($this->type_code == 'AC_INT') { $imgpicto = img_picto('', 'object_intervention', $color, false, 0, 0, '', 'paddingright'); - } elseif (preg_match('/^TICKET_MSG/', $this->code)) { + } elseif (!empty($this->code) && preg_match('/^TICKET_MSG/', $this->code)) { $imgpicto = img_picto('', 'object_conversation', $color, false, 0, 0, '', 'paddingright'); } elseif ($this->type != 'systemauto') { $imgpicto = img_picto('', 'user-cog', $color, false, 0, 0, '', 'paddingright'); @@ -2179,7 +2179,7 @@ class ActionComm extends CommonObject if ($exportholiday == 1) { $langs->load("holiday"); - $title = $langs->trans("Holidays"); + $title = $langs->transnoentities("Holidays"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; @@ -2196,12 +2196,12 @@ class ActionComm extends CommonObject $obj = $this->db->fetch_object($resql); $event = array(); - if ($obj->halfday == -1) { + if ($obj->halfday == 1) { $event['fulldayevent'] = false; $timestampStart = dol_stringtotime($obj->date_start." 00:00:00", 0); $timestampEnd = dol_stringtotime($obj->date_end." 12:00:00", 0); - } elseif ($obj->halfday == 1) { + } elseif ($obj->halfday == -1) { $event['fulldayevent'] = false; $timestampStart = dol_stringtotime($obj->date_start." 12:00:00", 0); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 4f7a944070b..7a33d26064f 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -57,8 +57,8 @@ class AgendaEvents extends DolibarrApi * * Return an array with Agenda Events informations * - * @param int $id ID of Agenda Events - * @return array|mixed Data without useless information + * @param int $id ID of Agenda Events + * @return Object Object with cleaned properties * * @throws RestException */ @@ -289,7 +289,7 @@ class AgendaEvents extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'delete')) { throw new RestException(401, "Insufficient rights to delete your Agenda Event"); } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index c7ab296a2a9..d40a8b15240 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -195,16 +195,16 @@ class CActionComm } if ($qualified && !empty($obj->module)) { - //var_dump($obj->type.' '.$obj->module.' '); var_dump($user->rights->facture->lire); + //var_dump($obj->type.' '.$obj->module.' '); var_dump($user->hasRight('facture', 'lire')); $qualified = 0; // Special cases - if ($obj->module == 'invoice' && isModEnabled('facture') && !empty($user->rights->facture->lire)) { + if ($obj->module == 'invoice' && isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $qualified = 1; } - if ($obj->module == 'order' && isModEnabled('commande') && empty($user->rights->commande->lire)) { + if ($obj->module == 'order' && isModEnabled('commande') && !$user->hasRight('commande', 'lire')) { $qualified = 1; } - if ($obj->module == 'propal' && isModEnabled("propal") && !empty($user->rights->propal->lire)) { + if ($obj->module == 'propal' && isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $qualified = 1; } if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (isModEnabled('supplier_invoice') && !empty($user->rights->supplier_invoice->lire)))) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 851f4419179..95387ec4cb0 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -92,7 +92,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); $permissiontoadd = $usercancreate; @@ -305,7 +305,7 @@ if ($object->id > 0) { $modulepart = 'actions'; - $permissiontoadd = $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create'); + $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d9089f03c14..744253208b9 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -91,13 +91,13 @@ if ($socid < 0) { } $canedit = 1; -if (empty($user->rights->agenda->myactions->read)) { +if (!$user->hasRight('agenda', 'myactions', 'read')) { accessforbidden(); } -if (empty($user->rights->agenda->allactions->read)) { +if (!$user->hasRight('agenda', 'allactions', 'read')) { $canedit = 0; } -if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } @@ -584,7 +584,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Local calendar $s .= '
'.$langs->trans("LocalAgenda").'  
'; - if ($user->rights->holiday->read) { + if ($user->hasRight("holiday", "read")) { // Holiday calendar $s .= '
rights->holiday->read) { +if ($user->hasRight("holiday", "read")) { // LEAVE-HOLIDAY CALENDAR $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; @@ -1875,7 +1875,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } } else { if ($user->hasRight('agenda', 'allactions', 'create') || - (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { + (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { $cssclass .= " movable cursormove"; } else { $cssclass .= " unmovable"; diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index ee34d07ea4b..9d9baff3c3e 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -53,7 +53,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); /* diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 342d0ba1a25..e67d2bdc89c 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -144,13 +144,13 @@ if ($socid < 0) { } $canedit = 1; -if (empty($user->rights->agenda->myactions->read)) { +if (!$user->hasRight('agenda', 'myactions', 'read')) { accessforbidden(); } -if (empty($user->rights->agenda->allactions->read)) { +if (!$user->hasRight('agenda', 'allactions', 'read')) { $canedit = 0; } -if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } @@ -267,7 +267,7 @@ if (empty($reshook)) { $uploaddir = true; // Only users that can delete any event can remove records. $permissiontodelete = $user->rights->agenda->allactions->delete; - $permissiontoadd = $user->rights->agenda->myactions->create; + $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create'); include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -401,7 +401,7 @@ $arrayofmassactions = array( if ($user->rights->agenda->allactions->delete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->agenda->myactions->create) { +if (isModEnabled('category') && $user->hasRight('agenda', 'myactions', 'create')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 9d3bd0044e4..6c8925869e8 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -89,13 +89,13 @@ if ($socid < 0) { // Permissions $canedit = 1; -if (empty($user->rights->agenda->myactions->read)) { +if (!$user->hasRight('agenda', 'myactions', 'read')) { accessforbidden(); } -if (empty($user->rights->agenda->allactions->read)) { +if (!$user->hasRight('agenda', 'allactions', 'read')) { $canedit = 0; } -if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index a2b1aad9d6a..7af29fdc84a 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -85,13 +85,13 @@ if ($socid < 0) { } $canedit = 1; -if (empty($user->rights->agenda->myactions->read)) { +if (!$user->hasRight('agenda', 'myactions', 'read')) { accessforbidden(); } -if (empty($user->rights->agenda->allactions->read)) { +if (!$user->hasRight('agenda', 'allactions', 'read')) { $canedit = 0; } -if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me $filtert = $user->id; } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b6713c5e257..2bab31751c3 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -606,7 +606,7 @@ if ($object->id > 0) { } // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $langs->load("categories"); print ''.$langs->trans("CustomersCategoriesShort").''; print ''; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 4be7cd47f4c..1ae1ae0a6fb 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -799,7 +799,7 @@ if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $use /* * Last actions */ -/*if ($user->rights->agenda->myactions->read) { +/*if ($user->hasRight('agenda', 'myactions', 'read')) { show_array_last_actions_done($max); }*/ @@ -807,7 +807,7 @@ if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $use /* * Actions to do */ -/*if ($user->rights->agenda->myactions->read) { +/*if ($user->hasRight('agenda', 'myactions', 'read')) { show_array_actions_to_do($max); }*/ diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e9013aa2f6b..aaa946fd2fe 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -257,9 +257,9 @@ if (empty($reshook)) { $substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) - $substitutionarray['__CHECK_READ__'] = ''; - $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; - $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'-'.$obj->tag.'-'.$obj->email.'-'.$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid); + $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; + $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY').'-'.$obj->tag.'-'.$obj->email.'-'.$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid); $onlinepaymentenabled = 0; if (isModEnabled('paypal')) { @@ -489,9 +489,9 @@ if (empty($reshook)) { // other are set at begin of page $substitutionarray['__EMAIL__'] = $object->sendto; $substitutionarray['__MAILTOEMAIL__'] = ''.$object->sendto.''; - $substitutionarray['__CHECK_READ__'] = 'sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0" width="1" height="1" style="width:1px;height:1px" border="0"/>'; - $substitutionarray['__UNSUBSCRIBE__'] = 'sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0" target="_blank" rel="noopener noreferrer">'.$langs->trans("MailUnsubcribe").''; - $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-undefinedintestmode-".$obj->sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0'; + $substitutionarray['__CHECK_READ__'] = 'sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0" width="1" height="1" style="width:1px;height:1px" border="0"/>'; + $substitutionarray['__UNSUBSCRIBE__'] = 'sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0" target="_blank" rel="noopener noreferrer">'.$langs->trans("MailUnsubcribe").''; + $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag=undefinedintestmode&unsuscrib=1&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')."-undefinedintestmode-".$obj->sendto."-0", 'md5').'&email='.urlencode($obj->sendto).'&mtid=0'; // Subject and message substitutions complete_substitutions_array($substitutionarray, $langs, $targetobject); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f0fb4a9bf7d..067cbce8efe 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -405,7 +405,7 @@ if ($object->fetch($id) >= 0) { print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic'); print '
'; - print '
'; + print '
'; print '
'; print '
'; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index 81e5cd0d9d2..fe6c733713b 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -54,7 +54,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid * Actions */ -if ($action == 'setpricelevel' && $user->rights->societe->creer) { +if ($action == 'setpricelevel' && $user->hasRight('societe', 'creer')) { $soc = new Societe($db); $soc->fetch($id); $soc->setPriceLevel(GETPOST("price_level"), $user); diff --git a/htdocs/comm/propal/agenda.php b/htdocs/comm/propal/agenda.php index c679fd267da..aa8f5d4aecb 100644 --- a/htdocs/comm/propal/agenda.php +++ b/htdocs/comm/propal/agenda.php @@ -194,7 +194,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=' 0) { $res = $soc->fetch($socid); + + if (GETPOSTINT('cond_reglement_id') == 0) { + $cond_reglement_id = $soc->cond_reglement_id; + } + if (GETPOSTINT('mode_reglement_id') == 0) { + $mode_reglement_id = $soc->mode_reglement_id; + } } // Load objectsrc @@ -1764,6 +1773,15 @@ if ($action == 'create') { } } + // when payment term is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($cond_reglement_id)) { + $cond_reglement_id = GETPOST("cond_reglement_id", 'int'); + } + // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($mode_reglement_id)) { + $mode_reglement_id = GETPOST("mode_reglement_id", 'int'); + } + //Warehouse default if null if ($soc->fk_warehouse > 0) { $warehouse_id = $soc->fk_warehouse; @@ -1868,15 +1886,13 @@ if ($action == 'create') { print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); // at last resort we take the payment term id which may be filled by default values set (if not getpostisset) - $paymentTermId = (GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id', 'int') != 0) ? GETPOST('cond_reglement_id', 'int') : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : GETPOST('cond_reglement_id', 'int')); - print $form->getSelectConditionsPaiements($paymentTermId, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); + print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); print ''; // Mode of payment print ''.$langs->trans('PaymentMode').''; print img_picto('', 'bank', 'class="pictofixedwidth"'); - $paymentMethod = (GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id', 'int') != 0) ? GETPOST('mode_reglement_id', 'int') : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : GETPOST('mode_reglement_id', 'int')); - print $form->select_types_paiements($paymentMethod, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1); print ''; // Bank Account @@ -2800,7 +2816,7 @@ if ($action == 'create') { print '' . $langs->trans('AmountTTC') . ''; print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index fdb44741e48..8658c759202 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -121,7 +121,7 @@ class Proposals extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if (!DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } @@ -162,7 +162,7 @@ class Proposals extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } @@ -295,7 +295,7 @@ class Proposals extends DolibarrApi { $filters = ""; - if (!DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b3f3d387df3..40ea890c846 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1674,7 +1674,7 @@ class Propal extends CommonObject $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->deposit_percent = $obj->deposit_percent; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; @@ -2108,7 +2108,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; - $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -2166,9 +2166,10 @@ class Propal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_end_validity != '' ? "'".$this->db->idate($date_end_validity)."'" : 'null'); - $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".((int) self::STATUS_DRAFT); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->error(); @@ -3721,6 +3722,7 @@ class Propal extends CommonObject { global $conf, $langs, $user; + $langs->load('propal'); $datas = []; $nofetch = !empty($params['nofetch']); @@ -3811,7 +3813,7 @@ class Propal extends CommonObject } $url = ''; - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { if ($option == '') { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id.$get_params; } elseif ($option == 'compta') { // deprecated diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e998f8487b3..753c449a278 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1144,7 +1144,7 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view products - if (isModEnabled('categorie') && $user->hasRight('categorie', 'read') && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'read') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { $searchCategoryProductOperator = -1; include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -1834,8 +1834,8 @@ if ($resql) { // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; + print ''; + print dol_escape_htmltag($obj->town); print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index ace4556fb62..36eb458f252 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -68,7 +68,8 @@ $usercancreate = $user->hasRight("propal", "creer"); $permissionnote = $user->rights->propal->creer; // Used by the include of actions_setnotes.inc.php -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 8aa72d9c43f..b81a31e1891 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -62,7 +62,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { print ''.$objectlink->ref_client.''; print ''.dol_print_date($objectlink->date, 'day').''; print ''; - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index c9ca03380a0..e7d386e348a 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -68,7 +68,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permissiontocreate) { //if ($user->rights->societe->creer) - //if ($user->rights->facture->creer) + //if ($user->hasRight('facture', 'creer')) $amount_ttc_1 = GETPOST('amount_ttc_1', 'alpha'); $amount_ttc_1 = price2num($amount_ttc_1); @@ -159,7 +159,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi if ($action == 'setremise' && $permissiontocreate) { //if ($user->rights->societe->creer) - //if ($user->rights->facture->creer) + //if ($user->hasRight('facture', 'creer')) $amount = price2num(GETPOST('amount', 'alpha'), '', 2); $desc = GETPOST('desc', 'alpha'); @@ -199,7 +199,7 @@ if ($action == 'setremise' && $permissiontocreate) { if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $permissiontocreate) { //if ($user->rights->societe->creer) - //if ($user->rights->facture->creer) + //if ($user->hasRight('facture', 'creer')) $db->begin(); diff --git a/htdocs/commande/agenda.php b/htdocs/commande/agenda.php index 0cb944afa63..08dfd32df95 100644 --- a/htdocs/commande/agenda.php +++ b/htdocs/commande/agenda.php @@ -194,7 +194,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='' . price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { // Multicurrency Amount TTC - print '' . price($object->total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . ''; } print ''; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index ae9625fbcb5..b82bd618a42 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -118,7 +118,7 @@ class Orders extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -165,7 +165,7 @@ class Orders extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -301,7 +301,7 @@ class Orders extends DolibarrApi */ public function getLines($id) { - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -504,7 +504,7 @@ class Orders extends DolibarrApi */ public function getContacts($id, $type = '') { - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } @@ -943,7 +943,7 @@ class Orders extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if (!DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(401); } if (!DolibarrApiAccess::$user->rights->commande->creer) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2f58c5576c7..ebd637bd43d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1980,7 +1980,7 @@ class Commande extends CommonOrder $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); $this->lines = array(); @@ -3753,7 +3753,7 @@ class Commande extends CommonOrder if ($user->hasRight('commande', 'lire')) { $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Order").''; if (isset($this->statut)) { - $datas[] = ' '.$this->getLibStatut(5); + $datas['status'] = ' '.$this->getLibStatut(5); } $datas['Ref'] = '
'.$langs->trans('Ref').': '.$this->ref; if (!$nofetch) { @@ -4181,7 +4181,7 @@ class Commande extends CommonOrder $now = dol_now(); - return max($this->date, $this->date_livraison) < ($now - $conf->commande->client->warning_delay); + return max($this->date, $this->delivery_date) < ($now - $conf->commande->client->warning_delay); } /** @@ -4193,7 +4193,7 @@ class Commande extends CommonOrder { global $conf, $langs; - if (empty($this->date_livraison)) { + if (empty($this->delivery_date)) { $text = $langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); } else { $text = $text = $langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day'); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 3ada37889db..ead429c7152 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -106,7 +106,7 @@ $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', $search_login = GETPOST('search_login', 'alpha'); $search_categ_cus = GETPOST("search_categ_cus", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); +$search_billed = GETPOST('search_billed', 'int'); $search_status = GETPOST('search_status', 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); @@ -1642,13 +1642,13 @@ if ($resql) { // Amount/Total (TTC / gross) in foreign currency if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { print ''; - print ''; + print ''; print ''; } // Author if (!empty($arrayfields['u.login']['checked'])) { - print ''; - print ''; + print ''; + print ''; print ''; } // Sales Representative @@ -1843,7 +1843,7 @@ if ($resql) { print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); } if (!empty($arrayfields['u.login']['checked'])) { - print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['sale_representative']['checked'])) { print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); @@ -2089,7 +2089,7 @@ if ($resql) { // If module invoices enabled and user with invoice creation permissions if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { print ' 
'; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 166afaeb5b3..884ba9cf390 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -813,7 +813,7 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( - 'GenerateOrdersSuppliers'=>img_picto('', 'doc', 'class="pictofixedwidth"').$langs->trans("GenerateOrdersSupplie"), + // TODO add mass action here ); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -875,7 +875,7 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view prospects other than his' - if (isModEnabled("categorie") && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -883,7 +883,7 @@ if ($resql) { $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); $moreforfilter .= '
'; } - if (isModEnabled("categorie") && $user->rights->categorie->lire) { + if (isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); @@ -1436,7 +1436,8 @@ if ($resql) { if (empty($i)) { $oldref = $obj->product_ref; } - if ($oldref != $obj->product_ref) { + if ($oldref != $obj->product_ref && $sortfield == 'pr.ref') { + // TODO make new /core/tpl/list_print_sub_total.php include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; $oldref = $obj->product_ref; } @@ -1600,7 +1601,7 @@ if ($resql) { // If module invoices enabled and user with invoice creation permissions if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { print ' '; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; @@ -1995,83 +1996,79 @@ if ($resql) { print ''; if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { - $generic_commande->getLinesArray(); // Load array ->lines $generic_commande->loadExpeditions(); // Load array ->expeditions - $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig = 0; $lig < $numlines; $lig++) { - if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { - $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; + if (isset($generic_commande->expeditions[$obj->rowid])) { + $reliquat = $obj->qty - $generic_commande->expeditions[$obj->rowid]; + } else { + $reliquat = $obj->qty; + } + if ($obj->product_type == 0 && $obj->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $obj->fk_product; + + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$obj->fk_product])) { + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$obj->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { - $reliquat = $generic_commande->lines[$lig]->qty; + $generic_product->stock_reel = $productstat_cache[$obj->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$obj->fk_product]['stock_reel'] = $generic_product->stock_theorique; } - if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service - $nbprod++; // order contains real products - $generic_product->id = $generic_commande->lines[$lig]->fk_product; - // Get local and virtual stock and store it into cache - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; - $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; - } else { - $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; - $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; - } - - if ($reliquat > $generic_product->stock_reel) { - $notshippable++; - } - if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; - $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; - } else { // BUGGED CODE. - // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. - // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE - // Detailed virtual stock, looks bugged, uncomplete and need heavy load. - // stock order and stock order_supplier - $stock_order = 0; - $stock_order_supplier = 0; - if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? - if (!empty($conf->commande->enabled)) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { - $generic_product->load_stats_commande(0, '1,2'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; - } else { - $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; - } - $stock_order = $generic_product->stats_commande['qty']; + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$obj->product_ref.' '.dol_trunc($obj->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $obj->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (!empty($conf->commande->enabled)) { + if (empty($productstat_cache[$obj->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$obj->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$obj->fk_product]['stats_order_customer']; } - if (isModEnabled('supplier_order')) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { - $generic_product->load_stats_commande_fournisseur(0, '3'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; - } else { - $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; - } - $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; - } - } - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; - if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { - $warning++; - $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } - if ($reliquat > $generic_product->stock_reel) { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } else { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + $stock_order = $generic_product->stats_commande['qty']; } if (isModEnabled('supplier_order')) { - $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + if (empty($productstat_cache[$obj->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$obj->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$obj->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; } + $text_info .= $reliquat.' x '.$obj->product_ref.' '.dol_trunc($obj->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $obj->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if (isModEnabled('supplier_order')) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + } + $text_info .= ($reliquat != $obj->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($obj->qty - $reliquat).')' : ''); + $text_info .= '
'; } } if ($notshippable == 0) { diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 57eb073bba3..edcd2a14f16 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -68,7 +68,8 @@ if (!$object->fetch($id, $ref) > 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 01738d91a06..2956208612a 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -135,7 +135,7 @@ if (empty($entity)) { $error = 0; $listofchoices = array( - 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)), + 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => $user->hasRight('facture', 'lire')), 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)), 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)), 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)), diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index f3047dacf3e..e6b51ec3c04 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -192,13 +192,16 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { } print ''; +for ($annee = $year_start; $annee <= $year_end; $annee++) { + $totsorties[$annee] = 0; + $totentrees[$annee] = 0; +} + for ($mois = 1; $mois < 13; $mois++) { print ''; print "".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B").""; - for ($annee = $year_start; $annee <= $year_end; $annee++) { - $totsorties[$annee] = 0; - $totentrees[$annee] = 0; + for ($annee = $year_start; $annee <= $year_end; $annee++) { $case = sprintf("%04s-%02s", $annee, $mois); print ' '; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index ac429de383f..90d336379d2 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -231,7 +231,7 @@ if (empty($reshook)) { $objectclass = 'Account'; $objectlabel = 'BankTransaction'; $permissiontoread = !empty($user->rights->banque->lire); - $permissiontodelete = !empty($user->rights->banque->modifier); + $permissiontodelete = $user->hasRight('banque', 'modifier'); $uploaddir = $conf->bank->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -328,7 +328,7 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' } -if (GETPOST('save') && !$cancel && !empty($user->rights->banque->modifier)) { +if (GETPOST('save') && !$cancel && $user->hasRight('banque', 'modifier')) { $error = 0; if (price2num(GETPOST("addcredit")) > 0) { @@ -388,7 +388,7 @@ if (GETPOST('save') && !$cancel && !empty($user->rights->banque->modifier)) { } } -if ($action == 'confirm_delete' && $confirm == 'yes' && !empty($user->rights->banque->modifier)) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'modifier')) { $accline = new AccountLine($db); $result = $accline->fetch(GETPOST("rowid", "int")); $result = $accline->delete($user); @@ -605,6 +605,12 @@ $sql .= " ".MAIN_DB_PREFIX."bank as b"; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; } + +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; if ($search_account > 0) { @@ -879,7 +885,7 @@ if ($resql) { } // Form to add a transaction with no invoice - if (!empty($user->rights->banque->modifier) && $action == 'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { + if ($user->hasRight('banque', 'modifier') && $action == 'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { print load_fiche_titre($langs->trans("AddBankRecordLong"), '', ''); print ''; @@ -1039,7 +1045,7 @@ if ($resql) { if (isModEnabled('categorie')) { // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $langs->load('categories'); // Bank line @@ -1730,6 +1736,11 @@ if ($resql) { } } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook + print $hookmanager->resPrint; + // Action edit/delete and select print ''; - print ''; + print ''; // Label print ''; @@ -643,7 +654,8 @@ if ($action == 'create') { if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') { // Show tabs $head = bank_prepare_head($object); - print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); + + print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account', 0, '', '', 0, '', 1); $formconfirm = ''; @@ -665,7 +677,7 @@ if ($action == 'create') { print '
'; print '
'; - print '
'; // Transaction reconciliated or edit link diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 6f08fb17054..42f9a2e8d0c 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -56,6 +56,7 @@ $langs->loadLangs(array("banks", "bills", "categories", "companies", "compta", " $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $object = new Account($db); $extrafields = new ExtraFields($db); @@ -213,7 +214,17 @@ if (empty($reshook)) { } if (!$error) { + $noback = 0; + $db->commit(); + + $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + + if (empty($noback)) { + header("Location: " . $urltogo); + exit; + } } else { $db->rollback(); } @@ -389,7 +400,7 @@ if ($action == 'create') { // Ref print '
'.$langs->trans("Ref").'ref).'" maxlength="12" autofocus>
ref).'" maxlength="12" autofocus>
'.$langs->trans("LabelBankCashAccount").'
'; + print '
'; // Type print ''; @@ -1016,6 +1028,8 @@ if ($action == 'create') { if (isModEnabled('categorie')) { print ''; + print ''; print ''; // BIC - print ''; + print ''; print ''; // Show fields of bank account diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7a39b845dd3..f6d7160160e 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -992,8 +992,6 @@ class Account extends CommonObject */ public function fetch($id, $ref = '') { - global $conf; - if (empty($id) && empty($ref)) { $this->error = "ErrorBadParameters"; return -1; @@ -1338,7 +1336,7 @@ class Account extends CommonObject * Charge indicateurs this->nb de tableau de bord * * @param int $filteraccountid To get info for a particular account id - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function load_state_board($filteraccountid = 0) { @@ -1366,6 +1364,7 @@ class Account extends CommonObject $this->nb["banklines"] = $obj->nb; } $this->db->free($resql); + return 1; } else { dol_print_error($this->db); $this->error = $this->db->error(); @@ -2569,8 +2568,9 @@ class AccountLine extends CommonObjectLine $result .= $langs->trans("BankLineConciliated").': '; $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliatedandaccounted') { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->id); + if (isModEnabled('accounting') && ($option == 'showall' || $option == 'showconciliatedandaccounted')) { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -2611,7 +2611,8 @@ class AccountLine extends CommonObjectLine public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; + //global $langs; + //$langs->load('companies'); /* if ($mode == 0) @@ -2644,6 +2645,8 @@ class AccountLine extends CommonObjectLine if ($status==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); if ($status==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ + + return ''; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index f9a4f8065bb..e81981a7490 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -121,8 +121,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return Object Object with cleaned properties + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 8e7ccc4183f..33342098dbc 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2023 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 @@ -34,7 +34,7 @@ class PaymentVarious extends CommonObject /** * @var string ID to identify managed object */ - public $element = 'variouspayment'; + public $element = 'payment_various'; /** * @var string Name of table without prefix where object is stored @@ -184,8 +184,6 @@ class PaymentVarious extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - $this->element = 'payment_various'; - $this->table_element = 'payment_various'; } /** diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index fd75c9ceaee..d8517391e17 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -588,7 +588,7 @@ if ($result) { print ""; // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $langs->load('categories'); // Bank line diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 301838c9a46..5f4cf425b79 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -394,7 +394,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $moreforfilter = ''; -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list); } @@ -422,7 +422,7 @@ print '
'.$langs->trans("AccountType").'
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + + $arrayselected = array(); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { @@ -1096,11 +1110,17 @@ if ($action == 'create') { } // IBAN - print '
'.$langs->trans($ibankey).'
'; + $tooltip = $langs->trans("Example").':
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; + print $form->textwithpicto($langs->trans($ibankey), $tooltip); + print '
'.$langs->trans($bickey).'
'; + $tooltip = $langs->trans("Example").': LIABLT2XXXX'; + print $form->textwithpicto($langs->trans($bickey), $tooltip); + print '
'; +print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; } // Balance @@ -835,7 +835,7 @@ if (!$found) { $colspan++; } } - print ''; + print ''; } // Show total line diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index e0a7fb39a5e..36855eb653c 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -47,6 +47,7 @@ if ($user->socid) { $optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST('mode', 'alpha'); +$massaction = GETPOST('massaction', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); @@ -679,7 +680,7 @@ while ($i < $imaxinloop) { // Date payment if ($arrayfields['datep']['checked']) { - print '"; + print '"; if (!$i) { $totalarray['nbfield']++; } @@ -688,7 +689,7 @@ while ($i < $imaxinloop) { // Date value if ($arrayfields['datev']['checked']) { - print '"; + print '"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 8db4516d3dd..c5fe5ae9868 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -36,7 +36,7 @@ if ($user->socid > 0) { $socid = $user->socid; } -if (!$user->rights->facture->lire) { +if (!$user->hasRight('facture', 'lire')) { accessforbidden(); } diff --git a/htdocs/compta/facture/agenda.php b/htdocs/compta/facture/agenda.php index 2442f9ce662..2f6075fbd52 100644 --- a/htdocs/compta/facture/agenda.php +++ b/htdocs/compta/facture/agenda.php @@ -222,7 +222,7 @@ if ($object->id > 0) { } - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 4efbabbaf49..7004ef52a0a 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1214,22 +1214,22 @@ if ($action == 'create') { $morehtmlref = ''; if ($action != 'editref') { - $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); + $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->hasRight('facture', 'creer'), '', '', 0, 2); } else { - $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); + $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->hasRight('facture', 'creer'), 'string'); } $morehtmlref .= '
'; // Ref customer - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); + //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('facture', 'creer'), 'string', '', 0, 1); + //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('facture', 'creer'), 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } @@ -1410,17 +1410,17 @@ if ($action == 'create') { // Note public print '
'; print ''; // Note private print ''; print ''; @@ -1460,7 +1460,7 @@ if ($action == 'create') { $list[] = str_replace(':', '|', $k).':'.$model; } $select = 'select;'.implode(',', $list); - print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); + print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->hasRight('facture', 'creer'), $select); } else { print $object->model_pdf; } @@ -1521,13 +1521,13 @@ if ($action == 'create') { // Date when (next invoice generation) print ''; // Auto generate documents @@ -1574,7 +1574,7 @@ if ($action == 'create') { print ''; print ''; print ''; @@ -1684,7 +1684,7 @@ if ($action == 'create') { ), ); if (empty($object->suspended)) { - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) { print ''; } else { @@ -1699,7 +1699,7 @@ if ($action == 'create') { } } - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { if (empty($object->suspended)) { print ''; } else { @@ -1708,7 +1708,7 @@ if ($action == 'create') { } // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete&token=' . newToken(), 'delete', $user->rights->facture->supprimer); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete&token=' . newToken(), 'delete', $user->hasRight('facture', 'supprimer')); } print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5601eb5838d..5fb7442d379 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -306,7 +306,7 @@ if (empty($reshook)) { } elseif ($action == 'unlinkdiscount' && $usercancreate) { // Delete link of credit note to invoice $discount = new DiscountAbsolute($db); - $result = $discount->fetch(GETPOST("discountid")); + $result = $discount->fetch(GETPOSTINT("discountid")); $discount->unlink_invoice(); } elseif ($action == 'valid' && $usercancreate) { // Validation @@ -4423,17 +4423,17 @@ if ($action == 'create') { print ''; // Amount HT print ''; @@ -4849,7 +4848,7 @@ if ($action == 'create') { print ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { // Multicurrency Amount TTC - print ''; + print ''; } print ''; @@ -5211,7 +5210,9 @@ if ($action == 'create') { print ''; print ''; print ''; $i++; if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 96ecf3381b2..d48740ea68d 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -127,7 +127,7 @@ class Invoices extends DolibarrApi */ private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } @@ -180,7 +180,7 @@ class Invoices extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } @@ -338,7 +338,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - if (!DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(401); } if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -372,7 +372,7 @@ class Invoices extends DolibarrApi */ public function getLines($id) { - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } @@ -647,7 +647,7 @@ class Invoices extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->facture->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'supprimer')) { throw new RestException(401); } $result = $this->invoice->fetch($id); @@ -1029,7 +1029,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } @@ -1331,7 +1331,7 @@ class Invoices extends DolibarrApi public function getPayments($id) { - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } if (empty($id)) { @@ -1741,7 +1741,7 @@ class Invoices extends DolibarrApi */ private function _fetchTemplateInvoice($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if (!DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'lire')) { throw new RestException(401); } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ff4658e96b0..72b56e3920c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -237,9 +237,15 @@ class Facture extends CommonInvoice */ public $lines = array(); + /** + * @var FactureLigne + */ public $line; public $extraparams = array(); + /** + * @var int ID facture rec + */ public $fac_rec; public $date_pointoftax; @@ -2238,7 +2244,7 @@ class Facture extends CommonInvoice $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit); $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -2461,8 +2467,6 @@ class Facture extends CommonInvoice */ public function update(User $user, $notrigger = 0) { - global $conf; - $error = 0; // Clean parameters @@ -4436,7 +4440,7 @@ class Facture extends CommonInvoice $remise = 0; } - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { $remise = price2num($remise, 2); $error = 0; @@ -4500,7 +4504,7 @@ class Facture extends CommonInvoice $remise = 0; } - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { $error = 0; $this->db->begin(); @@ -5629,11 +5633,11 @@ class Facture extends CommonInvoice * @param int $nbdays Delay before due date (or after if delay is negative) * @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ... * @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send') - * @param string $forcerecipient Force email of recipient (for example to send the email to an accountant supervisor instead of the customer) * @param string $datetouse 'duedate' (default) or 'invoicedate' + * @param string $forcerecipient Force email of recipient (for example to send the email to an accountant supervisor instead of the customer) * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode = 'all', $template = '', $forcerecipient = '', $datetouse = 'duedate') + public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode = 'all', $template = '', $datetouse = 'duedate', $forcerecipient = '') { global $conf, $langs, $user; @@ -5829,7 +5833,7 @@ class Facture extends CommonInvoice $actioncomm->contact_id = 0; $actioncomm->code = 'AC_EMAIL'; - $actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateOK (nbdays='.$nbdays.' paymentmode='.$paymentmode.' template='.$template.' forcerecipient='.$forcerecipient.' datetouse='.$datetouse.')'; + $actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateOK (nbdays='.$nbdays.' paymentmode='.$paymentmode.' template='.$template.' datetouse='.$datetouse.' forcerecipient='.$forcerecipient.')'; $actioncomm->note_private = $sendContent; $actioncomm->fk_project = $tmpinvoice->fk_project; $actioncomm->datep = dol_now(); @@ -6010,6 +6014,9 @@ class FactureLigne extends CommonInvoiceLine */ public $table_element = 'facturedet'; + /** + * @var FactureLigne + */ public $oldline; //! From llx_facturedet @@ -6067,6 +6074,16 @@ class FactureLigne extends CommonInvoiceLine public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** + * Constructor + * + * @param DoliDB $db handler d'acces base de donnee + */ + public function __construct($db) + { + $this->db = $db; + } + /** * Load invoice line from database * @@ -6153,6 +6170,8 @@ class FactureLigne extends CommonInvoiceLine $this->multicurrency_total_tva = $objp->multicurrency_total_tva; $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->fetch_optionals(); + $this->db->free($result); return 1; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 8625be6438e..56ef08d1f1e 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -854,7 +854,7 @@ while ($i < $imaxinloop) { // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print '
'; @@ -497,7 +497,7 @@ if (!empty($arrayfields['b.clos']['checked'])) { 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") ); - print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth125 onrightofpage', 1); + print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75 maxwidth125 onrightofpage', 1); print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'.dol_print_date($obj->datep, 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($obj->datev, 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."
'; - print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer); + print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer')); print ''; - print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); + print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); print '
'; - print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer); + print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer')); print ''; - print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); + print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->hasRight('facture', 'creer'), 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); print '
'; if ($action == 'date_when' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); + print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->hasRight('facture', 'creer'), 'day'); } else { print $langs->trans("NextDateToExecution"); } print ''; if ($action == 'date_when' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->hasRight('facture', 'creer'), 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); } //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); if (!$object->isMaxNbGenReached()) { @@ -1543,13 +1543,13 @@ if ($action == 'create') { // Max period / Rest period print '
'; if ($action == 'nb_gen_max' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); + print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->hasRight('facture', 'creer')); } else { print $langs->trans("MaxPeriodNumber"); } print ''; if ($action == 'nb_gen_max' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->hasRight('facture', 'creer')); } else { print ''; } @@ -1559,14 +1559,14 @@ if ($action == 'create') { // Status of generated invoices print '
'; if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer')); } else { print $langs->trans("StatusOfGeneratedInvoices"); } print ''; $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); + print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->hasRight('facture', 'creer'), $select); } print '
'; if ($action == 'generate_pdf' || $object->frequency > 0) { - print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); + print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->hasRight('facture', 'creer')); } else { print $langs->trans("StatusOfGeneratedDocuments"); } @@ -1582,7 +1582,7 @@ if ($action == 'create') { print ''; $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc'); if ($action == 'generate_pdf' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select); + print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->hasRight('facture', 'creer'), $select); } print '
'.$langs->trans('Type').''; print $object->getLibType(2); if ($object->module_source) { - print ' ('.$langs->trans("POS").' '.ucfirst($object->module_source).' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; + print ' ('.$langs->trans("POS").' '.dol_escape_htmltag(ucfirst($object->module_source)).' - '.$langs->trans("Terminal").' '.dol_escape_htmltag($object->pos_source).')'; } if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); - print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).''; + print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1, '', 32)).''; } if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); - print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).''; + print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; } $facidavoir = $object->getListIdAvoirFromInvoice(); @@ -4448,7 +4448,7 @@ if ($action == 'create') { } $facavoir = new Facture($db); $facavoir->fetch($id); - print $facavoir->getNomUrl(1); + print $facavoir->getNomUrl(1, '', 32); } print ''; } @@ -4477,7 +4477,7 @@ if ($action == 'create') { if ($result > 0) { print ' '; $s = $langs->transnoentities("GeneratedFromTemplate", '{s1}'); - $s = str_replace('{s1}', ''.dol_escape_htmltag($tmptemplate->ref).'', $s); + $s = str_replace('{s1}', $tmptemplate->getNomUrl(1, '', 32), $s); print $s; print ''; } @@ -4801,7 +4801,6 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { $sign = -1; // We invert sign for output } - print '
' . $langs->trans('AmountHT') . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '' . price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.price($obj->amount_ttc).''; - print 'rowid.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print 'rowid.'">'; + print img_picto($langs->transnoentitiesnoconv("RemoveDiscount"), 'unlink'); + print ''; print '
'; - if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) { + if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) { if ($invoicerectmp->isMaxNbGenReached()) { print $langs->trans("MaxNumberOfGenerationReached"); } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { @@ -1044,7 +1044,7 @@ while ($i < $imaxinloop) { // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; - if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) { + if ($user->hasRight('facture', 'creer') && empty($invoicerectmp->suspended)) { if ($invoicerectmp->isMaxNbGenReached()) { print $langs->trans("MaxNumberOfGenerationReached"); } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a64a24c791f..5e5dde00ab2 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -187,10 +187,10 @@ $error = 0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Facture($db); -$hookmanager->initHooks(array('invoicelist')); +$hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -392,7 +392,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($action == 'makepayment_confirm' && !empty($user->rights->facture->paiement)) { +if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement')) { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); if (!empty($arrayofselected)) { @@ -609,6 +609,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +//$sql .= ", COUNT(rc.rowid) as anotherfield"; $sqlfields = $sql; // $sql fields to remove for count total @@ -975,7 +977,10 @@ if ($resql) { exit; } - llxHeader('', $langs->trans('CustomersInvoices'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); + // Output page + // -------------------------------------------------------------------- + + llxHeader('', $title, 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); if ($socid > 0) { $soc = new Societe($db); @@ -1175,7 +1180,7 @@ if ($resql) { 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); - if (!empty($user->rights->facture->paiement)) { + if ($user->hasRight('facture', 'paiement')) { $arrayofmassactions['makepayment'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakePaymentAndClassifyPayed"); } if (isModEnabled('prelevement') && !empty($user->rights->prelevement->bons->creer)) { @@ -1209,7 +1214,6 @@ if ($resql) { $i = 0; print '
'."\n"; - if ($optioncss != '') { print ''; } @@ -1310,13 +1314,14 @@ if ($resql) { } print '
'; - print ''."\n"; + print '
'."\n"; - // Filters lines + // Fields title search + // -------------------------------------------------------------------- print ''; - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - // Action column + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // No if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref @@ -2355,6 +2366,9 @@ if ($resql) { if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['dynamount_payed']['checked'])) { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index b571c8550f1..4962448f18c 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -81,7 +81,7 @@ if ($type == 'bank-transfer') { } } else { $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); - if (!$user->rights->facture->lire) { + if (!$user->hasRight('facture', 'lire')) { accessforbidden(); } } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index b886c5595e1..8e81de43d1f 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -44,7 +44,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $langs->loadLangs(array('bills', 'companies', 'other')); $mode = GETPOST("mode") ? GETPOST("mode") : 'customer'; -if ($mode == 'customer' && !$user->rights->facture->lire) { +if ($mode == 'customer' && !$user->hasRight('facture', 'lire')) { accessforbidden(); } if ($mode == 'supplier' && empty($user->rights->fournisseur->facture->lire)) { diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index c3c774b79e7..84d9db320ef 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -51,7 +51,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
'; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; @@ -1959,11 +1964,17 @@ if ($resql) { print ''; } print ''.(($offset * $limit) + $i).''.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : ' ').' date_when, 'day'); ?> rights->facture->lire) { + if ($user->hasRight('facture', 'lire')) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 9c77eed2540..ddc48e264c4 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -98,9 +98,9 @@ $form = new Form($db); $formfile = new FormFile($db); $thirdpartystatic = new Societe($db); -llxHeader("", $langs->trans("AccountancyTreasuryArea")); +llxHeader("", $langs->trans("InvoicesArea")); -print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); +print load_fiche_titre($langs->trans("InvoicesArea"), '', 'bill'); print '
'; @@ -129,7 +129,7 @@ print '
'; // Latest modified customer invoices -if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { +if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $langs->load("boxes"); $tmpinvoice = new Facture($db); diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index d7b0ccbda73..8873fd26b88 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -91,7 +91,7 @@ if (empty($min)) { // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +$modetax = getDolGlobalString('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOST("modetax", 'int'); } @@ -140,8 +140,9 @@ $fsearch .= ''; $fsearch .= $langs->trans("SalesTurnoverMinimum").': '; $fsearch .= ''; -$calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; +$calc = getDolGlobalString('MAIN_INFO_LOCALTAX_CALC').$local; // Affiche en-tete du rapport +$description=''; if ($calc == 0 || $calc == 1) { // Calculate on invoice for goods and services $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; @@ -178,8 +179,11 @@ if ($calc == 2) { // Invoice for goods, payment for services $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); } -report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); +$periodlink = ''; +$exportlink = ''; + +report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); $vatcust = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); $vatsup = $langs->transcountry($local == 1 ? "LT1" : "LT2", $mysoc->country_code); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index f25b476fa94..f5d1fe1f948 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -80,7 +80,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +$modetax = getDolGlobalString('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOST("modetax", 'int'); } @@ -223,14 +223,14 @@ if ($localTaxType == 1) { $LTPaid = 'LT1Paid'; $LTCustomer = 'LT1Customer'; $LTSupplier = 'LT1Supplier'; - $CalcLT = $conf->global->MAIN_INFO_LOCALTAX_CALC1; + $CalcLT = getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1'); } else { $LT = 'LT2'; $LTSummary = 'LT2Summary'; $LTPaid = 'LT2Paid'; $LTCustomer = 'LT2Customer'; $LTSupplier = 'LT2Supplier'; - $CalcLT = $conf->global->MAIN_INFO_LOCALTAX_CALC2; + $CalcLT = getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2'); } $fsearch = ''; @@ -471,8 +471,8 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $type = 1; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -511,8 +511,8 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $type = 1; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 66c58580df6..f8e5e12e8c8 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -102,8 +102,8 @@ if (empty($min)) { // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products //$modetax = $conf->global->TAX_MODE; -$calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; -$modetax = $conf->global->$calc; +$calc = getDolGlobalString('MAIN_INFO_LOCALTAX_CALC').$local; +$modetax = getDolGlobalInt('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOST("modetax", 'int'); } @@ -169,6 +169,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $year_start; +$q=0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -184,13 +185,13 @@ if ($nextquarter < 4) { $nextquarter = 1; $nextyear++; } -$description .= $fsearch; +$description = $fsearch; $builddate = dol_now(); -/*if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +/*if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description.='
'.$langs->trans("DepositsAreNotIncluded"); } @@ -222,6 +223,8 @@ if ($mysoc->tva_assuj) { $vatsup .= ' ('.$langs->trans("ToGetBack").')'; } +$periodlink = ''; +$exportlink = ''; report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 1828c5d053b..ea36236689b 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -78,7 +78,7 @@ $hookmanager->initHooks(array('paiementcard', 'globalcard')); $formquestion = array(); -$usercanissuepayment = !empty($user->rights->facture->paiement); +$usercanissuepayment = $user->hasRight('facture', 'paiement'); $fieldid = 'rowid'; $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); @@ -360,7 +360,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Invoice with Paypal transaction // TODO add hook here - if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) { + if (isModEnabled('paypalplus') && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) { if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) { $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; } diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 865ce719291..a2873c2e2c3 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -279,8 +279,8 @@ print '
'; print ''."\n"; // Date payment -print ''; // Payment type (VIR, LIQ, ...) @@ -362,7 +362,7 @@ if (isModEnabled("banque")) { print ''; print $langs->trans("NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv("Module85Name")); print ''; - if (!empty($user->rights->facture->paiement)) { + if ($user->hasRight('facture', 'paiement')) { // Try to guess $bankaccountidofinvoices that is ID of bank account defined on invoice. // Return null if not found, return 0 if it has different value for at least 2 invoices, return the value if same on all invoices where a bank is defined. $amountofpayments = $object->getAmountsArray(); @@ -396,8 +396,8 @@ if (isModEnabled("banque")) { } // Comments -print ''; print '
'.$form->editfieldkey("Date", 'datep', $object->date, $object, $user->rights->facture->paiement).''; -print $form->editfieldval("Date", 'datep', $object->date, $object, $user->rights->facture->paiement, 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'), '', 0, '', 'id', 'tzuser'); +print '
'.$form->editfieldkey("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement')).''; +print $form->editfieldval("Date", 'datep', $object->date, $object, $user->hasRight('facture', 'paiement'), 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'), '', 0, '', 'id', 'tzuser'); print '
'.$form->editfieldkey("Comments", 'note', $object->note, $object, $user->rights->facture->paiement).''; -print $form->editfieldval("Note", 'note', $object->note, $object, $user->rights->facture->paiement, 'textarea:'.ROWS_3.':90%'); +print '
'.$form->editfieldkey("Comments", 'note', $object->note, $object, $user->hasRight('facture', 'paiement')).''; +print $form->editfieldval("Note", 'note', $object->note, $object, $user->hasRight('facture', 'paiement'), 'textarea:'.ROWS_3.':90%'); print '
'; @@ -537,14 +537,14 @@ print '
'; if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->socid == 0 && $object->statut == 0 && $action == '') { - if ($user->rights->facture->paiement) { + if ($user->hasRight('facture', 'paiement')) { print ''.$langs->trans('Valid').''; } } } if ($user->socid == 0 && $action == '') { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->facture->paiement && !$disable_delete); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('facture', 'paiement') && !$disable_delete); } print '
'; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7df61ebefcb..d8d538c8d7a 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -306,6 +306,7 @@ class Paiement extends CommonObject if (!empty($currencyofpayment)) { // We must check that the currency of invoices is the same than the currency of the bank + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bankaccount = new Account($this->db); $bankaccount->fetch($this->fk_account); $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index eb27f948b2e..9a114c9a119 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -50,7 +50,7 @@ if (!$year) { } // Security check -if (empty($user->rights->facture->lire)) { +if (!$user->hasRight('facture', 'lire')) { accessforbidden(); } diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 0839d51987e..901f648ba1d 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -53,7 +53,7 @@ if (!$sortfield) { } // Security check -if (empty($user->rights->facture->lire)) { +if (!$user->hasRight('facture', 'lire')) { accessforbidden(); } diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 11f7f1e454f..4a1d44b6c92 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -55,7 +55,7 @@ if ($id > 0) { } } -$result = restrictedArea($user, 'payment_sc', $id, ''); +$result = restrictedArea($user, 'payment_sc', $object, ''); /* @@ -130,26 +130,20 @@ print '
'; print ''; -// Ref -/*print ''; -print '';*/ - // Date -print ''; +print ''; // Mode -print ''; +print ''; // Numero -print ''; +print ''; // Amount -print ''; +print ''; // Note -print ''; +print ''; // Bank account if (isModEnabled("banque")) { @@ -159,7 +153,7 @@ if (isModEnabled("banque")) { print ''; print ''; - print ''; print ''; @@ -252,8 +246,7 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { - if ($user->rights->facture->paiement) - { + if ($user->hasRight('facture', 'paiement')){ print ''.$langs->trans('Valid').''; } } diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 88650256ecc..bf4eb7ecaef 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -125,7 +125,6 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->char llxHeader(); $tva = new TVA($db); - $form = new Form($db); $h = 0; @@ -173,26 +172,20 @@ print '
'; print '
'.$langs->trans('Ref').''; -print $form->showrefnav($object,'id','',1,'rowid','id'); -print '
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_payment.'
'.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).'
'.$langs->trans('Amount').''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Amount').''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note).'
'.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'
'.$langs->trans('BankTransactionLine').''; + print ''; print $bankline->getNomUrl(1, 0, 'showall'); print '
'; -// Ref -/*print ''; -print '';*/ - // Date -print ''; +print ''; // Mode -print ''; +print ''; // Numero -print ''; +print ''; // Montant -print ''; +print ''; // Note -print ''; +print ''; // Bank account if (isModEnabled("banque")) { @@ -202,7 +195,7 @@ if (isModEnabled("banque")) { print ''; print ''; - print ''; print ''; @@ -294,8 +287,7 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { - if ($user->rights->facture->paiement) - { + if ($user->hasRight('facture', 'paiement')) { print ''.$langs->trans('Valid').''; } } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 4e66009d942..9e5f79a0c01 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -27,6 +27,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -273,11 +274,28 @@ if ($id > 0 || $ref) { $labelfororderfield = 'CreditTransferFile'; } print $langs->trans($labelfororderfield).'
'.$langs->trans('Ref').''; -print $form->showrefnav($object,'id','',1,'rowid','id'); -print '
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_paiement.'
'.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note).'
'.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).'
'.$langs->trans('BankTransactionLine').''; + print ''; print $bankline->getNomUrl(1, 0, 'showall'); print '
'; - $relativepath = 'receipts/'.$object->ref.'.xml'; + $modulepart = 'prelevement'; if ($object->type == 'bank-transfer') { $modulepart = 'paymentbybanktransfer'; } + + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output; + } else { + $dir = $conf->paymentbybanktransfer->dir_output; + } + if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility + $relativepath = 'receipts/'.$object->ref.'.xml'; + } + } else { + $relativepath = 'receipts/'.$object->ref.'.xml'; + } + print ''.$relativepath; print img_picto('', 'download', 'class="paddingleft"'); print ''; @@ -434,7 +452,7 @@ if ($id > 0 || $ref) { print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; + print '
'; print ''; print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4784f72d455..e88aa44b3ee 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1061,7 +1061,12 @@ class BonPrelevement extends CommonObject dol_mkdir($dir); } - $this->filename = $dir.'/'.$ref.'.xml'; + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $this->filename = $dir.'/'.$ref.'-'.$labelentity.'.xml'; + } else { + $this->filename = $dir.'/'.$ref.'.xml'; + } // Create withdraw order in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; @@ -1170,7 +1175,7 @@ class BonPrelevement extends CommonObject $this->factures = $factures_prev_id; $this->context['factures_prev'] = $factures_prev; - // Generation of direct debit or credti transfer file $this->filename (May be a SEPA file for european countries) + // Generation of direct debit or credit transfer file $this->filename (May be a SEPA file for european countries) // This also set the property $this->total with amount that is included into file $result = $this->generate($format, $executiondate, $type); if ($result < 0) { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 361b52998ec..1a09f72c604 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -434,11 +434,11 @@ if ($resql) { if ($num) { require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($db); while ($i < $num && $i < $limit) { $obj = $db->fetch_object($resql); + $bac = new CompanyBankAccount($db); // Must include the new in loop so the fetch is clean $bac->fetch(0, $obj->socid); $invoicestatic->id = $obj->rowid; diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 38c02fdc24b..c34db505cc5 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -274,7 +274,9 @@ while ($i < min($num, $limit)) { print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 22da9e20afb..531bd0feda4 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -27,6 +27,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -155,17 +156,34 @@ if ($id > 0 || $ref) { print ''; print ''; + $modulepart = 'prelevement'; + if ($object->type == 'bank-transfer') { + $modulepart = 'paymentbybanktransfer'; + } + print ''; print ''; + $modulepart = 'prelevement'; + if ($object->type == 'bank-transfer') { + $modulepart = 'paymentbybanktransfer'; + } + print ''; print ''; + $modulepart = 'prelevement'; + if ($object->type == 'bank-transfer') { + $modulepart = 'paymentbybanktransfer'; + } + print ''; print ''; print ''; -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { print ''; print ''; + print ''; print ''; @@ -964,7 +964,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''; print ''; - print '
'; + print ''; print price($obj->amount, 1, $langs, 1, -1, -1, $conf->currency).' / '.price($obj->total_ttc, 1, $langs, 1, -1, -1, $conf->currency); + print ''; print ''.dol_print_date($db->jdate($obj->date_demande), 'day').'
'; $labelfororderfield = 'WithdrawalFile'; if ($object->type == 'bank-transfer') { $labelfororderfield = 'CreditTransferFile'; } print $langs->trans($labelfororderfield).''; - $relativepath = 'receipts/'.$object->ref.'.xml'; - $modulepart = 'prelevement'; - if ($object->type == 'bank-transfer') { - $modulepart = 'paymentbybanktransfer'; + + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output; + } else { + $dir = $conf->paymentbybanktransfer->dir_output; + } + if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility + $relativepath = 'receipts/'.$object->ref.'.xml'; + } + } else { + $relativepath = 'receipts/'.$object->ref.'.xml'; } + print ''.$relativepath; print img_picto('', 'download', 'class="paddingleft"'); print ''; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 67a7cf46c33..41d956d66ef 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -27,6 +27,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -149,17 +150,34 @@ if ($id > 0 || $ref) { print '
'; $labelfororderfield = 'WithdrawalFile'; if ($object->type == 'bank-transfer') { $labelfororderfield = 'CreditTransferFile'; } print $langs->trans($labelfororderfield).''; - $relativepath = 'receipts/'.$object->ref.'.xml'; - $modulepart = 'prelevement'; - if ($object->type == 'bank-transfer') { - $modulepart = 'paymentbybanktransfer'; + + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output; + } else { + $dir = $conf->paymentbybanktransfer->dir_output; + } + if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility + $relativepath = 'receipts/'.$object->ref.'.xml'; + } + } else { + $relativepath = 'receipts/'.$object->ref.'.xml'; } + print ''.$relativepath; print img_picto('', 'download', 'class="paddingleft"'); print ''; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index efaab1532f8..a3dad35f9ff 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -26,6 +26,7 @@ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -143,17 +144,34 @@ if ($id > 0 || $ref) { print '
'; $labelfororderfield = 'WithdrawalFile'; if ($object->type == 'bank-transfer') { $labelfororderfield = 'CreditTransferFile'; } print $langs->trans($labelfororderfield).''; - $relativepath = 'receipts/'.$object->ref.'.xml'; - $modulepart = 'prelevement'; - if ($object->type == 'bank-transfer') { - $modulepart = 'paymentbybanktransfer'; + + if (isModEnabled('multicompany')) { + $labelentity = $conf->entity; + $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml'; + + if ($type != 'bank-transfer') { + $dir = $conf->prelevement->dir_output; + } else { + $dir = $conf->paymentbybanktransfer->dir_output; + } + if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility + $relativepath = 'receipts/'.$object->ref.'.xml'; + } + } else { + $relativepath = 'receipts/'.$object->ref.'.xml'; } + print ''.$relativepath; print img_picto('', 'download', 'class="paddingleft"'); print ''; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 8cf005d9ade..4e29351c4cc 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -223,6 +223,12 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +$arrayofmassactions = array( + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), +); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + print ''."\n"; print ''; if ($optioncss != '') { diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index d9f5e7b1d19..c42672d904c 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -172,7 +172,6 @@ $num = $db->num_rows($resql); llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); - $param = ''; $param .= "&statut=".urlencode($statut); if ($type == 'bank-transfer') { @@ -191,6 +190,11 @@ if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +$arrayofmassactions = array( + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), +); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''."\n"; print ''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index a9ab57a7037..187a4ab7b8f 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -79,8 +79,8 @@ if (empty($action) && empty($id) && empty($ref)) { } // Load object -if ($id > 0) { - $object->fetch($id); +if ($id > 0 || $ref) { + $object->fetch($id, $ref); } $permissiontoread = $user->rights->tax->charges->lire; @@ -111,13 +111,11 @@ if ($reshook < 0) { if (empty($reshook)) { // Classify paid - if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { - $object->fetch($id); + if ($action == 'confirm_paid' && $permissiontoadd && $confirm == 'yes') { $result = $object->setPaid($user); } if ($action == 'reopen' && $user->rights->tax->charges->creer) { - $result = $object->fetch($id); if ($object->paye) { $result = $object->setUnpaid($user); if ($result > 0) { @@ -130,19 +128,16 @@ if (empty($reshook)) { } // Link to a project - if ($action == 'classin' && $user->rights->tax->charges->creer) { - $object->fetch($id); + if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('fk_project')); } - if ($action == 'setfk_user' && $user->rights->tax->charges->creer) { - $object->fetch($id); + if ($action == 'setfk_user' && $permissiontoadd) { $object->fk_user = $fk_user; $object->update($user); } - if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); + if ($action == 'setlib' && $permissiontoadd) { $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -150,8 +145,7 @@ if (empty($reshook)) { } // payment mode - if ($action == 'setmode' && $user->rights->tax->charges->creer) { - $object->fetch($id); + if ($action == 'setmode' && $permissiontoadd) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -159,8 +153,7 @@ if (empty($reshook)) { } // Bank account - if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { - $object->fetch($id); + if ($action == 'setbankaccount' && $permissiontoadd) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -168,8 +161,7 @@ if (empty($reshook)) { } // Delete social contribution - if ($action == 'confirm_delete' && $confirm == 'yes') { - $object->fetch($id); + if ($action == 'confirm_delete' && $permissiontodelete && $confirm == 'yes') { $totalpaid = $object->getSommePaiement(); if (empty($totalpaid)) { $result = $object->delete($user); @@ -186,7 +178,7 @@ if (empty($reshook)) { // Add social contribution - if ($action == 'add' && $user->rights->tax->charges->creer) { + if ($action == 'add' && $permissiontoadd) { $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { @@ -224,7 +216,7 @@ if (empty($reshook)) { } - if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { + if ($action == 'update' && !$cancel && $permissiontoadd) { $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { @@ -245,7 +237,7 @@ if (empty($reshook)) { $object->date_ech = $dateech; $object->periode = $dateperiod; $object->amount = $amount; - $object->fk_user = $fk_user; + $object->fk_user = $fk_user; $result = $object->update($user); if ($result <= 0) { @@ -259,12 +251,10 @@ if (empty($reshook)) { $action = ''; } - if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer)) { + if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { $db->begin(); - $originalId = $id; - - $object->fetch($id); + $originalId = $object->id; if ($object->id > 0) { $object->id = $object->ref = null; @@ -358,7 +348,7 @@ if ($action == 'create') { print dol_get_fiche_head(); - print ''; + print '
'; // Label print ""; @@ -583,7 +573,7 @@ if ($id > 0) { print '
'; print '
'; - print '
'; + print '
'; // Type print ''; print ''; foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { - if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print ''; print ''; print ''; @@ -1128,7 +1128,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; print ''; print ''; } } - if ($action != 'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action != 'edit_price_by_qty' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print ''; print ''; print ''; @@ -1260,7 +1260,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; } foreach ($object->prices_by_qty_list[0] as $ii => $prices) { - if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print ''; print ''; print ''; @@ -1289,7 +1289,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print ''; print ''; print ''; // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load('projects'); print ''; @@ -440,7 +440,7 @@ if ($action == 'create') { $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; if ($usercancreate) { @@ -887,7 +887,7 @@ if ($action == 'create') { print ''; // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $projectid = $object->fk_project; $langs->load('projects'); print ''; diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 27b4d2409e9..c71d37bace1 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -57,8 +57,8 @@ class StockMovements extends DolibarrApi * * Return an array with stock movement informations * - * @param int $id ID of movement - * @return array|mixed data without useless information + * @param int $id ID of movement + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 55012aa681c..c7b9e67fce7 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -55,8 +55,8 @@ class Warehouses extends DolibarrApi * * Return an array with warehouse informations * - * @param int $id ID of warehouse - * @return array|mixed data without useless information + * @param int $id ID of warehouse + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 29965516498..6bed56acd0d 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -60,7 +60,7 @@ $morehtmlref = '
'; $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; // Project -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; if ($usercancreate) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 03e718b2c0b..666253e5e2c 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -270,17 +270,17 @@ if (!empty($searchCategoryWarehouseList)) { $listofcategoryid = ''; foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) { if (intval($searchCategoryWarehouse) == -2) { - $searchCategoryWarehouseSqlList[] = "NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse)"; + $searchCategoryWarehouseSqlList[] = " NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)"; } elseif (intval($searchCategoryWarehouse) > 0) { if ($searchCategoryWarehouseOperator == 0) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).")"; } else { $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryWarehouse); } } } if ($listofcategoryid) { - $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE p.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + $searchCategoryWarehouseSqlList[] = " EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX."categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } if ($searchCategoryWarehouseOperator == 1) { if (!empty($searchCategoryWarehouseSqlList)) { @@ -453,7 +453,7 @@ if ($search_all) { $moreforfilter = ''; -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list); } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 571ff25a753..7cc649428c2 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -426,7 +426,7 @@ $userstatic = new User($db); $form = new Form($db); $formother = new FormOther($db); $formproduct = new FormProduct($db); -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { $formproject = new FormProjets($db); } diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 92bf74fa104..e0366f48eb2 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -593,7 +593,7 @@ if ($action == "transfert_stock" && !$cancel) { $form = new Form($db); $formproduct = new FormProduct($db); -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { $formproject = new FormProjets($db); } $productlot = new ProductLot($db); @@ -795,7 +795,7 @@ if ($object->id > 0) { $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; if ($usercancreate && 1 == 2) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7befa095142..54ec2f865a9 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class. if (isModEnabled('productbatch')) { require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; } -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -115,8 +115,8 @@ $hookmanager->initHooks(array('stockproductcard', 'globalcard')); $error = 0; -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'lire'); if ($object->isService()) { @@ -165,7 +165,7 @@ if ($action == 'setcost_price') { } } -if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) { +if ($action == 'addlimitstockwarehouse' && $user->hasRight('produit', 'creer')) { $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); @@ -204,7 +204,7 @@ if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer) exit; } -if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit->creer)) { +if ($action == 'delete_productstockwarehouse' && $user->hasRight('produit', 'creer')) { $pse = new ProductStockEntrepot($db); $pse->fetch(GETPOST('fk_productstockwarehouse', 'int')); @@ -216,7 +216,7 @@ if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit-> } // Set stock limit -if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) { +if ($action == 'setseuil_stock_alerte' && $user->hasRight('produit', 'creer')) { $object = new Product($db); $result = $object->fetch($id); $object->seuil_stock_alerte = $stocklimit; @@ -230,7 +230,7 @@ if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) } // Set desired stock -if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) { +if ($action == 'setdesiredstock' && $user->hasRight('produit', 'creer')) { $object = new Product($db); $result = $object->fetch($id); $object->desiredstock = $desiredstock; @@ -531,7 +531,7 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save")) { $form = new Form($db); $formproduct = new FormProduct($db); -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { $formproject = new FormProjets($db); } @@ -1263,14 +1263,14 @@ if (!$variants) { print '

'; print load_fiche_titre($langs->trans('AddNewProductStockWarehouse')); - if (!empty($user->rights->produit->creer)) { + if ($user->hasRight('produit', 'creer')) { print ''; print ''; print ''; print ''; } print '
'; @@ -638,7 +628,7 @@ if ($id > 0) { // Bank account if (isModEnabled("banque")) { print '
'; - print ''; + print ''; } elseif ($x_coll == -2) { - print ''; + print ''; } else { - print ''; + print ''; } } else { $x_both = array(); @@ -247,7 +251,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->name = $x_coll[$my_coll_rate]['company_name'][$id]; $company_static->name_alias = $x_coll[$my_coll_rate]['company_alias'][$id]; $company_static->email = $x_coll[$my_coll_rate]['company_email'][$id]; - $company_static->tva_intra = $x_coll[$my_coll_rate]['tva_intra'][$id]; + $company_static->tva_intra = isset($x_coll[$my_coll_rate]['tva_intra'][$id])?$x_coll[$my_coll_rate]['tva_intra'][$id]:0; $company_static->client = $x_coll[$my_coll_rate]['company_client'][$id]; $company_static->fournisseur = $x_coll[$my_coll_rate]['company_fournisseur'][$id]; $company_static->status = $x_coll[$my_coll_rate]['company_status'][$id]; @@ -257,27 +261,27 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate]['company_supplier_accounting_code'][$id]; $x_both[$my_coll_rate]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_rate]['facid'][$id], - 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], - 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], - 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], - 'payment_ref'=>$x_coll[$my_coll_rate]['payment_ref'][$id], - 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], - 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], - 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'id' => $x_coll[$my_coll_rate]['facid'][$id], + 'descr' => $x_coll[$my_coll_rate]['descr'][$id], + 'pid' => $x_coll[$my_coll_rate]['pid'][$id], + 'pref' => $x_coll[$my_coll_rate]['pref'][$id], + 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_ref' => $x_coll[$my_coll_rate]['payment_ref'][$id], + 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id], + 'datef' => $x_coll[$my_coll_rate]['datef'][$id], + 'datep' => $x_coll[$my_coll_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) + 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id], + 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id], + 'link' => $invoice_customer->getNomUrl(1, '', 12) ); } } @@ -300,22 +304,22 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $expensereport->type = $x_paye[$my_paye_rate]['type'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_ref' =>$x_paye[$my_paye_rate]['payment_ref'][$id], - 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_rate]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'link' => $expensereport->getNomUrl(1) ); } else { $invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id]; @@ -336,27 +340,27 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate]['company_supplier_accounting_code'][$id]; $x_both[$my_paye_rate]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_rate]['facid'][$id], - 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], - 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], - 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], - 'payment_ref'=>$x_paye[$my_paye_rate]['payment_ref'][$id], - 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], - 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], - 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'id' => $x_paye[$my_paye_rate]['facid'][$id], + 'descr' => $x_paye[$my_paye_rate]['descr'][$id], + 'pid' => $x_paye[$my_paye_rate]['pid'][$id], + 'pref' => $x_paye[$my_paye_rate]['pref'][$id], + 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_ref' => $x_paye[$my_paye_rate]['payment_ref'][$id], + 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id], + 'datef' => $x_paye[$my_paye_rate]['datef'][$id], + 'datep' => $x_paye[$my_paye_rate]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'company_link' => $company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id], + 'link' => $invoice_supplier->getNomUrl(1, '', 12) ); } } @@ -375,21 +379,21 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Customers invoices print ''; - print ''; - print ''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { - print ''; + print ''; + print ''; + if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { + print ''; } else { print ''; } - print ''; - print ''; + print ''; + print ''; if ($modetax != 1) { - print ''; - print ''; + print ''; + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; $action = "tvadetail"; @@ -410,15 +414,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate print ""; - print ''; - print ''."\n"; + print '' . "\n"; foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { // Define type @@ -434,26 +438,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // Payment - $ratiopaymentinvoice=1; + $ratiopaymentinvoice = 1; if ($modetax != 1) { - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } } } // Total collected - $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; // VAT - $temp_vat=$fields['vat']*$ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } } @@ -495,7 +499,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; + if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') print ''; else print ''; // Company name @@ -556,10 +560,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id = $fields['payment_id']; $payment_static->ref = $fields['payment_ref']; - print $payment_static->getNomUrl(2, '', '', 0).' '; + print $payment_static->getNomUrl(2, '', '', 0) . ' '; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -596,47 +600,47 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total customers for this vat rate print ''; print ''; - print ''; + print ''; if ($modetax != 1) { print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } if (count($x_coll) == 0) { // Show a total line if nothing shown print ''; print ''; - print ''; + print ''; if ($modetax != 1) { print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } // Blank line - print ''; + print ''; // Print table headers for this quadri - expenses print ''; - print ''; - print ''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; + print ''; + print ''; + if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') print ''; else print ''; - print ''; - print ''; + print ''; + print ''; if ($modetax != 1) { - print ''; - print ''; + print ''; + print ''; } - print ''; - print ''; - print ''."\n"; + print ''; + print ''; + print '' . "\n"; foreach (array_keys($x_paye) as $rate) { $subtot_paye_total_ht = 0; @@ -644,15 +648,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (is_array($x_both[$rate]['paye']['detail'])) { print ""; - print ''; - print ''."\n"; + print '' . "\n"; foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { // Define type @@ -670,8 +674,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Payment $ratiopaymentinvoice = 1; if ($modetax != 1) { - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); @@ -727,7 +731,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') { print ''; } else { print ''; @@ -790,11 +794,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; $paymentfourn_static->ref = $fields['payment_ref']; - print $paymentfourn_static->getNomUrl(2, '', '', 0).' '; + print $paymentfourn_static->getNomUrl(2, '', '', 0) . ' '; } - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { @@ -832,26 +836,26 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total suppliers for this vat rate print ''; print ''; - print ''; + print ''; if ($modetax != 1) { print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } if (count($x_paye) == 0) { // Show a total line if nothing shown print ''; print ''; - print ''; + print ''; if ($modetax != 1) { print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } @@ -863,8 +867,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print '
'; + print ''; print ''; print ''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { print ''; } else { print ''; } - print ''; + print ''; print ''; if ($modetax != 1) { print ''; @@ -454,7 +458,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { print ''; } else { print ''; @@ -520,8 +524,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $payment_static->ref = $fields['payment_ref']; print $payment_static->getNomUrl(2, '', '', 0).' '; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -589,12 +593,12 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; print ''; print ''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') { print ''; } else { print ''; } - print ''; + print ''; print ''; if ($modetax != 1) { print ''; @@ -646,7 +650,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + if (getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'payment' || getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'payment') { print ''; } else { print ''; @@ -711,8 +715,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print $paymentfourn_static->getNomUrl(2, '', '', 0); } - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 37e7f75b306..72366e6a7e2 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); +$now = dol_now(); + $refresh = GETPOSTISSET('submit') ? true : false; $year_current = GETPOSTISSET('year') ? GETPOST('year', 'int') : dol_print_date($now, '%Y', 'tzserver'); $year_start = $year_current; @@ -49,7 +51,7 @@ include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +$modetax = getDolGlobalString('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOST("modetax", 'int'); } @@ -196,16 +198,16 @@ if ($modetax == 2) { $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; $description .= $langs->trans("VATSummary").'
'; -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') { $description .= $langs->trans("RulesVATDueProducts"); } -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') { $description .= $langs->trans("RulesVATInProducts"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') { $description .= '
'.$langs->trans("RulesVATDueServices"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { $description .= '
'.$langs->trans("RulesVATInServices"); } if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -417,8 +419,8 @@ if ($refresh === true) { $type = 1; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { @@ -457,8 +459,8 @@ if ($refresh === true) { $type = 1; } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) { //print $langs->trans("NA"); } else { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 33d5b5716bc..2b3b5354cea 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -24,17 +24,17 @@ /** * \file htdocs/compta/tva/payments.php * \ingroup compta - * \brief Page to list payments of special expenses + * \brief Page to list payments of special expenses */ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/paymentvat.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); @@ -47,7 +47,7 @@ if (!$year && $mode != 'tvaonly') { $year = date("Y", time()); } -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -90,39 +90,76 @@ $title = $langs->trans("VATPayments"); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.$contextpage; + $param .= '&contextpage=' . $contextpage; } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.$limit; + $param .= '&limit=' . $limit; } if ($sortfield) { - $param .= '&sortfield='.$sortfield; + $param .= '&sortfield=' . $sortfield; } if ($sortorder) { - $param .= '&sortorder='.$sortorder; + $param .= '&sortorder=' . $sortorder; } - -print ''; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - $center = ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); - if ($year) { - $param .= '&year='.$year; + $param .= '&year=' . $year; } -if (isModEnabled('tax') && $user->rights->tax->charges->lire) { +$sql = "SELECT tva.rowid, tva.label as label, b.fk_account, ptva.fk_bank"; +$sql .= ", tva.datev"; +$sql .= ", tva.amount as total,"; +$sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaid, ptva.num_paiement as num_payment,"; +$sql .= " pct.code as payment_code"; +$sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva,"; +$sql .= " " . MAIN_DB_PREFIX . "payment_vat as ptva"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "bank as b ON (b.rowid = ptva.fk_bank)"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_account as bank ON (bank.rowid = b.fk_account)"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_paiement as pct ON ptva.fk_typepaiement = pct.id"; +$sql .= " WHERE ptva.fk_tva = tva.rowid"; +$sql .= " AND tva.entity = " . $conf->entity; +if ($year > 0) { + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (tva.datev IS NOT NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; + $sql .= " OR (tva.datev IS NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; + $sql .= ")"; +} +if (preg_match('/^cs\./', $sortfield) + || preg_match('/^tva\./', $sortfield) + || preg_match('/^ptva\./', $sortfield) + || preg_match('/^pct\./', $sortfield) + || preg_match('/^bank\./', $sortfield)) { + $sql .= $db->order($sortfield, $sortorder); +} +//$sql.= $db->plimit($limit+1,$offset); +//print $sql; + +dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); +} else { + setEventMessages($db->lasterror, null, 'errors'); +} + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $num, 'title_accountancy', 0, '', '', $limit); + +if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { + print ''; + if ($optioncss != '') { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print $langs->trans('DefaultBankAccount'); print ''; if ($action != 'editbankaccount' && $user->rights->tax->charges->creer) { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index d74d90c40be..66bd680739d 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -453,8 +453,12 @@ class ChargeSociales extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; $sql .= " paye = 1"; $sql .= " WHERE rowid = ".((int) $this->id); + $return = $this->db->query($sql); + if ($return) { + $this->paye = 1; + return 1; } else { return -1; @@ -488,8 +492,12 @@ class ChargeSociales extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; $sql .= " paye = 0"; $sql .= " WHERE rowid = ".((int) $this->id); + $return = $this->db->query($sql); + if ($return) { + $this->paye = 0; + return 1; } else { return -1; diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index b9dd6c7429d..dce5ec2602e 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -210,16 +210,16 @@ $builddate = dol_now(); if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); } -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') { $description .= '
'.$langs->trans("RulesVATDueProducts"); } -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') { $description .= '
'.$langs->trans("RulesVATInProducts"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') { $description .= '
'.$langs->trans("RulesVATDueServices"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { $description .= '
'.$langs->trans("RulesVATInServices"); } if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 3a088ca30b5..db18debb26b 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -265,7 +265,6 @@ class PaymentVAT extends CommonObject */ public function fetch($id) { - global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.fk_tva,"; @@ -275,7 +274,7 @@ class PaymentVAT extends CommonObject $sql .= " t.amount,"; $sql .= " t.fk_typepaiement,"; $sql .= " t.num_paiement as num_payment,"; - $sql .= " t.note,"; + $sql .= " t.note as note_private,"; $sql .= " t.fk_bank,"; $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; @@ -303,7 +302,8 @@ class PaymentVAT extends CommonObject $this->fk_typepaiement = $obj->fk_typepaiement; $this->num_paiement = $obj->num_payment; $this->num_payment = $obj->num_payment; - $this->note = $obj->note; + $this->note = $obj->note_private; + $this->note_private = $obj->note_private; $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index d0ed3032684..c00da16c3be 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -53,7 +53,7 @@ if (empty($min)) { // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE); +$modetax = getDolGlobalInt('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOSTINT("modetax"); } @@ -122,6 +122,7 @@ $calcmode .= ' ('.$langs->trans("TaxModuleSetupToMod // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); $prevyear = $date_start_year; +$q=0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -139,16 +140,16 @@ if ($nextquarter < 4) { } $builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { - $description .= $langs->trans("RulesVATDueProducts"); +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') { + $description = $langs->trans("RulesVATDueProducts"); } -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') { $description .= $langs->trans("RulesVATInProducts"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') { $description .= '
'.$langs->trans("RulesVATDueServices"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { $description .= '
'.$langs->trans("RulesVATInServices"); } if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -180,14 +181,17 @@ $productcust = $langs->trans("Description"); $namerate = $langs->trans("VATRate"); $amountcust = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatcust .= ' ('.$langs->trans("StatusToPay").')'; + $vatcust = ' ('.$langs->trans("StatusToPay").')'; } $elementsup = $langs->trans("SuppliersInvoices"); $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatsup .= ' ('.$langs->trans("ToGetBack").')'; + $vatsup = ' ('.$langs->trans("ToGetBack").')'; } +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); $vatcust = $langs->trans("VATReceived"); @@ -240,7 +244,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $company_static->name = $x_coll[$my_coll_thirdpartyid]['company_name'][$id]; $company_static->name_alias = $x_coll[$my_coll_thirdpartyid]['company_alias'][$id]; $company_static->email = $x_coll[$my_coll_thirdpartyid]['company_email'][$id]; - $company_static->tva_intra = $x_coll[$my_coll_thirdpartyid]['tva_intra'][$id]; + $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid]['tva_intra'][$id])?$x_coll[$my_coll_thirdpartyid]['tva_intra'][$id]:0; $company_static->client = $x_coll[$my_coll_thirdpartyid]['company_client'][$id]; $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid]['company_fournisseur'][$id]; $company_static->status = $x_coll[$my_coll_thirdpartyid]['company_status'][$id]; @@ -254,13 +258,13 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'pref' =>isset($x_coll[$my_coll_thirdpartyid]['pref'][$id])?$x_coll[$my_coll_thirdpartyid]['pref'][$id]:'', 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'pstatus' =>$x_paye[$my_coll_thirdpartyid]['pstatus'][$id], - 'pstatusbuy'=>$x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id], + 'pstatus' =>isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id])?$x_paye[$my_coll_thirdpartyid]['pstatus'][$id]:'', + 'pstatusbuy'=>isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id])?$x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]:'', 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_ref'=>$x_coll[$my_coll_thirdpartyid]['payment_ref'][$id], + 'payment_ref'=>isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id])?$x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]:'', 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], @@ -386,12 +390,12 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print '
'.$elementcust.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namerate.''.$productcust.''.$amountcust.''.dol_print_date($fields['datef'], 'day').''.dol_print_date($fields['datep'], 'day').'
'.$elementsup.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namesup.''.$productsup.''.$amountsup.''.dol_print_date($fields['datef'], 'day').''.dol_print_date($fields['datep'], 'day').'
'; print ''; @@ -147,19 +184,19 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { $sql .= ", tva.amount as total,"; $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaid, ptva.num_paiement as num_payment,"; $sql .= " pct.code as payment_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,"; - $sql .= " ".MAIN_DB_PREFIX."payment_vat as ptva"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = ptva.fk_bank)"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank_account as bank ON (bank.rowid = b.fk_account)"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id"; + $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva,"; + $sql .= " " . MAIN_DB_PREFIX . "payment_vat as ptva"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "bank as b ON (b.rowid = ptva.fk_bank)"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_account as bank ON (bank.rowid = b.fk_account)"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_paiement as pct ON ptva.fk_typepaiement = pct.id"; $sql .= " WHERE ptva.fk_tva = tva.rowid"; - $sql .= " AND tva.entity = ".$conf->entity; + $sql .= " AND tva.entity = " . $conf->entity; if ($year > 0) { $sql .= " AND ("; // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (tva.datev IS NOT NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; - $sql .= " OR (tva.datev IS NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= " (tva.datev IS NOT NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; + $sql .= " OR (tva.datev IS NULL AND tva.datev between '" . $db->idate(dol_get_first_day($year)) . "' AND '" . $db->idate(dol_get_last_day($year)) . "')"; $sql .= ")"; } if (preg_match('/^cs\./', $sortfield) @@ -169,12 +206,8 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { || preg_match('/^bank\./', $sortfield)) { $sql .= $db->order($sortfield, $sortorder); } - //$sql.= $db->plimit($limit+1,$offset); - //print $sql; - dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { + if ($num) { $num = $db->num_rows($resql); $i = 0; $total = 0; @@ -194,7 +227,7 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { print ''; // Ref payment - print '\n"; + print '\n"; // VAT print ''; // Label - print ''; + print ''; // Date $date = $db->jdate($obj->datev); - print ''; + print ''; // Date payment $datep = $db->jdate($obj->datep); - print ''; + print ''; // Type payment $labelpaymenttype = ''; if ($obj->payment_code) { - $labelpaymenttype = $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + $labelpaymenttype = $langs->trans("PaymentTypeShort" . $obj->payment_code) . ' '; } - print ''; // Chq number - print ''; + print ''; if (isModEnabled("banque")) { // Bank transaction @@ -241,7 +274,7 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { } // Expected to pay - print ''; + print ''; // Paid print ''; + print ''; print ''; // A total here has no sense print ''; print ''; @@ -268,16 +301,14 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { } print ''; print ''; - print '"; + print '"; print ""; - } else { - dol_print_error($db); } print '
'.$payment_vat_static->getNomUrl(1)."' . $payment_vat_static->getNomUrl(1) . "'; @@ -202,28 +235,28 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { print ''.dol_escape_htmltag($obj->label).'' . dol_escape_htmltag($obj->label) . ''.dol_print_date($date, 'day').'' . dol_print_date($date, 'day') . ''.dol_print_date($datep, 'day').'' . dol_print_date($datep, 'day') . ''; + print ''; print dol_escape_htmltag($labelpaymenttype); print ''.dol_escape_htmltag($obj->num_payment).'' . dol_escape_htmltag($obj->num_payment) . ''.price($obj->total).'' . price($obj->total) . ''; @@ -258,7 +291,7 @@ if (isModEnabled('tax') && $user->rights->tax->charges->lire) { } // Total - print '
'.$langs->trans("Total").'
' . $langs->trans("Total") . '    '.price($totalpaid)."' . price($totalpaid) . "
'; print ''; -} -print ''; + print ''; +} // End of page llxFooter(); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 1cedd5ce410..5235b4211ff 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -23,25 +23,25 @@ */ /** - * \file htdocs/compta/tva/quadri_detail.php - * \ingroup tax - * \brief VAT by rate + * \file htdocs/compta/tva/quadri_detail.php + * \ingroup tax + * \brief VAT by rate */ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); @@ -50,7 +50,7 @@ $refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTIS $invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : ''; $vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'alphanohtml') : -1; -include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; +include DOL_DOCUMENT_ROOT . '/compta/tva/initdatesforvat.inc.php'; $min = price2num(GETPOST("min", "alpha")); if (empty($min)) { @@ -59,7 +59,7 @@ if (empty($min)) { // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE); +$modetax = getDolGlobalInt('TAX_MODE'); if (GETPOSTISSET("modetax")) { $modetax = GETPOSTINT("modetax"); } @@ -95,11 +95,11 @@ $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { if (GETPOST($param) != '') { - $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + $morequerystring .= ($morequerystring ? '&' : '') . $param . '=' . GETPOST($param); } } -$title = $langs->trans("VATReport")." ".dol_print_date($date_start, '', 'tzserver')." -> ".dol_print_date($date_end, '', 'tzserver'); +$title = $langs->trans("VATReport") . " " . dol_print_date($date_start, '', 'tzserver') . " -> " . dol_print_date($date_end, '', 'tzserver'); llxHeader('', $title, '', '', 0, 0, '', '', $morequerystring); @@ -107,8 +107,8 @@ llxHeader('', $title, '', '', 0, 0, '', '', $morequerystring); //$fsearch.='
'; $fsearch = ''; -$fsearch .= ''; -$fsearch .= ''; +$fsearch .= ''; +$fsearch .= ''; //$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; //$fsearch.=' '; @@ -125,12 +125,13 @@ if ($modetax == 1) { if ($modetax == 2) { $calcmode = $langs->trans('OptionPaymentForProductAndServices'); } -$calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; +$calcmode .= ' (' . $langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT . '/admin/taxes.php') . ')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $period .= ' - '; $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $prevyear = $date_start_year; +$q=0; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -146,29 +147,29 @@ if ($nextquarter < 4) { $nextquarter = 1; $nextyear++; } -$description .= $fsearch; +$description = $fsearch; $builddate = dol_now(); -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') { $description .= $langs->trans("RulesVATDueProducts"); } -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { +if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') { $description .= $langs->trans("RulesVATInProducts"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { - $description .= '
'.$langs->trans("RulesVATDueServices"); +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') { + $description .= '
' . $langs->trans("RulesVATDueServices"); } -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { - $description .= '
'.$langs->trans("RulesVATInServices"); +if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') { + $description .= '
' . $langs->trans("RulesVATInServices"); } if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description .= '
'.$langs->trans("DepositsAreNotIncluded"); + $description .= '
' . $langs->trans("DepositsAreNotIncluded"); } if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= $langs->trans("SupplierDepositsAreNotIncluded"); } if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { - $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); + $description .= '
' . $langs->trans("ThisIsAnEstimatedValue"); } // Customers invoices @@ -178,7 +179,7 @@ $amountcust = $langs->trans("AmountHT"); $vatcust = $langs->trans("VATReceived"); $namecust = $langs->trans("Name"); if ($mysoc->tva_assuj) { - $vatcust .= ' ('.$langs->trans("VATToPay").')'; + $vatcust .= ' (' . $langs->trans("VATToPay") . ')'; } // Suppliers invoices @@ -188,10 +189,13 @@ $amountsup = $amountcust; $vatsup = $langs->trans("VATPaid"); $namesup = $namecust; if ($mysoc->tva_assuj) { - $vatsup .= ' ('.$langs->trans("ToGetBack").')'; + $vatsup .= ' (' . $langs->trans("ToGetBack") . ')'; } $optioncss = GETPOST('optioncss', 'alpha'); +$periodlink = ''; +$exportlink = ''; + if ($optioncss != "print") { report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); } @@ -221,11 +225,11 @@ $x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy') if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); if ($x_coll == -1) { - print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
'.$langs->trans("FeatureNotYetAvailable").'
' . $langs->trans("FeatureNotYetAvailable") . '
'.$langs->trans("Error").'
' . $langs->trans("Error") . '
'.$elementcust.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").'' . $elementcust . '' . $langs->trans("DateInvoice") . '' . $langs->trans("DatePayment") . ''.$namecust.''.$productcust.'' . $namecust . '' . $productcust . ''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')' . $amountcust . '' . $langs->trans("Payment") . ' (' . $langs->trans("PercentOfInvoice") . ')'.$langs->trans("AmountHTVATRealReceived").''.$vatcust.'' . $langs->trans("AmountHTVATRealReceived") . '' . $vatcust . '
'; + print ''; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; - print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; + print '&date_startyear=' . urlencode($date_start_year) . '&date_startmonth=' . urlencode($date_start_month) . '&date_startday=' . urlencode($date_start_day) . '&date_endyear=' . urlencode($date_end_year) . '&date_endmonth=' . urlencode($date_end_month) . '&date_endday=' . urlencode($date_end_day) . '">' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; print '
' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '
'.$langs->trans("Total").':' . $langs->trans("Total") . ':  '.price(price2num($subtot_coll_total_ht, 'MT')).''.price(price2num($subtot_coll_vat, 'MT')).'' . price(price2num($subtot_coll_total_ht, 'MT')) . '' . price(price2num($subtot_coll_vat, 'MT')) . '
'.$langs->trans("Total").':' . $langs->trans("Total") . ':  '.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).'' . price(price2num(0, 'MT')) . '' . price(price2num(0, 'MT')) . '
 
 
'.$elementsup.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").'' . $elementsup . '' . $langs->trans("DateInvoice") . '' . $langs->trans("DatePayment") . ''.$namesup.''.$productsup.'' . $namesup . '' . $productsup . ''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')' . $amountsup . '' . $langs->trans("Payment") . ' (' . $langs->trans("PercentOfInvoice") . ')'.$langs->trans("AmountHTVATRealPaid").''.$vatsup.'
' . $langs->trans("AmountHTVATRealPaid") . '' . $vatsup . '
'; + print ''; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; - print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; + print '&date_startyear=' . urlencode($date_start_year) . '&date_startmonth=' . urlencode($date_start_month) . '&date_startday=' . urlencode($date_start_day) . '&date_endyear=' . urlencode($date_end_year) . '&date_endmonth=' . urlencode($date_end_month) . '&date_endday=' . urlencode($date_end_day) . '">' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; print '
' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '
'.$langs->trans("Total").':' . $langs->trans("Total") . ':  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'' . price(price2num($subtot_paye_total_ht, 'MT')) . '' . price(price2num($subtot_paye_vat, 'MT')) . '
'.$langs->trans("Total").':' . $langs->trans("Total") . ':  '.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).'' . price(price2num(0, 'MT')) . '' . price(price2num(0, 'MT')) . '
'; $diff = $x_coll_sum - $x_paye_sum; print ''; - print ''; - print '\n"; + print ''; + print '\n"; print "\n"; $i++; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index f4cfeaa38cd..2419e74c5c9 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -257,7 +257,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $out = ''; $newcardbutton = ''; if (isModEnabled('agenda')) { - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); @@ -266,12 +266,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); } - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 3c82ae4f99b..306185cbc8a 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -253,7 +253,7 @@ abstract class ActionsContactCardCommon $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); - $this->tpl['note'] = nl2br($this->object->note); + $this->tpl['note'] = $this->object->note_private; } if ($action == 'create_user') { @@ -278,7 +278,7 @@ abstract class ActionsContactCardCommon /** * Assign POST values into object * - * @return string HTML output + * @return void */ private function assign_post() { diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 20be2b468b4..157e00c5c4a 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -110,7 +110,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->societe->contact->supprimer) { + if ($action == 'delete' && $user->hasRight('societe', 'contact', 'supprimer')) { $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index adf5bb722d3..127375b8c92 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -142,7 +142,7 @@ if (empty($user->socid)) { print ''.$langs->trans('Modify').''; } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + if (!$this->control->tpl['user_id'] && $user->hasRight('user', 'user', 'creer')) { print ''.$langs->trans("CreateDolibarrLogin").''; } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 739c4145db8..994a9bd9a63 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi * @@ -143,7 +143,7 @@ if (empty($reshook)) { } // Creation utilisateur depuis contact - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) { // Recuperation contact actuel $result = $object->fetch($id); @@ -313,7 +313,7 @@ if (empty($reshook)) { } } - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'contact', 'supprimer')) { $result = $object->fetch($id); $object->oldcopy = clone $object; @@ -867,7 +867,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { print ''; print ''; print ''; } @@ -1030,7 +1030,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Country print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // EMail print ''; print ''; if (isModEnabled('mailing')) { $langs->load("mails"); @@ -1157,7 +1157,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $arrayselected = array(); print ''; print ''; @@ -2036,7 +2030,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; /* print "".''; print ''; } else { @@ -556,7 +567,7 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; @@ -577,7 +588,7 @@ if ($id > 0 || !empty($ref)) { print '
'.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''.price(price2num($diff, 'MT'))."' . $langs->trans("TotalToPay") . ($q ? ', ' . $langs->trans("Quadri") . ' ' . $q : '') . '' . price(price2num($diff, 'MT')) . "
'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%'); @@ -996,7 +996,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { print '
'; - print img_picto('', 'company').$form->select_company(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); + print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : ($object->socid ? $object->socid : -1), 'socid', '', $langs->trans("SelectThirdParty")); print '
'; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print img_picto('', 'globe-americas', 'class="pictofixedwidth"'); print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id'); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); @@ -1053,26 +1053,26 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Phone print '
'.$form->editfieldkey('PhonePro', 'phone_pro', GETPOST('phone_pro', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); + print img_picto('', 'object_phoning', 'class="pictofixedwidth"'); print ''.$form->editfieldkey('PhonePerso', 'fax', GETPOST('phone_perso', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning'); + print img_picto('', 'object_phoning', 'class="pictofixedwidth"'); print '
'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0, 'string', '').''; - print img_picto('', 'object_phoning_mobile'); + print img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"'); print ''.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''; - print img_picto('', 'object_phoning_fax'); + print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"'); print '
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; - print img_picto('', 'object_email'); + print img_picto('', 'object_email', 'class="pictofixedwidth"'); print '
'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; @@ -1390,7 +1390,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->contact->creer) { + if ($action != 'editlevel' && $user->hasRight('societe', 'contact', 'creer')) { print 'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; @@ -1430,7 +1430,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Categories - if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { print ''; print '\n"; } - // With option one email per recipient + // With option for one email per recipient if (!empty($this->withoptiononeemailperrecipient)) { if (abs($this->withoptiononeemailperrecipient) == 1) { $out .= ''; } else { $out .= ''; @@ -1083,7 +1092,7 @@ class FormMail extends Form $tmparray = $this->withto; foreach ($tmparray as $key => $val) { $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); } $withtoselected = GETPOST("receiver", 'array'); // Array of selected value @@ -1121,7 +1130,7 @@ class FormMail extends Form $tmparray = $this->withtocc; foreach ($tmparray as $key => $val) { $tmparray[$key] = str_replace(array('<', '>'), array('(', ')'), $tmparray[$key]); - $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8', true); } $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value $out .= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500', null, ""); @@ -1365,7 +1374,7 @@ class FormMail extends Form // If template is for a module, check module is enabled; if not, take next template if ($obj->module) { $tempmodulekey = $obj->module; - if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) { continue; } } @@ -1501,7 +1510,7 @@ class FormMail extends Form // If template is for a module, check module is enabled. if ($obj->module) { $tempmodulekey = $obj->module; - if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) { continue; } } diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a3908df0adb..ac6bbc42e0d 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -243,7 +243,7 @@ class FormSetup */ public function saveConfFromPost($noMessageInUpdate = false) { - global $hookmanager; + global $hookmanager, $conf; $parameters = array(); $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks @@ -264,6 +264,10 @@ class FormSetup $this->db->begin(); $error = 0; foreach ($this->items as $item) { + if ($item->getType() == 'yesno' && !empty($conf->use_javascript_ajax)) { + continue; + } + $res = $item->setValueFromPost(); if ($res > 0) { $item->saveConfValue(); @@ -900,7 +904,7 @@ class FormSetupItem { global $conf; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); return $doleditor->Create(1); } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index dab47e9ce52..7e0ecb6a3c4 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -857,9 +857,9 @@ class FormTicket } // If selected is text, we compare with code, otherwise with id - if (preg_match('/[a-z]/i', $selected) && $selected == $arraycategories['code']) { + if (isset($selected) && preg_match('/[a-z]/i', $selected) && $selected == $arraycategories['code']) { print ' selected="selected"'; - } elseif ($selected == $id) { + } elseif (isset($selected) && $selected == $id) { print ' selected="selected"'; } elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) { print ' selected="selected"'; @@ -1194,9 +1194,9 @@ class FormTicket } // If text is selected, we compare with code, otherwise with id - if (preg_match('/[a-z]/i', $selected) && $selected == $arrayseverities['code']) { + if (isset($selected) && preg_match('/[a-z]/i', $selected) && $selected == $arrayseverities['code']) { print ' selected="selected"'; - } elseif ($selected == $id) { + } elseif (isset($selected) && $selected == $id) { print ' selected="selected"'; } elseif ($arrayseverities['use_default'] == "1" && !$selected && !$empty) { print ' selected="selected"'; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index d069bb0da23..56b02b41676 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -70,9 +70,9 @@ class Interfaces // phpcs:enable // Check parameters if (!is_object($object) || !is_object($conf)) { // Error - $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); - dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); - $this->errors[] = $this->error; + $error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + dol_syslog(get_class($this).'::run_triggers '.$error, LOG_ERR); + $this->errors[] = $error; return -1; } if (!is_object($langs)) { // Warning diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 1b40486adad..5ce093f7868 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -547,7 +547,7 @@ class Notify break; case 'ORDER_SUPPLIER_VALIDATE': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($outputlangs)); @@ -555,7 +555,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($outputlangs)); @@ -563,7 +563,7 @@ class Notify break; case 'ORDER_SUPPLIER_REFUSE': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($outputlangs)); @@ -815,7 +815,7 @@ class Notify break; case 'ORDER_SUPPLIER_VALIDATE': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); @@ -823,7 +823,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); @@ -831,7 +831,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE2': $link = ''.$newref.''; - $dir_output = $conf->fournisseur->commande->dir_output; + $dir_output = $conf->fournisseur->commande->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object); $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 7133167b4dd..ee886b5bb83 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1140,10 +1140,8 @@ class SMTPs /** * Inserts given addresses into structured format. - * This method takes a list of given addresses, via an array - * or a COMMA delimted string, and inserts them into a highly - * structured array. This array is designed to remove duplicate - * addresses and to sort them by Domain. + * This method takes a list of given addresses, via an array or a COMMA delimted string, and inserts them into a highly + * structured array. This array is designed to remove duplicate addresses and to sort them by Domain. * * @param string $_type TO, CC, or BCC lists to add addrresses into * @param mixed $_addrList Array or COMMA delimited string of addresses @@ -1245,7 +1243,9 @@ class SMTPs } // Pull User Name and Host.tld apart - list($_aryEmail['user'], $_aryEmail['host']) = explode('@', $_aryEmail['addr']); + $_tmpHost = explode('@', $_aryEmail['addr']); + $_aryEmail['user'] = $_tmpHost[0]; + $_aryEmail['host'] = $_tmpHost[1]; // Put the brackets back around the address $_aryEmail['addr'] = '<'.$_aryEmail['addr'].'>'; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 5aa334600fb..9569a9c2731 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -269,7 +269,7 @@ class Translate // Enable caching of lang file in memory (not by default) $usecachekey = ''; // Using a memcached server - if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { + if (isModEnabled('memcached') && !empty($conf->global->MEMCACHED_SERVER)) { $usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index f67702ca7c9..3f1fe9ff888 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -186,7 +186,7 @@ class Utils } // Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them - if (!empty($conf->api->enabled)) { + if (isModEnabled('api')) { dol_mkdir($conf->api->dir_temp); } dol_mkdir($conf->user->dir_temp); diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index 0bb532e33c4..e2694520577 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -260,14 +260,16 @@ class vCard * Add a e-mail address to this vCard * * @param string $address E-mail address - * @param string $type (optional) The type of the e-mail (typical "PREF;INTERNET" or "INTERNET") + * @param string $type (optional) The type of the e-mail (typical "PREF" or "INTERNET") * @return void */ public function setEmail($address, $type = "") { $key = "EMAIL"; - if ($type != "") { - $key .= ";".$type; + if ($type == "PREF") { + $key .= ";PREF=1"; + } elseif (!empty($type)) { + $key .= ";TYPE=".dol_strtolower($type); } $this->properties[$key] = $address; } diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 331c5078c54..5f933b435c4 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -300,9 +300,9 @@ if (is_array($search_groupby) && count($search_groupby)) { $sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse; } - // Add the where here - /* - $sqlfilters = GETPOST('search_component_params_hidden', 'alphanohtml'); + // Add a where here keeping only the citeria on $tabletouse + // TODO + /*$sqlfilters = ... GETPOST('search_component_params_hidden', 'alphanohtml'); if ($sqlfilters) { $errormessage = ''; $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); @@ -418,7 +418,7 @@ $startyear = $endyear - 2; $param = ''; -print ''; +print ''; print ''; print ''; print ''; @@ -572,6 +572,8 @@ print ''; // Generate the SQL request $sql = ''; if (!empty($search_measures) && !empty($search_xaxis)) { + $errormessage = ''; + $fieldid = 'rowid'; $sql = "SELECT "; @@ -663,7 +665,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) { } } } else { - dol_print_error($db, 'Found a key into search_xaxis not found into arrayofxaxis'); + $errormessage = 'Found a key into search_xaxis not found into arrayofxaxis'; } } @@ -690,7 +692,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) { } } } else { - dol_print_error($db, 'Found a key into search_groupby not found into arrayofgroupby'); + $errormessage = 'Found a key into search_groupby not found into arrayofgroupby'; } } @@ -717,7 +719,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) { } } } else { - dol_print_error($db, 'Found a key into search_measures not found into arrayofmesures'); + $errormessage = 'Found a key into search_measures not found into arrayofmesures'; } } @@ -728,11 +730,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) { // Add the where here $sqlfilters = $search_component_params_hidden; if ($sqlfilters) { - $errormessage = ''; - $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage); - if ($errormessage) { - print dol_escape_htmltag($errormessage); - } + $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage, 0, 0, 1); } $sql .= " GROUP BY "; foreach ($search_xaxis as $key => $val) { @@ -797,6 +795,11 @@ if (!empty($search_measures) && !empty($search_xaxis)) { } //print $sql; +if ($errormessage) { + print dol_escape_htmltag($errormessage); + $sql = ''; +} + $legend = array(); foreach ($search_measures as $key => $val) { $legend[] = $langs->trans($arrayofmesures[$val]['label']); diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 30b3ea76975..b29b3cb7385 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -283,7 +283,7 @@ abstract class DoliDB implements Database * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'. Note: If the quantity fo sortorder values is lower than sortfield, we used the last value for missing values. * @return string String to provide syntax of a sort sql string */ - public function order($sortfield = null, $sortorder = null) + public function order($sortfield = '', $sortorder = '') { if (!empty($sortfield)) { $oldsortorder = ''; diff --git a/htdocs/core/filemanagerdol/connectors/php/config.inc.php b/htdocs/core/filemanagerdol/connectors/php/config.inc.php index 368b82c42e7..7407ab706a7 100644 --- a/htdocs/core/filemanagerdol/connectors/php/config.inc.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.inc.php @@ -160,7 +160,7 @@ $Config['QuickUploadPath']['File'] = $Config['UserFilesPath']; $Config['QuickUploadAbsolutePath']['File'] = $Config['UserFilesAbsolutePath']; $Config['AllowedExtensions']['Image'] = array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'ai'); -if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { +if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) { $Config['AllowedExtensions']['Image'][] = 'svg'; } $Config['DeniedExtensions']['Image'] = array(); diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index ae0de6ad0cb..5ed7dfb2eb1 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -128,7 +128,7 @@ if (empty($conf->dol_no_mouse_hover)) { print ' jQuery(".classfortooltiponclicktext").dialog({ closeOnEscape: true, classes: { "ui-dialog": "highlight" }, - maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max($_SESSION['dol_screenwidth'] - 20, 320) : 700).', + maxHeight: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? max((empty($_SESSION['dol_screenwidth']) ? 0 : $_SESSION['dol_screenwidth']) - 20, 320) : 700).', modal: true, autoOpen: false }).css("z-index: 5000"); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index c602d13cbf7..04ecd350227 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1320,14 +1320,21 @@ jQuery(document).ready(function() { * TODO: Recheck with the select2 GH issue and remove once this is fixed on their side */ +global->MAIN_DISABLE_SELECT2_FOCUS_PROTECTION) && !defined('DISABLE_SELECT2_FOCUS_PROTECTION')) { + ?> $(document).on('select2:open', (e) => { console.log("Execute the focus (click on combo or use space when on component"); const target = $(e.target); if (target && target.length) { - const id = target[0].id || target[0].name; + let id = target[0].id || target[0].name; + if (id.substr(-2) == "[]") id = id.substr(0,id.length-2); document.querySelector('input[aria-controls*='+id+']').focus(); } }); + // End of lib_head.js.php diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 83fdc6bc043..cdd3fdc61ff 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -375,7 +375,7 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; @@ -1097,9 +1097,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; print ''; + $arrayofmassactions = array(); + $mode = 'view'; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print "\n".'
'.$langs->trans("Categories").''; print $form->showCategories($object->id, Categorie::TYPE_CONTACT, 1); @@ -1491,7 +1491,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $dolibarr_user->getLoginUrl(-1); } else { //print ''.$langs->trans("NoDolibarrAccess").''; - if (!$object->user_id && $user->rights->user->user->creer) { + if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) { print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add', 'class="pictofixedwidth"').$langs->trans("CreateDolibarrLogin").''; } } @@ -1527,11 +1527,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Activer - if ($object->statut == 0 && $user->rights->societe->contact->creer) { + if ($object->statut == 0 && $user->hasRight('societe', 'contact', 'creer')) { print ''.$langs->trans("Reactivate").''; } // Desactiver - if ($object->statut == 1 && $user->rights->societe->contact->creer) { + if ($object->statut == 1 && $user->hasRight('societe', 'contact', 'creer')) { print ''.$langs->trans("DisableUser").''; } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 2d64c5b8921..049dbfefc1f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -847,7 +847,7 @@ $arrayofmassactions = array( if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->societe->creer) { +if (isModEnabled('category') && $user->hasRight('societe', 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { @@ -899,7 +899,7 @@ if ($search_firstlast_only) { } $moreforfilter = ''; -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('ContactCategoriesShort'); diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index e9e5d64f495..394dfbe7070 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -61,7 +61,9 @@ $hookmanager->initHooks(array('contactnote')); /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index ba5fde87468..f2a05d0eb10 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -50,7 +50,7 @@ $errors = array(); * Action */ -if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact->creer) { +if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'contact', 'creer')) { $ret = $object->fetch($id); // Note: Correct date should be completed with location to have exact GM time of birth. diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 4984e940bad..d444bb6eb8e 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -90,7 +90,7 @@ if ($id > 0 || !empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendacontract', 'globalcard')); -$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php /* @@ -244,14 +244,14 @@ if ($object->id > 0) { $newcardbutton = ''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { $backtopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out = '&origin='.$object->element.'&originid='.$object->id.'&backtopage='.urlencode($backtopage); $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; $param = '&id='.$object->id; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d5d0858ab38..72b7ebed3ed 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -96,10 +96,10 @@ $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes lines and labels $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_element_line); -$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php -$permissiontodelete = ($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer; -$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('contrat', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('contrat', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontodelete = ($user->hasRight('contrat', 'creer') && $object->statut == $object::STATUS_DRAFT) || $user->hasRight('contrat', 'supprimer'); +$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoedit = $permissiontoadd; $error = 0; @@ -865,7 +865,7 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('contrat', 'supprimer')) { $result = $object->delete($user); if ($result >= 0) { header("Location: list.php?restore_lastsearch_values=1"); @@ -2150,7 +2150,7 @@ if ($action == 'create') { if (isModEnabled('facture') && $object->statut > 0) { $langs->load("bills"); - if ($user->rights->facture->creer) { + if ($user->hasRight('facture', 'creer')) { print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params); } else { $params['attr']['title'] = $langs->trans("NotEnoughPermissions"); @@ -2210,8 +2210,8 @@ if ($action == 'create') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->contrat->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->contrat->lire; - $delallowed = $user->rights->contrat->creer; + $genallowed = $user->hasRight('contrat', 'lire'); + $delallowed = $user->hasRight('contrat', 'creer'); print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, ($object->model_pdf ? $object->model_pdf : getDolGlobalString('CONTRACT_ADDON_PDF')), 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index fbcd3c0804d..d8c44316bd5 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -60,9 +60,8 @@ class Contracts extends DolibarrApi * * Return an array with contract informations * - * @param int $id ID of contract - * @return array|mixed data without useless information - * + * @param int $id ID of contract + * @return Object Object with cleaned properties * @throws RestException */ public function get($id) @@ -529,7 +528,7 @@ class Contracts extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->contrat->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'supprimer')) { throw new RestException(401); } $result = $this->contract->fetch($id); @@ -660,11 +659,6 @@ class Contracts extends DolibarrApi $object = parent::_cleanObjectDatas($object); unset($object->address); - - unset($object->date_start); - unset($object->date_start_real); - unset($object->date_end); - unset($object->date_end_real); unset($object->civility_id); return $object; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 58b04f0b894..d207455ca58 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -738,6 +738,10 @@ class Contrat extends CommonObject } return $this->id; + } else { + dol_syslog(get_class($this)."::fetch Contract failed"); + $this->error = "Fetch contract failed"; + return -1; } } else { dol_syslog(get_class($this)."::fetch Contract not found"); @@ -1664,7 +1668,7 @@ class Contrat extends CommonObject * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $rang Position - * @return int < 0 si erreur, > 0 si ok + * @return int <0 if KO, >0 if OK */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { @@ -1819,6 +1823,9 @@ class Contrat extends CommonObject $this->db->commit(); return 1; + } else { + $this->db->rollback(); + return -1; } } else { $this->db->rollback(); diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 2af24364604..2570103018b 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -54,7 +54,7 @@ $object = new Contrat($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contractcard', 'globalcard')); -$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php /* diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 3fb6ce25a6d..1e25eadc607 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -84,7 +84,7 @@ $modulepart = 'contract'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contractcard', 'globalcard')); -$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -183,8 +183,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'contract'; - $permissiontoadd = $user->rights->contrat->creer; - $permtoedit = $user->rights->contrat->creer; + $permissiontoadd = $user->hasRight('contrat', 'creer'); + $permtoedit = $user->hasRight('contrat', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index d3ab453b484..5ecb310d1be 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -177,9 +177,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->contrat->lire; -$permissiontoadd = $user->rights->contrat->creer; -$permissiontodelete = $user->rights->contrat->supprimer; +$permissiontoread = $user->hasRight('contrat', 'lire'); +$permissiontoadd = $user->hasRight('contrat', 'creer'); +$permissiontodelete = $user->hasRight('contrat', 'supprimer'); /* @@ -692,7 +692,7 @@ if ($user->rights->user->user->lire) { $moreforfilter .= '
'; } // If the user can view categories of products -if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -701,7 +701,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->right $moreforfilter .= '
'; } // Filter on customer categories -if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && isModEnabled("categorie") && $user->rights->categorie->lire) { +if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) { $moreforfilter .= '
'; $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); @@ -974,7 +974,7 @@ while ($i < $imaxinloop) { $socstatic->name_alias = $obj->name_alias; $socstatic->email = $obj->email; $socstatic->status = $obj->company_status; - $socstatic->logo = $obj->logo; + $socstatic->logo = $obj->company_logo; $socstatic->country_id = $obj->country_id; $socstatic->country_code = ''; $socstatic->country = ''; diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 576d3ce5fe2..00f94fee5e3 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -54,8 +54,8 @@ $result = restrictedArea($user, 'contrat', $id); $object = new Contrat($db); $object->fetch($id, $ref); -$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('contrat', 'creer'); // Used by the include of actions_setnotes.inc.php /* diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index de5f08a3693..859bf4b62b0 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -476,7 +476,7 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); -//if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +//if ($user->hasRight('contrat', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -519,7 +519,7 @@ $morefilter = ''; $moreforfilter = ''; // If the user can view categories of products -if (isModEnabled('categorie') && ($user->rights->produit->lire || $user->rights->service->lire)) { +if (isModEnabled('categorie') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index a74f9c4c5a8..aff6677be62 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -164,9 +164,14 @@ if ($action == 'add') { } else { // Else it's separated key/value and coma list foreach ($parameters_array as $param_ligne) { - list($key, $value) = explode(',', $param_ligne); - if (!array_key_exists('options', $params)) { - $params['options'] = array(); + if (strpos($param_ligne, ',')!==false) { + list($key, $value) = explode(',', $param_ligne); + if (!array_key_exists('options', $params)) { + $params['options'] = array(); + } + } else { + $key=$param_ligne; + $value=null; } $params['options'][$key] = $value; } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 6c5ac91c9bb..b680a81521c 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -92,7 +92,27 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC) && !emp if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://' && substr($link, 0, 7) != 'davs://') { $link = 'http://'.$link; } - dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); + + // Parse $newUrl + $newUrlArray = parse_url($link); + + // Check URL is external + if (!getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS')) { + if (!empty($newUrlArray['path']) && preg_match('/\.svg$/i', $newUrlArray['path'])) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans('ErrorSVGFilesNotAllowedAsLinksWithout', 'MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS'), null, 'errors'); + } + } + // Alow external links to svg ? + if (!getDolGlobalString('MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS')) { + // Test $newUrlAray['host'] to check link is external using isIPAllowed() + // TODO + } + + if (!$error) { + dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); + } } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index da7f2f43740..22510525a64 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -475,7 +475,7 @@ if (!$error && $massaction == 'confirm_presend') { $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); $substitutionarray['__EMAIL__'] = $thirdparty->email; - $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__CHECK_READ__'] = ''; $parameters = array('mode'=>'formemail'); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 624fe5766d2..21427edba07 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -346,7 +346,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO // Make substitution in email content $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; - $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; $parameters = array('mode'=>'formemail'); complete_substitutions_array($substitutionarray, $langs, $object, $parameters); diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 4ab4d0add32..69aae0dab4e 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -48,6 +48,7 @@ $object = fetchObjectByElement($id, $element); $module = $object->module; $element = $object->element; + $usesublevelpermission = ($module != $element ? $element : ''); if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly $usesublevelpermission = ''; diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index a20034ba0fe..9a3bfc8d541 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -98,12 +98,12 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } elseif ($table_element_line == 'facture_fourn_det_rec' && $user->rights->fournisseur->facture->creer) { $perm = 1; - } elseif ($table_element_line == 'product_attribute_value' && $fk_element == 'fk_product_attribute' && ($user->rights->produit->lire || $user->rights->service->lire)) { + } elseif ($table_element_line == 'product_attribute_value' && $fk_element == 'fk_product_attribute' && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { $perm = 1; } elseif ($table_element_line == 'ecm_files') { // Used when of page "documents.php" if (!empty($user->rights->ecm->creer)) { $perm = 1; - } elseif ($fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) { + } elseif ($fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || !empty($user->rights->service->creer))) { $perm = 1; } elseif ($fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) { $perm = 1; @@ -112,7 +112,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) } elseif ($fk_element == 'fk_soc' && !empty($user->rights->societe->creer)) { $perm = 1; } - } elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) { + } elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || !empty($user->rights->service->creer))) { $perm = 1; } elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) { $perm = 1; diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index a15728a04f0..54a1dd0cb63 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -60,7 +60,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->accounting->mouvements->lire); + $this->hidden = !$user->hasRight('accounting', 'mouvements', 'lire'); } /** @@ -79,7 +79,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); - if ($user->rights->accounting->mouvements->lire) { + if ($user->hasRight('accounting', 'mouvements', 'lire')) { $sql = "SELECT DISTINCT b.piece_num"; $sql .= ", b.doc_date as date_movement"; $sql .= ", b.label_operation"; diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 3ea5b191799..0a6fa06033f 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -60,7 +60,7 @@ class box_accountancy_suspense_account extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->accounting->mouvements->lire); + $this->hidden = !$user->hasRight('accounting', 'mouvements', 'lire'); } /** @@ -78,7 +78,7 @@ class box_accountancy_suspense_account extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); - if ($user->rights->accounting->mouvements->lire) { + if ($user->hasRight('accounting', 'mouvements', 'lire')) { $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; if (!empty($suspenseAccount) && $suspenseAccount > 0) { $sql = "SELECT COUNT(*) as nb_suspense_account"; diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 31852cfe9ff..840d6c06ffc 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -84,7 +84,7 @@ class box_actions extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestActionsToDo", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->hasRight('agenda', 'myactions', 'read')) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; $sql .= ", ta.code"; $sql .= ", ta.libelle as type_label"; @@ -105,7 +105,7 @@ class box_actions extends ModeleBoxes if ($user->socid) { $sql .= " AND s.rowid = ".((int) $user->socid); } - if (empty($user->rights->agenda->allactions->read)) { + if (!$user->hasRight('agenda', 'allactions', 'read')) { $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")"; } $sql .= " ORDER BY a.datep ASC"; diff --git a/htdocs/core/boxes/box_actions_future.php b/htdocs/core/boxes/box_actions_future.php index 61340ca8c85..61a40938b8c 100644 --- a/htdocs/core/boxes/box_actions_future.php +++ b/htdocs/core/boxes/box_actions_future.php @@ -86,7 +86,7 @@ class box_actions_future extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleFutureActions", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->hasRight('agenda', 'myactions', 'read')) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; $sql .= ", ta.code"; $sql .= ", ta.libelle as type_label"; @@ -107,7 +107,7 @@ class box_actions_future extends ModeleBoxes if ($user->socid) { $sql .= " AND s.rowid = ".((int) $user->socid); } - if (empty($user->rights->agenda->allactions->read)) { + if (!$user->hasRight('agenda', 'allactions', 'read')) { $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")"; } $sql .= " AND a.datep > '".$this->db->idate($now)."'"; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index f051fe5ade3..47ad55399ad 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); - if ($user->hasRight('societe', 'lire') && $user->rights->societe->contact->lire) { + if ($user->hasRight('societe', 'lire') && $user->hasRight('societe', 'contact', 'lire')) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 17544d90299..4587e026968 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -78,9 +78,10 @@ class box_dolibarr_state_board extends ModeleBoxes if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $hookmanager = new HookManager($this->db); $hookmanager->initHooks(array('index')); - $object = new stdClass; + $object = new stdClass(); $action = ''; - $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); + $parameters =array(); + $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; $boxstatFromHook = $hookmanager->resPrint; @@ -300,7 +301,7 @@ class box_dolibarr_state_board extends ModeleBoxes $this->info_box_contents[0][0] = array( 'tr' => 'class="nohover"', - 'td' => '', + 'td' => 'class="tdwidgetstate"', 'textnoformat' => $boxstat ); } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 6a59c6f0d56..3991c95bc60 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -58,7 +58,7 @@ class box_factures extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->facture->lire); + $this->hidden = !$user->hasRight('facture', 'lire'); } /** @@ -87,7 +87,7 @@ class box_factures extends ModeleBoxes 'limit'=> dol_strlen($text) ); - if ($user->rights->facture->lire) { + if ($user->hasRight('facture', 'lire')) { $sql = "SELECT f.rowid as facid"; $sql .= ", f.ref, f.type, f.total_ht"; $sql .= ", f.total_tva"; diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 06124d4ab35..ac05d51e607 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -84,7 +84,7 @@ class box_factures_fourn extends ModeleBoxes 'text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."SupplierBills", $max) ); - if ($user->rights->fournisseur->facture->lire) { + if ($user->hasRight('fournisseur', 'facture', 'lire')) { $langs->load("bills"); $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index ad6c6c97c27..291c8961ddc 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/boxes/box_factures_fourn_imp.php * \ingroup fournisseur - * \brief Fichier de gestion d'une box des factures fournisseurs impayees + * \brief Widget to show remain to get on purchase invoices */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -72,73 +72,83 @@ class box_factures_fourn_imp extends ModeleBoxes global $conf, $user, $langs; $this->max = $max; + //$this->max = 1000; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $facturestatic = new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + + $facturestatic = new FactureFournisseur($this->db); $thirdpartystatic = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); + $langs->load("bills"); - if ($user->rights->fournisseur->facture->lire) { - $langs->load("bills"); + $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $this->max)); - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite"; - $sql .= ", f.datef as df"; - $sql .= ", f.total_ht as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut as status, f.type"; - $sql .= ", f.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; + if ($user->hasRight('fournisseur', 'facture', 'lire')) { + $sql1 = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; + $sql1 .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; + $sql1 .= ", s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6"; + $sql1 .= ", f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite"; + $sql1 .= ", f.datef as df"; + $sql1 .= ", f.total_ht"; + $sql1 .= ", f.total_tva"; + $sql1 .= ", f.total_ttc"; + $sql1 .= ", f.paye, f.fk_statut as status, f.type"; + $sql1 .= ", f.tms"; + $sql1 .= ", SUM(pf.amount) as am"; + $sql2 = " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql2 .= ",".MAIN_DB_PREFIX."facture_fourn as f"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity = ".$conf->entity; - $sql .= " AND f.paye = 0"; - $sql .= " AND fk_statut = 1"; + $sql2 .= " WHERE f.fk_soc = s.rowid"; + $sql2 .= " AND f.entity IN (".getEntity('supplier_invoice').")"; + $sql2 .= " AND f.paye = 0"; + $sql2 .= " AND fk_statut = 1"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + $sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { - $sql .= " AND s.rowid = ".((int) $user->socid); + $sql2 .= " AND s.rowid = ".((int) $user->socid); } - $sql .= " ORDER BY datelimite DESC, f.ref_supplier DESC "; - $sql .= $this->db->plimit($max, 0); + $sql3 = " GROUP BY s.rowid, s.nom, s.name_alias, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; + $sql3 .= " f.rowid, f.ref, f.ref_supplier, f.date_lim_reglement,"; + $sql3 .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut, f.tms"; + $sql3 .= " ORDER BY datelimite DESC, f.ref_supplier DESC "; + $sql3 .= $this->db->plimit($this->max + 1, 0); + + $sql = $sql1.$sql2.$sql3; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $line = 0; - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; + $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; - $facturestatic = new FactureFournisseur($this->db); - - while ($line < $num) { + while ($line < min($num, $this->max)) { $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->date_echeance = $datelimite; $facturestatic->date = $date; + $facturestatic->date_echeance = $datelimite; $facturestatic->statut = $objp->status; $facturestatic->status = $objp->status; - $alreadypaid = $facturestatic->getSommePaiement(); + //$alreadypaid = $facturestatic->getSommePaiement(); - $facturestatic->alreadypaid = $alreadypaid ? $alreadypaid : 0; + $facturestatic->paye = $objp->paye; + $facturestatic->alreadypaid = $objp->am; $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; @@ -149,6 +159,13 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartystatic->logo = $objp->logo; $thirdpartystatic->email = $objp->email; $thirdpartystatic->entity = $objp->entity; + $thirdpartystatic->tva_intra = $objp->tva_intra; + $thirdpartystatic->idprof1 = !empty($objp->idprof1) ? $objp->idprof1 : ''; + $thirdpartystatic->idprof2 = !empty($objp->idprof2) ? $objp->idprof2 : ''; + $thirdpartystatic->idprof3 = !empty($objp->idprof3) ? $objp->idprof3 : ''; + $thirdpartystatic->idprof4 = !empty($objp->idprof4) ? $objp->idprof4 : ''; + $thirdpartystatic->idprof5 = !empty($objp->idprof5) ? $objp->idprof5 : ''; + $thirdpartystatic->idprof6 = !empty($objp->idprof6) ? $objp->idprof6 : ''; $late = ''; if ($facturestatic->hasDelay()) { @@ -161,12 +178,12 @@ class box_factures_fourn_imp extends ModeleBoxes 'td' => 'class="nowraponall"', 'text' => $facturestatic->getNomUrl(1), 'text2'=> $late, - 'asis' => 1 + 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartystatic->getNomUrl(1, '', 40), + 'text' => $thirdpartystatic->getNomUrl(1, '', 44), 'asis' => 1, ); @@ -182,19 +199,52 @@ class box_factures_fourn_imp extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type), + 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->am, $objp->type), ); $line++; } + if ($this->max < $num) { + $this->info_box_contents[$line][] = array('td' => 'colspan="6"', 'text' => '...'); + $line++; + } if ($num == 0) { $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', + 'td' => 'class="center opacitymedium"', 'text'=>$langs->trans("NoUnpaidSupplierBills"), ); } + $sql = "SELECT SUM(f.total_ht) as total_ht ".$sql2; + + $result = $this->db->query($sql); + $objp = $this->db->fetch_object($result); + $totalamount = $objp->total_ht; + + // Add the sum à the bottom of the boxes + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total_wrap"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right liste_total" ', + 'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index a6103c26257..0e45396bc89 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -21,7 +21,7 @@ /** * \file htdocs/core/boxes/box_factures_imp.php * \ingroup factures - * \brief Module de generation de l'affichage de la box factures impayees + * \brief Widget to show remain to get on sale invoices */ require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; /** - * Class to manage the box to show last invoices + * Class to manage the box to show not paid sales invoices */ class box_factures_imp extends ModeleBoxes { @@ -61,7 +61,7 @@ class box_factures_imp extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->facture->lire); + $this->hidden = !($user->hasRight('facture', 'lire')); } /** @@ -75,6 +75,7 @@ class box_factures_imp extends ModeleBoxes global $conf, $user, $langs; $this->max = $max; + //$this->max = 1000; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -84,66 +85,66 @@ class box_factures_imp extends ModeleBoxes $langs->load("bills"); - $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max)); + $textHead = $langs->trans("BoxTitleOldestUnpaidCustomerBills"); + $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $this->max), 'limit'=> dol_strlen($textHead)); - if ($user->rights->facture->lire) { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.client"; + if ($user->hasRight('facture', 'lire')) { + $sql1 = "SELECT s.rowid as socid, s.nom as name, s.name_alias, s.code_client, s.client"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= ", spe.accountancy_code_customer as code_compta"; + $sql1 .= ", spe.accountancy_code_customer as code_compta"; } else { - $sql .= ", s.code_compta"; + $sql1 .= ", s.code_compta"; } - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; - $sql .= ", f.ref, f.date_lim_reglement as datelimite"; - $sql .= ", f.type"; - $sql .= ", f.datef as date"; - $sql .= ", f.total_ht"; - $sql .= ", f.total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut as status, f.rowid as facid"; - $sql .= ", sum(pf.amount) as am"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql1 .= ", s.logo, s.email, s.entity"; + $sql1 .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql1 .= ", f.ref, f.date_lim_reglement as datelimite"; + $sql1 .= ", f.type"; + $sql1 .= ", f.datef as date"; + $sql1 .= ", f.total_ht"; + $sql1 .= ", f.total_tva"; + $sql1 .= ", f.total_ttc"; + $sql1 .= ", f.paye, f.fk_statut as status, f.rowid as facid"; + $sql1 .= ", SUM(pf.amount) as am"; + $sql2 = " FROM ".MAIN_DB_PREFIX."societe as s"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); + $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('invoice').")"; - $sql .= " AND f.paye = 0"; - $sql .= " AND fk_statut = 1"; + $sql2 .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql2 .= " WHERE f.fk_soc = s.rowid"; + $sql2 .= " AND f.entity IN (".getEntity('invoice').")"; + $sql2 .= " AND f.paye = 0"; + $sql2 .= " AND fk_statut = 1"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + $sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($user->socid) { - $sql .= " AND s.rowid = ".((int) $user->socid); + $sql2 .= " AND s.rowid = ".((int) $user->socid); } - $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; + $sql3 = " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " spe.accountancy_code_customer as code_compta,"; + $sql3 .= " spe.accountancy_code_customer as code_compta,"; } else { - $sql .= " s.code_compta,"; + $sql3 .= " s.code_compta,"; } - $sql .= " f.ref, f.date_lim_reglement,"; - $sql .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; - //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; - $sql .= " ORDER BY datelimite ASC, f.ref ASC "; - $sql .= $this->db->plimit($max, 0); + $sql3 .= " f.rowid, f.ref, f.date_lim_reglement,"; + $sql3 .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut"; + $sql3 .= " ORDER BY datelimite ASC, f.ref ASC "; + $sql3 .= $this->db->plimit($this->max + 1, 0); + + $sql = $sql1.$sql2.$sql3; $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now = dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; - while ($line < $num) { + while ($line < min($num, $this->max)) { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); @@ -158,7 +159,9 @@ class box_factures_imp extends ModeleBoxes $facturestatic->status = $objp->status; $facturestatic->date = $this->db->jdate($objp->date); $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $facturestatic->alreadypaid = $objp->paye; + + $facturestatic->paye = $objp->paye; + $facturestatic->alreadypaid = $objp->am; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -212,14 +215,47 @@ class box_factures_imp extends ModeleBoxes $line++; } + if ($this->max < $num) { + $this->info_box_contents[$line][] = array('td' => 'colspan="6"', 'text' => '...'); + $line++; + } if ($num == 0) { $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoUnpaidCustomerBills") + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoUnpaidCustomerBills") ); } + $sql = "SELECT SUM(f.total_ht) as total_ht ".$sql2; + + $result = $this->db->query($sql); + $objp = $this->db->fetch_object($result); + $totalamount = $objp->total_ht; + + // Add the sum à the bottom of the boxes + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total_wrap"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right liste_total" ', + 'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 2cecc278392..1e24f26ef81 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -98,7 +98,6 @@ class box_funnel_of_prospection extends ModeleBoxes $listofopplabel = array(); $listofoppcode = array(); $colorseriesstat = array(); - $bordercolorseries = array(); $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; $sql .= " WHERE active=1"; @@ -116,24 +115,19 @@ class box_funnel_of_prospection extends ModeleBoxes $listofoppcode[$objp->rowid] = $objp->code; switch ($objp->code) { case 'PROSP': - $colorseriesstat[$objp->rowid] = '#FFFFFF'; - $bordercolorseries[$objp->rowid] = $badgeStatus0; + $colorseriesstat[$objp->rowid] = '-'.$badgeStatus0; break; case 'QUAL': - $colorseriesstat[$objp->rowid] = '#FFFFFF'; - $bordercolorseries[$objp->rowid] = $badgeStatus1; + $colorseriesstat[$objp->rowid] = '-'.$badgeStatus1; break; case 'PROPO': $colorseriesstat[$objp->rowid] = $badgeStatus1; - $bordercolorseries[$objp->rowid] = $badgeStatus1; break; case 'NEGO': $colorseriesstat[$objp->rowid] = $badgeStatus4; - $bordercolorseries[$objp->rowid] = $badgeStatus4; break; case 'WON': $colorseriesstat[$objp->rowid] = $badgeStatus6; - $bordercolorseries[$objp->rowid] = $badgeStatus6; break; default: break; @@ -234,7 +228,7 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph->SetLegend($liststatus); $dolgraph->setHideXValues(true); $dolgraph->SetDataColor(array_values($colorseriesstat)); - $dolgraph->setBorderColor(array_values($bordercolorseries)); + //$dolgraph->setBorderColor(array_values($bordercolorseries)); $dolgraph->setShowLegend(2); if (!empty($conf->dol_optimize_smallscreen)) { $dolgraph->SetWidth(320); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 34dc015a1db..556b3a7fe42 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -56,7 +56,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->facture->lire); + $this->hidden = !$user->hasRight('facture', 'lire'); } /** @@ -103,7 +103,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } - if ($user->rights->facture->lire) { + if ($user->hasRight('facture', 'lire')) { $mesg = ''; $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index 0f2c7bdb92f..7a638f11b92 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -54,7 +54,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->facture->lire); + $this->hidden = !$user->hasRight('facture', 'lire'); } /** @@ -95,7 +95,7 @@ class box_graph_invoices_peryear extends ModeleBoxes if ($user->socid) $socid = $user->socid; if (empty($user->rights->societe->client->voir) || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user - if ($user->rights->facture->lire) { + if ($user->hasRight('facture', 'lire')) { $mesg = ''; $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 87952f008c8..b92862d5089 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -102,7 +102,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } - if ($user->rights->fournisseur->facture->lire) { + if ($user->hasRight('fournisseur', 'facture', 'lire')) { $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 2b0e61afa87..e0e1498824a 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -60,9 +60,9 @@ class box_graph_product_distribution extends ModeleBoxes $this->db = $db; $this->hidden = !( - (isModEnabled('facture') && !empty($user->rights->facture->lire)) - || (isModEnabled('commande') && !empty($user->rights->commande->lire)) - || (isModEnabled('propal') && !empty($user->rights->propal->lire)) + (isModEnabled('facture') && $user->hasRight('facture', 'lire')) + || (isModEnabled('commande') && $user->hasRight('commande', 'lire')) + || (isModEnabled('propal') && $user->hasRight('propal', 'lire')) ); } @@ -107,7 +107,7 @@ class box_graph_product_distribution extends ModeleBoxes $showinvoicenb = 1; $showordernb = 1; } - if (!isModEnabled('facture') || empty($user->rights->facture->lire)) { + if (!isModEnabled('facture') || !$user->hasRight('facture', 'lire')) { $showinvoicenb = 0; } if (isModEnabled('propal') || empty($user->rights->propal->lire)) { @@ -152,7 +152,7 @@ class box_graph_product_distribution extends ModeleBoxes $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '300' : '320'; $HEIGHT = '150'; // Height require to have 5+1 entries into legend visible. - if (isModEnabled("propal") && !empty($user->rights->propal->lire)) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { $langs->load("propal"); @@ -214,7 +214,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (isModEnabled('commande') && !empty($user->rights->commande->lire)) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { $langs->load("orders"); @@ -278,7 +278,7 @@ class box_graph_product_distribution extends ModeleBoxes } - if (isModEnabled('facture') && !empty($user->rights->facture->lire)) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showinvoicenb) { $langs->load("bills"); @@ -365,14 +365,14 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - if (isModEnabled("propal") || !empty($user->rights->propal->lire)) { + if (isModEnabled("propal") || $user->hasRight('propal', 'lire')) { $stringtoshow .= ' '.$langs->trans("ForProposals"); $stringtoshow .= ' '; } - if (isModEnabled('commande') || !empty($user->rights->commande->lire)) { + if (isModEnabled('commande') || $user->hasRight('commande', 'lire')) { $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); } - if (isModEnabled('facture') || !empty($user->rights->facture->lire)) { + if (isModEnabled('facture') || $user->hasRight('facture', 'lire')) { $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); $stringtoshow .= '   '; } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index e881db92412..89475095eb4 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -105,7 +105,7 @@ class box_graph_propales_permonth extends ModeleBoxes $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user } - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index e9404254b0a..efee61607ba 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -93,7 +93,7 @@ class box_members_by_tags extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '')); - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $stats = new AdherentStats($this->db, $user->socid, $user->id); diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 046c7031ece..72db5ec4f92 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -94,7 +94,7 @@ class box_members_by_type extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '')); - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($this->db, $user->socid, $user->id); // Show array diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 5c6082f1032..788695a1d36 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -90,7 +90,7 @@ class box_members_last_modified extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index e7f1d99137d..324d0df218d 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -92,7 +92,7 @@ class box_members_last_subscriptions extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("LastSubscriptionsModified", $max)); - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { $sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.gender, a.email, a.photo, a.morphy,"; $sql .= " a.datefin as date_end_subscription,"; diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index fe406ad29a3..f42ba94e688 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -90,7 +90,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersSubscriptionsByYear", $max)); - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { $num = 0; $line = 0; // List of subscription by year diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index f0f346b69a9..35d91d34064 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -62,7 +62,7 @@ class box_produits extends ModeleBoxes $this->db = $db; $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>(isModEnabled("product") || isModEnabled("service")), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $tmpentry = array('enabled'=>(isModEnabled("product") || isModEnabled("service")), 'perms'=>(!empty($user->rights->produit->lire) || $user->hasRight('service', 'lire')), 'module'=>'product|service'); $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } @@ -84,7 +84,7 @@ class box_produits extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); - if ($user->rights->produit->lire || $user->rights->service->lire) { + if ($user->rights->produit->lire || $user->hasRight('service', 'lire')) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; $sql .= ", p.accountancy_code_sell"; $sql .= ", p.accountancy_code_sell_intra"; diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index e7150929a89..72b9e770962 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -86,7 +86,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); - if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { + if (($user->rights->produit->lire || $user->hasRight('service', 'lire')) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; diff --git a/htdocs/core/boxes/box_project_opportunities.php b/htdocs/core/boxes/box_project_opportunities.php index 733e57db831..1acae79469f 100644 --- a/htdocs/core/boxes/box_project_opportunities.php +++ b/htdocs/core/boxes/box_project_opportunities.php @@ -74,14 +74,10 @@ class box_project_opportunities extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs; + global $user, $langs; $this->max = $max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask = 0; - $textHead = $langs->trans("OpenedProjectsOpportunities"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); @@ -158,9 +154,9 @@ class box_project_opportunities extends ModeleBoxes 'asis' => 1 ); - $this->info_box_contents[$i][] = array('td' => 'class="amount right"', 'text' => ($projectstatic->opp_amount ? price($projectstatic->opp_amount) : '')); + $this->info_box_contents[$i][] = array('td' => 'class="amount right nowraponall"', 'text' => ($projectstatic->opp_amount ? price($projectstatic->opp_amount) : '')); - $this->info_box_contents[$i][] = array('td' => 'class=""', 'asis'=>1, 'text' => ($projectstatic->opp_status_code ? $langs->trans("OppStatus".$projectstatic->opp_status_code).' ' : '').'('.round($projectstatic->opp_percent).'%)'); + $this->info_box_contents[$i][] = array('td' => 'class="nowraponall"', 'asis'=>1, 'text' => ($projectstatic->opp_status_code ? $langs->trans("OppStatus".$projectstatic->opp_status_code).' ' : '').'('.round($projectstatic->opp_percent).'%)'); $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index a0ff56aa625..d731e017842 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -83,7 +83,7 @@ class box_propales extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."Propals", $max)); - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 81cd361f4a1..5c674734ae8 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -60,7 +60,7 @@ class box_services_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = !(!empty($user->rights->service->lire) && !empty($user->rights->contrat->lire)); + $this->hidden = !($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')); } /** diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 65494e09e11..92acf87898a 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1007,6 +1007,7 @@ class CMailFile $this->dump_mail(); } + $smtperrorcode = 0; if (! $result) { $smtperrorcode = $this->smtps->lastretval; // SMTP error code dol_syslog("CMailFile::sendfile: mail SMTP error code ".$smtperrorcode, LOG_WARNING); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 11f2fca8226..b67a864a4f3 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -106,6 +106,12 @@ abstract class CommonDocGenerator public $emetteur; + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 7.1 = array(7, 1) + */ + public $phpmin = array(7, 1); + /** * @var array Array of columns */ @@ -475,6 +481,11 @@ abstract class CommonDocGenerator $date = (isset($object->element) && $object->element == 'contrat' && isset($object->date_contrat)) ? $object->date_contrat : (isset($object->date) ? $object->date : null); + if (get_class($object) == 'CommandeFournisseur') { + /* @var $object CommandeFournisseur*/ + $object->date_validation = $object->date_valid; + $object->date_commande = $object->date; + } $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref' => (property_exists($object, 'ref') ? $object->ref : ''), @@ -492,7 +503,8 @@ abstract class CommonDocGenerator $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_approve'=>(!empty($object->date_approve) ?dol_print_date($object->date_approve, 'day') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->delivery_date) ?dol_print_date($object->delivery_date, 'day') : ''), $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), $array_key.'_payment_mode_code'=>$object->mode_reglement_code, @@ -967,7 +979,7 @@ abstract class CommonDocGenerator } $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); - } elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { + } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6c129b86250..31c3ae24d52 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -793,7 +793,8 @@ abstract class CommonObject $hookmanager->initHooks(array($this->element . 'dao')); $parameters = array( - 'tooltipcontentarray' => &$datas + 'tooltipcontentarray' => &$datas, + 'params' => $params, ); // Note that $action and $object may have been modified by some hooks $hookmanager->executeHooks('getTooltipContent', $parameters, $this, $action); @@ -6617,6 +6618,11 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + case 'link': + if ($this->array_options["options_".$key] === '') { + $this->array_options["options_".$key] = null; + } + break; /* case 'link': $param_list = array_keys($attributeParam['options']); @@ -8442,16 +8448,19 @@ abstract class CommonObject { global $user; + $module = $this->module; $element = $this->element; + if ($element == 'facturerec') { $element = 'facture'; } elseif ($element == 'invoice_supplier_rec') { return $user->rights->fournisseur->facture; - } elseif ($element == 'evaluation') { - return $user->rights->hrm->evaluation; + } elseif ($module && !empty($user->rights->$module->$element)) { + // for modules built with ModuleBuilder + return $user->rights->$module->$element; } - return $user->rights->{$element}; + return $user->rights->$element; } /** @@ -8746,7 +8755,7 @@ abstract class CommonObject $return .= ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; } // Special cas for product - if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($modulepart == 'product' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { // Link to resize $return .= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; @@ -8775,7 +8784,7 @@ abstract class CommonObject } if ($showaction) { // Special case for product - if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($modulepart == 'product' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { // Link to resize $return .= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; @@ -9890,14 +9899,16 @@ abstract class CommonObject } // Force values to default values when known - foreach ($this->fields as $key => $value) { - // If fields are already set, do nothing - if (array_key_exists($key, $fields)) { - continue; - } + if (property_exists($this, 'fields')) { + foreach ($this->fields as $key => $value) { + // If fields are already set, do nothing + if (array_key_exists($key, $fields)) { + continue; + } - if (!empty($value['default'])) { - $this->$key = $value['default']; + if (!empty($value['default'])) { + $this->$key = $value['default']; + } } } diff --git a/htdocs/core/class/commonpeople.class.php b/htdocs/core/class/commonpeople.class.php index 54180eb626c..7eecbfc5f9e 100644 --- a/htdocs/core/class/commonpeople.class.php +++ b/htdocs/core/class/commonpeople.class.php @@ -27,6 +27,29 @@ */ trait CommonPeople { + /** + * @var string Address + */ + public $address; + + /** + * @var string zip code + */ + public $zip; + + /** + * @var string town + */ + public $town; + + /** + * @var int $state_id + */ + public $state_id; // The state/department + public $state_code; + public $state; + + /** * Return full name (civility+' '+name+' '+lastname) * diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 46e60b2f7fd..fe5f6b53974 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -292,4 +292,20 @@ class Cstate // extends CommonObject return 1; } } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $langs; + return $langs->trans($this->name); + } } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 9f5ea960c9a..c66bd73b96e 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -366,13 +366,14 @@ class DiscountAbsolute $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); + require_once DOL_DOCUMENT_ROOT. '/core/class/commoninvoice.class.php'; $result = $this->db->query($sql); if ($result) { // If source of discount was a credit note or deposit, we change source statut. if ($this->fk_facture_source) { $sql = "UPDATE ".$this->db->prefix()."facture"; $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid = ".((int) $this->fk_facture_source); + $sql .= " WHERE (type IN (".$this->db->sanitize(CommonInvoice::TYPE_CREDIT_NOTE.", ".CommonInvoice::TYPE_DEPOSIT).") AND rowid = ".((int) $this->fk_facture_source); dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); $result = $this->db->query($sql); @@ -387,7 +388,7 @@ class DiscountAbsolute } elseif ($this->fk_invoice_supplier_source) { $sql = "UPDATE ".$this->db->prefix()."facture_fourn"; $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid = ".((int) $this->fk_invoice_supplier_source); + $sql .= " WHERE (type IN (".$this->db->sanitize(CommonInvoice::TYPE_CREDIT_NOTE.", ".CommonInvoice::TYPE_DEPOSIT).") AND rowid = ".((int) $this->fk_invoice_supplier_source); dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); $result = $this->db->query($sql); @@ -573,12 +574,12 @@ class DiscountAbsolute $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount"; $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture as f"; $sql .= " WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = ".((int) $invoice->id); - $sql .= " AND f.type = 3"; + $sql .= " AND f.type = ". (int) $invoice::TYPE_DEPOSIT; } elseif ($invoice->element == 'invoice_supplier') { $sql = "SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount"; $sql .= " FROM ".$this->db->prefix()."societe_remise_except as rc, ".$this->db->prefix()."facture_fourn as f"; $sql .= " WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = ".((int) $invoice->id); - $sql .= " AND f.type = 3"; + $sql .= " AND f.type = ". (int) $invoice::TYPE_DEPOSIT; } else { $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; dol_print_error($this->error); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index bb63c1dd927..973db087e06 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -90,7 +90,7 @@ class DolEditor $this->readonly = $readonly; // Check if extended editor is ok. If not we force textarea - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) { + if ((!isModEnabled('fckeditor') && $okforextendededitor != 'ace') || empty($okforextendededitor)) { $this->tool = 'textarea'; } if ($okforextendededitor === 'ace') { diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8fad21d5e3b..362d61e5325 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1351,7 +1351,7 @@ class DolGraph // Add a callback to change label to show only positive value if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) { - $this->stringtoshow .= ', tooltips: { mode: \'nearest\', + $this->stringtoshow .= 'tooltips: { mode: \'nearest\', callbacks: {'; if (is_array($this->tooltipsTitles)) { $this->stringtoshow .=' diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a2d1552d1d2..afd4b57e916 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2088,7 +2088,7 @@ class ExtraFields continue; } - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) { + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'checkbox', 'chkbxlst')))) { //when unticking boolean field, it's not set in POST continue; } @@ -2115,7 +2115,7 @@ class ExtraFields if (empty($enabled) || ( $onlykey === '@GETPOSTISSET' - && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')) + && in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'checkbox', 'chkbxlst')) && in_array(abs($enabled), array(2, 5)) && ! GETPOSTISSET('options_' . $key) // Update hidden checkboxes and multiselect only if they are provided ) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 5f3a4e8b1e9..40bf654e30a 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -59,7 +59,7 @@ class FileUpload $filename = $element_prop['classfile']; $dir_output = $element_prop['dir_output']; - //print 'fileupload.class.php: element='.$element.' pathname='.$pathname.' filename='.$filename.' dir_output='.$dir_output; + //print 'fileupload.class.php: element='.$element.' pathname='.$pathname.' filename='.$filename.' dir_output='.$dir_output."\n"; if (empty($dir_output)) { setEventMessage('The element '.$element.' is not supported for uploading file. dir_output is unknow.', 'errors'); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e25f970fad2..2c0610084aa 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -158,6 +158,10 @@ class HookManager if (!is_array($this->hooks) || empty($this->hooks)) { return 0; // No hook available, do nothing. } + if (!is_array($parameters)) { + dol_syslog('executeHooks was called with a non array $parameters. Surely a bug.', LOG_WARNING); + $parameters = array(); + } $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e9ffa3d4bfc..dd94edf7228 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1336,7 +1336,7 @@ class Form // mode 1 $urloption = 'htmlname=' . urlencode(str_replace('.', '_', $htmlname)) . '&outjson=1&filter=' . urlencode($filter) . (empty($excludeids) ? '' : '&excludeids=' . join(',', $excludeids)) . ($showtype ? '&showtype=' . urlencode($showtype) : '') . ($showcode ? '&showcode=' . urlencode($showcode) : ''); - $out .= ''; + $out .= ''; if (empty($hidelabel)) { print $langs->trans("RefOrLabel") . ' : '; } elseif ($hidelabel > 1) { @@ -1706,22 +1706,22 @@ class Form /** * Return list of all contacts (for a third party or all) * - * @param int $socid Id ot third party or 0 for all - * @param string $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param integer $showfunction Add function into label - * @param string $morecss Add more class to class style - * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box - * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param bool $options_only Return options only (for ajax treatment) - * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container - * @param string $htmlid Html id to use instead of htmlname - * @return int <0 if KO, Nb of contact in list if OK - * @deprecated You can use selectcontacts directly (warning order of param was changed) + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param integer $showfunction Add function into label + * @param string $morecss Add more class to class style + * @param integer $showsoc Add company into label + * @param int $forcecombo Force to use combo box + * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param bool $options_only Return options only (for ajax treatment) + * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container + * @param string $htmlid Html id to use instead of htmlname + * @return int <0 if KO, Nb of contact in list if OK + * @deprecated You can use selectcontacts directly (warning order of param was changed) */ public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') { @@ -1731,28 +1731,28 @@ class Form } /** - * Return HTML code of the SELECT of list of all contacts (for a third party or all). - * This also set the number of contacts found into $this->num + * Return HTML code of the SELECT of list of all contacts (for a third party or all). + * This also set the number of contacts found into $this->num * * @since 9.0 Add afterSelectContactOptions hook * - * @param int $socid Id ot third party or 0 for all or -1 for empty list - * @param array|int $selected Array of ID of pre-selected contact id - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param integer $showfunction Add function into label - * @param string $morecss Add more class to class style - * @param bool $options_only Return options only (for ajax treatment) - * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box (so no ajax beautify effect) - * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container - * @param string $htmlid Html id to use instead of htmlname - * @param bool $multiple add [] in the name of element and add 'multiple' attribut - * @param integer $disableifempty Set tag 'disabled' on select if there is no choice - * @return int|string <0 if KO, HTML with select string if OK. + * @param int $socid Id ot third party or 0 for all or -1 for empty list + * @param array|int $selected Array of ID of pre-selected contact id + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param integer $showfunction Add function into label + * @param string $morecss Add more class to class style + * @param bool $options_only Return options only (for ajax treatment) + * @param integer $showsoc Add company into label + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) + * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container + * @param string $htmlid Html id to use instead of htmlname + * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param integer $disableifempty Set tag 'disabled' on select if there is no choice + * @return int|string <0 if KO, HTML with select string if OK. */ public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0) { @@ -2211,7 +2211,9 @@ class Form $outarray2[$userstatic->id] = array( 'id'=>$userstatic->id, 'label'=>$labeltoshow, - 'labelhtml'=>$labeltoshowhtml + 'labelhtml'=>$labeltoshowhtml, + 'color'=>'', + 'picto'=>'' ); $i++; @@ -7944,7 +7946,7 @@ class Form $urloption = 'htmlname=' . urlencode($htmlname) . '&outjson=1&objectdesc=' . urlencode($objectdesc) . '&filter=' . urlencode($filter) . ($sortfield ? '&sortfield=' . urlencode($sortfield) : ''); // Activate the auto complete using ajax call. $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); - $out .= ''; + $out .= ''; $out .= ''; } else { // Immediate load of table record. @@ -9350,22 +9352,22 @@ class Form } /** - * Return a HTML area with the reference of object and a navigation bar for a business object - * Note: To complete search with a particular filter on select, you can set $object->next_prev_filter set to define SQL criterias. + * Return a HTML area with the reference of object and a navigation bar for a business object + * Note: To complete search with a particular filter on select, you can set $object->next_prev_filter set to define SQL criterias. * - * @param object $object Object to show. - * @param string $paramid Name of parameter to use to name the id into the URL next/previous link. - * @param string $morehtml More html content to output just before the nav bar. - * @param int $shownav Show Condition (navigation is shown if value is 1). - * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field compared to $object->ref). Use 'none' to disable next/prev. - * @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref. - * @param string $morehtmlref More html to show after ref. - * @param string $moreparam More param to add in nav link url. Must start with '&...'. - * @param int $nodbprefix Do not include DB prefix to forge table name. - * @param string $morehtmlleft More html code to show before ref. - * @param string $morehtmlstatus More html code to show under navigation arrows (status place). - * @param string $morehtmlright More html code to show after ref. - * @return string Portion HTML with ref + navigation buttons + * @param object $object Object to show. + * @param string $paramid Name of parameter to use to name the id into the URL next/previous link. + * @param string $morehtml More html content to output just before the nav bar. + * @param int $shownav Show Condition (navigation is shown if value is 1). + * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field compared to $object->ref). Use 'none' to disable next/prev. + * @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref. + * @param string $morehtmlref More html to show after ref. + * @param string $moreparam More param to add in nav link url. Must start with '&...'. + * @param int $nodbprefix Do not include DB prefix to forge table name. + * @param string $morehtmlleft More html code to show before ref. + * @param string $morehtmlstatus More html code to show under navigation arrows (status place). + * @param string $morehtmlright More html code to show after ref. + * @return string Portion HTML with ref + navigation buttons */ public function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '') { @@ -9536,8 +9538,10 @@ class Form } else { $ret .= dol_htmlentities($fullname) . $addgendertxt . ((!empty($object->societe) && $object->societe != $fullname) ? ' (' . dol_htmlentities($object->societe) . ')' : ''); } - } elseif (in_array($object->element, array('contact', 'user', 'usergroup'))) { + } elseif (in_array($object->element, array('contact', 'user'))) { $ret .= dol_htmlentities($object->getFullName($langs)) . $addgendertxt; + } elseif ($object->element == 'usergroup') { + $ret .= dol_htmlentities($object->name); } elseif (in_array($object->element, array('action', 'agenda'))) { $ret .= $object->ref . '
' . $object->label; } elseif (in_array($object->element, array('adherent_type'))) { @@ -9547,7 +9551,6 @@ class Form } elseif ($fieldref != 'none') { $ret .= dol_htmlentities(!empty($object->$fieldref) ? $object->$fieldref : ""); } - if ($morehtmlref) { // don't add a additional space, when "$morehtmlref" starts with a HTML div tag if (substr($morehtmlref, 0, 4) != 'morphy, 'mor')) !== false) { + if ($modulepart == 'societe' || ($modulepart == 'memberphoto' && !empty($object->morphy) && strpos($object->morphy, 'mor')) !== false) { $nophoto = 'company'; } else { $nophoto = '/public/theme/common/user_anonymous.png'; @@ -10431,23 +10434,25 @@ class Form /** * Output the component to make advanced search criteries * - * @param array $arrayofcriterias Array of available search criterias. Example: array($object->element => $object->fields, 'otherfamily' => otherarrayoffields, ...) - * @param array $search_component_params Array of selected search criterias - * @param array $arrayofinputfieldsalreadyoutput Array of input fields already inform. The component will not generate a hidden input field if it is in this list. - * @param string $search_component_params_hidden String with $search_component_params criterias - * @return string HTML component for advanced search + * @param array $arrayofcriterias Array of available search criterias. Example: array($object->element => $object->fields, 'otherfamily' => otherarrayoffields, ...) + * @param array $search_component_params Array of selected search criterias + * @param array $arrayofinputfieldsalreadyoutput Array of input fields already inform. The component will not generate a hidden input field if it is in this list. + * @param string $search_component_params_hidden String with $search_component_params criterias + * @return string HTML component for advanced search */ public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden = '') { global $langs; + if ($search_component_params_hidden != '' && !preg_match('/^\(.*\)$/', $search_component_params_hidden)) { // If $search_component_params_hidden does not start and end with () + $search_component_params_hidden = '(' . $search_component_params_hidden . ')'; + } + $ret = ''; $ret .= '
'; - //$ret .= ''; $ret .= ''; $ret .= ''; - //$ret .= $langs->trans("Filters"); $ret .= ''; $ret .= '
'; @@ -10456,16 +10461,58 @@ class Form $ret .= '
'; if ($search_component_params_hidden) { - if (!preg_match('/^\(.*\)$/', $search_component_params_hidden)) { // If $search_component_params_hidden does not start and end with () - $search_component_params_hidden .= '(' . $search_component_params_hidden . ')'; + // Split the criteria on each AND + //var_dump($search_component_params_hidden); + + $nbofchars = dol_strlen($search_component_params_hidden); + $arrayofandtags = array(); + $i = 0; $s = ''; + $countparenthesis = 0; + while ($i < $nbofchars) { + $char = dol_substr($search_component_params_hidden, $i, 1); + + if ($char == '(') { + $countparenthesis++; + } elseif ($char == ')') { + $countparenthesis--; + } + + if ($countparenthesis == 0) { + $char2 = dol_substr($search_component_params_hidden, $i+1, 1); + $char3 = dol_substr($search_component_params_hidden, $i+2, 1); + if ($char == 'A' && $char2 == 'N' && $char3 == 'D') { + // We found a AND + $arrayofandtags[] = trim($s); + $s = ''; + $i+=2; + } else { + $s .= $char; + } + } else { + $s .= $char; + } + $i++; } - $errormessage = ''; - $searchtags = forgeSQLFromUniversalSearchCriteria($search_component_params_hidden, $errormessage); - if ($errormessage) { - print 'ERROR in parsing search string: ' . dol_escape_htmltag($errormessage); + if ($s) { + $arrayofandtags[] = trim($s); + } + + // Show each AND part + foreach ($arrayofandtags as $tmpkey => $tmpval) { + $errormessage = ''; + $searchtags = forgeSQLFromUniversalSearchCriteria($tmpval, $errormessage, 1, 1); + if ($errormessage) { + $this->error = 'ERROR in parsing search string: '.$errormessage; + } + // Remove first and last parenthesis but only if first is the opening and last the closing of the same group + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $searchtags = removeGlobalParenthesis($searchtags); + + $ret .= ''; + $ret .= 'x '; + $ret .= dol_escape_htmltag($searchtags); + $ret .= ''; } - //var_dump($searchtags); - $ret .= 'x ' . dol_escape_htmltag($searchtags) . ''; } //$ret .= ''; @@ -10478,9 +10525,11 @@ class Form if ($show_search_component_params_hidden) { $ret .= ''; } - $ret .= ""; + $ret .= ""; $ret .= ''; - // For compatibility with forms that show themself the search criteria in addition of this component, we output the fields + // $ret .= ""; + + // For compatibility with forms that show themself the search criteria in addition of this component, we output these fields foreach ($arrayofcriterias as $criterias) { foreach ($criterias as $criteriafamilykey => $criteriafamilyval) { if (in_array('search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) { @@ -10506,12 +10555,23 @@ class Form $ret .= '
'; - $ret .= "\n"; + $ret .= "\n"; $ret .= ''; $ret .= '
'; $ret .= '
'; + $ret .= ' + '; + + return $ret; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 965c6c4f13f..c2cb0b4e059 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -138,16 +138,16 @@ class FormAccounting extends Form /** * Return list of journals with label by nature * - * @param array $selectedIds Preselected journal code array - * @param string $htmlname Name of field in html form - * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) - * @param int $showempty Add an empty field - * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code - * @param int $select_out Set value returned by select. 0=rowid (default), 1=code - * @param string $morecss More css non HTML object - * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * @param int $disabledajaxcombo Disable ajax combo box. - * @return string String with HTML select + * @param array $selectedIds Preselected journal code array + * @param string $htmlname Name of field in html form + * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) + * @param int $showempty Add an empty field + * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code + * @param int $select_out Set value returned by select. 0=rowid (default), 1=code + * @param string $morecss More css non HTML object + * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. + * @param int $disabledajaxcombo Disable ajax combo box. + * @return string String with HTML select */ public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index b60e26d2931..1f7055f58b0 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1207,7 +1207,7 @@ class FormFile if ($permtoeditline < 0) { // Old behaviour for backward compatibility. New feature should call method with value 0 or 1 $permtoeditline = 0; if (in_array($modulepart, array('product', 'produit', 'service'))) { - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) { + if ($user->hasRight('produit', 'creer') && $object->type == Product::TYPE_PRODUCT) { $permtoeditline = 1; } if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) { @@ -1986,7 +1986,7 @@ class FormFile } elseif ($sortfield == "date") { $sortfield = "datea"; } else { - $sortfield = null; + $sortfield = ''; } $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); $param .= (isset($object->id) ? '&id='.$object->id : ''); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 04510aca821..72312d1d9ce 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -432,7 +432,9 @@ class FormMail extends Form if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { - $this->add_attached_files($file, basename($file), dol_mimetype($file)); + if (!empty($file)) { + $this->add_attached_files($file, basename($file), dol_mimetype($file)); + } } } } @@ -698,18 +700,25 @@ class FormMail extends Form $out .= "
'; $out .= $langs->trans("GroupEmails"); $out .= ''; $out .= ' withoptiononeemailperrecipient > 0 ? ' checked="checked"' : '').'> '; - $out .= ''; - $out .= ''; - $out .= ' - '; - $out .= $langs->trans("WarningIfYouCheckOneRecipientPerEmail"); - $out .= ''; + $out .= ''; + //$out .= ''; + //$out .= ' - '; + //$out .= $langs->trans("WarningIfYouCheckOneRecipientPerEmail"); + //$out .= ''; + if (getDolGlobalString('MASS_ACTION_EMAIL_ON_DIFFERENT_THIRPARTIES_ADD_CUSTOM_EMAIL')) { + if (!empty($this->withto) && !is_array($this->withto)) { + $out .= ' '.$langs->trans("or").' '; + } + } $out .= '
'."\n"; @@ -1199,6 +1202,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl // Fields title search // -------------------------------------------------------------------- print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } foreach ($contactstatic->fields as $key => $val) { $align = ''; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -1241,15 +1250,21 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; + } foreach ($contactstatic->fields as $key => $val) { $align = ''; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -1281,7 +1296,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; + } print ''."\n"; $i = -1; @@ -1331,6 +1349,27 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl print ''; + // Actions + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + // ID if (!empty($arrayfields['t.rowid']['checked'])) { print ''; } - // Edit - if ($user->hasRight('societe', 'contact', 'creer')) { - print ''; - print img_edit(); - print ''; - } - - print ''; - print "\n"; $i++; } @@ -1965,7 +2006,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { $labeltype = 'AC_OTH'; } - if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { + if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) { $labeltype = $langs->trans("Message"); } else { if (!empty($arraylist[$labeltype])) { diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index e864060bc25..088504fbde4 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -134,7 +134,7 @@ function contact_prepare_head(Contact $object) // Agenda / Events $head[$tab][0] = DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id; $head[$tab][1] = $langs->trans("Events"); - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $head[$tab][1] .= '/'; $head[$tab][1] .= $langs->trans("Agenda"); } diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 152c18b59d2..75ffdbf9a7c 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -90,7 +90,7 @@ function contract_prepare_head(Contrat $object) $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 0384704a7f2..00d71f32f91 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -122,7 +122,7 @@ function fichinter_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/fichinter/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans('Events'); - if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 289a2b3082c..6320a82dfa5 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -409,8 +409,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) */ function dol_compare_file($a, $b) { - global $sortorder; - global $sortfield; + global $sortorder, $sortfield; $sortorder = strtoupper($sortorder); @@ -440,6 +439,8 @@ function dol_compare_file($a, $b) } return ($a->size < $b->size) ? $retup : $retdown; } + + return 0; } @@ -3149,7 +3150,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $conf->import->dir_temp.'/'.$original_file; } elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_output)) { // Wrapping for recruitment module - $accessallowed = $user->rights->recruitment->recruitmentjobposition->read; + $accessallowed = $user->hasRight('recruitment', 'recruitmentjobposition', 'read'); $original_file = $conf->recruitment->dir_output.'/'.$original_file; } elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { // Wrapping for wysiwyg editor diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 7093493dad9..85479230d3e 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -229,7 +229,7 @@ function ordersupplier_prepare_head(CommandeFournisseur $object) $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $head[$h][1] .= '/'; $head[$h][1] .= $langs->trans("Agenda"); } diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index 1b7cfc7ca73..8270f9927f7 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2022 Anthony Berton +/* Copyright (C) 2022-2023 Laurent Destailleur + * Copyright (C) 2022 Anthony Berton * * 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 @@ -24,8 +24,6 @@ */ - - /** * Connect to FTP server * @@ -153,6 +151,7 @@ function dol_ftp_close($connect_id) return ftp_close($connect_id); } } + return true; } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e35c9e86e3e..ee41b3a4c92 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -45,7 +45,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; - +// Function for better PHP x compatibility if (!function_exists('utf8_encode')) { /** * Implement utf8_encode for PHP that does not support it. @@ -71,6 +71,46 @@ if (!function_exists('utf8_decode')) { return mb_convert_encoding($elements, 'ISO-8859-1', 'UTF-8'); } } +if (!function_exists('str_starts_with')) { + /** + * str_starts_with + * + * @param string $haystack haystack + * @param string $needle needle + * @return boolean + */ + function str_starts_with($haystack, $needle) + { + return (string) $needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0; + } +} +if (!function_exists('str_ends_with')) { + /** + * str_ends_with + * + * @param string $haystack haystack + * @param string $needle needle + * @return boolean + */ + function str_ends_with($haystack, $needle) + { + return $needle !== '' && substr($haystack, -strlen($needle)) === (string) $needle; + } +} +if (!function_exists('str_contains')) { + /** + * str_contains + * + * @param string $haystack haystack + * @param string $needle needle + * @return boolean + */ + function str_contains($haystack, $needle) + { + return $needle !== '' && mb_strpos($haystack, $needle) !== false; + } +} + /** * Return the full path of the directory where a module (or an object of a module) stores its files. Path may depends on the entity if a multicompany module is enabled. @@ -171,7 +211,8 @@ function isModEnabled($module) // Fix special cases $arrayconv = array( 'project' => 'projet', - 'contract' => 'contrat' + 'contract' => 'contrat', + 'bank' => 'banque' ); if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) { $arrayconv['supplier_order'] = 'fournisseur'; @@ -1542,6 +1583,7 @@ function dol_escape_json($stringtoescape) /** * Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input fields. + * When we output string on pages, we use dol_string_onlythesehtmltags(dol_htmlentitiesbr()) for notes, and use dol_escape_htmltag() for simple labels. * * @param string $stringtoescape String to escape * @param int $keepb 1=Keep b tags, 0=remove them completely @@ -2044,7 +2086,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab } } elseif (!empty($links[$i][1])) { $outmore .= ''; - $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. + $outmore .= preg_replace('/([a-z])\|([a-z])/i', '\\1 | \\2', $links[$i][1]); // Replace x|y with x | y to allow wrap on long composed texts. $outmore .= ''."\n"; } $outmore .= ''; @@ -3257,7 +3299,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor $htmllink .= '?chat" alt="'.$langs->trans("Chat").' '.$value.'" title="'.dol_escape_htmltag($langs->trans("Chat").' '.$value).'">'; $htmllink .= ''; $htmllink .= ''; - if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create) { + if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'create')) { $addlink = 'AC_SKYPE'; $link = ''; if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) { @@ -3593,7 +3635,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } - //if (($cid || $socid) && isModEnabled('agenda') && $user->rights->agenda->myactions->create) + //if (($cid || $socid) && isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'create')) if (isModEnabled('agenda') && $user->hasRight("agenda", "myactions", "create")) { $type = 'AC_TEL'; $link = ''; @@ -4162,7 +4204,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', 'edit', 'ellipsis-h', 'email', 'entity', 'envelope', 'eraser', 'establishment', 'expensereport', 'external-link-alt', 'external-link-square-alt', 'eye', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', - 'gears', 'generate', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', + 'gears', 'generate', 'generic', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'hands-helping', 'help', 'holiday', 'id-card', 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'jobprofile', 'knowledgemanagement', @@ -4402,7 +4444,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if ($srconly) { return $fullpathpicto; } - // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people + + // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } @@ -5170,7 +5213,8 @@ function dol_print_error($db = '', $error = '', $errors = null) if (function_exists('top_httphead')) { // In CLI context, the method does not exists top_httphead(); } - http_response_code(500); + //http_response_code(500); // If we use 500, message is not ouput with some command line tools + http_response_code(202); // If we use 202, this is not really an error message, but this allow to ouput message on command line tools } if (empty($dolibarr_main_prod)) { @@ -5212,7 +5256,7 @@ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = $now = dol_now(); print '
'; + } if ($showproject) { // Project ref @@ -822,14 +834,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Progress calculated (Note: ->duration is time spent) if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { - print ''; } @@ -892,7 +908,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; // Action column - print ''; + print ''; + } print "\n"; @@ -973,9 +993,15 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } + // Total line if (($total_projectlinesa_planned > 0 || $total_projectlinesa_spent > 0 || $total_projectlinesa_tobill > 0 || $total_projectlinesa_billed > 0 || $total_budget_amount > 0) && $level <= 0) { print ''; + + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ''; if ($showproject) { print ''; @@ -1092,18 +1118,24 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; } - //Check if Extrafields is totalizable - foreach ($extrafields->attributes['projet_task']['totalizable'] as $key=>$value) { - if ($arrayfields['ef.'.$key]['checked'] == 1) { - print ''; } } + // Column for the drag and drop print ''; + + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ''; } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index b24fec85a9c..626a89a9bea 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -111,7 +111,7 @@ function propal_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/comm/propal/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda')&& ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $nbEvent = 0; // Enable caching of thirdparty count actioncomm require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 1fa2aa2f2e1..2a1e09b96c3 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -88,7 +88,7 @@ function resource_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/resource/agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $head[$h][1] .= '/'; $head[$h][1] .= $langs->trans("Agenda"); } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b95253bf040..1dddac4d4f9 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -116,6 +116,7 @@ function dolGetRandomBytes($length) * @param string $ciphering Default ciphering algorithm * @param string $forceseed To force the seed * @return string encoded string + * @since v17 * @see dolDecrypt(), dol_hash() */ function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = '') @@ -153,7 +154,7 @@ function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = if (empty($forceseed)) { $ivseed = dolGetRandomBytes($ivlen); } else { - $ivseed = dol_trunc(md5($forceseed), $ivlen, 'right', 'UTF-8', 1); + $ivseed = dol_substr(md5($forceseed), 0, $ivlen, 'ascii', 1); } $newchain = openssl_encrypt($chain, $ciphering, $key, 0, $ivseed); @@ -170,6 +171,7 @@ function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = * @param string $chain string to encode * @param string $key If '', we use $conf->file->instance_unique_id * @return string encoded string + * @since v17 * @see dolEncrypt(), dol_hash() */ function dolDecrypt($chain, $key = '') @@ -358,6 +360,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } else { $objectid = $object; // $objectid can be X or 'X,Y,Z' } + if ($objectid == "-1") { + $objectid = 0; + } if ($objectid) { $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input } @@ -377,6 +382,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $feature2 = 'myactions|allactions'; $dbt_select = 'id'; } + if ($features == 'bank') { + $features = 'banque'; + } if ($features == 'facturerec') { $features = 'facture'; } @@ -496,7 +504,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $nbko++; } } elseif ($feature == 'payment') { - if (empty($user->rights->facture->lire)) { + if (!$user->hasRight('facture', 'lire')) { $readok = 0; $nbko++; } @@ -561,7 +569,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', // Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files) $createok = 1; $nbko = 0; - $wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || in_array(GETPOST('action', 'aZ09'), array('create', 'update', 'set', 'upload', 'add_element_resource', 'confirm_delete_linked_resource')) || GETPOST('roworder', 'alpha', 2)); + $wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || in_array(GETPOST('action', 'aZ09'), array('create', 'update', 'set', 'upload', 'add_element_resource', 'confirm_deletebank', 'confirm_delete_linked_resource')) || GETPOST('roworder', 'alpha', 2)); $wemustcheckpermissionfordeletedraft = ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'); if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) { @@ -587,7 +595,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $nbko++; } } elseif ($feature == 'banque') { - if (empty($user->rights->banque->modifier)) { + if (!$user->hasRight('banque', 'modifier')) { $createok = 0; $nbko++; } @@ -608,13 +616,13 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } } elseif (!empty($feature2)) { // This is for permissions on 2 levels (module->object->write) foreach ($feature2 as $subfeature) { - if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) { + if ($subfeature == 'user' && $user->id == $objectid && $user->hasRight('user', 'self', 'creer')) { continue; // User can edit its own card } - if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) { + if ($subfeature == 'user' && $user->id == $objectid && $user->hasRight('user', 'self', 'password')) { continue; // User can edit its own password } - if ($subfeature == 'user' && $user->id != $objectid && $user->rights->user->user->password) { + if ($subfeature == 'user' && $user->id != $objectid && $user->hasRight('user', 'user', 'password')) { continue; // User can edit another user's password } @@ -658,7 +666,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', // Check create user permission $createuserok = 1; if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') { - if (!$user->rights->user->user->creer) { + if (!$user->hasRight('user', 'user', 'creer')) { $createuserok = 0; } @@ -688,7 +696,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $deleteok = 0; } } elseif ($feature == 'produit|service') { - if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) { + if (!$user->hasRight('produit', 'supprimer') && !$user->hasRight('service', 'supprimer')) { $deleteok = 0; } } elseif ($feature == 'commande_fournisseur') { @@ -708,7 +716,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $deleteok = 0; } } elseif ($feature == 'banque') { - if (empty($user->rights->banque->modifier)) { + if (!$user->hasRight('banque', 'modifier')) { $deleteok = 0; } } elseif ($feature == 'cheque') { @@ -847,14 +855,15 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $feature = 'agenda'; $dbtablename = 'actioncomm'; } - if ($feature == 'payment_sc') { $feature = "chargesociales"; + $objectid = $object->fk_charge; } + $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment','chargesociales'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment', 'chargesociales'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe $checkother = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object @@ -1002,7 +1011,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 1; } - //var_dump($checkonentitydone); + //var_dump($sql); if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield // If external user: Check permission for external users diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index f6d354d9431..17a0657dc0a 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -569,10 +569,12 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token { global $conf; + $out = ''; + if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - print ''; + $out .= ''; } + + return $out; } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 29ced3591a1..799594fcefd 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -155,8 +155,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // Define sql request $sql = ''; - if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { + if (($direction == 'sell' && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($direction == 'buy' && getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; @@ -168,6 +168,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype, p.tosell as pstatus, p.tobuy as pstatusbuy,"; $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; + $sql .= " ,'' as datep"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,"; $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; @@ -303,6 +304,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; } + $list[$assoc['company_id']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['company_id']]['dtype'][] = $assoc['dtype']; $list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']); @@ -356,8 +358,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di // Define sql request $sql = ''; - if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + if (($direction == 'sell' && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') + || ($direction == 'buy' && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; @@ -743,8 +745,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // Define sql request $sql = ''; - if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { + if (($direction == 'sell' && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') + || ($direction == 'buy' && getDolGlobalString('TAX_MODE_BUY_PRODUCT') == 'invoice')) { // Count on delivery date (use invoice date as delivery is unknown) $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; @@ -755,7 +757,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; + $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount,"; + $sql .= " '' as datep"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$invoicedettable." as d ON d.".$fk_facture."=f.rowid"; @@ -944,8 +947,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // Define sql request $sql = ''; - if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') - || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) { + if (($direction == 'sell' && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') + || ($direction == 'buy' && getDolGlobalString('TAX_MODE_BUY_SERVICE') == 'invoice')) { // Count on invoice date $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.vat_src_code as vat_src_code, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index d31da45f968..0e6ddfba0b5 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -133,7 +133,7 @@ function ticket_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; } $head[$h][1] = $langs->trans('Events'); - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $head[$h][1] .= '/'; $head[$h][1] .= $langs->trans("Agenda"); } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 8058deb387b..0c6d9932bca 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -40,7 +40,7 @@ function user_prepare_head(User $object) $canreadperms = true; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms)); + $canreadperms = ($user->admin || ($user->id != $object->id && $user->hasRight('user', 'user_advance', 'readperms')) || ($user->id == $object->id && $user->hasRight('user', 'self_advance', 'readperms'))); } $h = 0; @@ -394,7 +394,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print $langs->trans("WarningThemeForcedTo", $conf->global->MAIN_FORCETHEME); } - print '
'; + print $form->showFilterButtons(); + print ''; - print $form->showFilterButtons(); - print ''; + print $form->showFilterButtons(); + print '
'; + + // Add to agenda + if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) { + print ''; + print img_object($langs->trans("Event"), "action"); + print '   '; + } + + // Edit + if ($user->hasRight('societe', 'contact', 'creer')) { + print ''; + print img_edit(); + print ''; + } + + print ''; @@ -1406,24 +1445,26 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Actions - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - // Add to agenda - if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) { - print ''; - print img_object($langs->trans("Event"), "action"); - print '   '; + // Add to agenda + if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) { + print ''; + print img_object($langs->trans("Event"), "action"); + print '   '; + } + + // Edit + if ($user->hasRight('societe', 'contact', 'creer')) { + print ''; + print img_edit(); + print ''; + } + + print '
'; + $selected = 0; + if (in_array($lines[$i]->id, $arrayofselected)) { + $selected = 1; + } + print ''; + print ''; + $s = ''; $shtml = ''; if ($lines[$i]->planned_workload || $lines[$i]->duration) { if ($lines[$i]->planned_workload) { - print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; + $s = round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; + $shtml = $s; } else { - print ''.$langs->trans('WorkloadNotDefined').''; + $s = $langs->trans('WorkloadNotDefined'); + $shtml = ''.$s.''; } } + print ''; + print $shtml; print ''; $ifisrt = 1; foreach (array('internal', 'external') as $source) { - $tab = $lines[$i]->liste_contact(-1, $source); + //$tab = $lines[$i]->liste_contact(-1, $source); + $tab = $lines[$i]->liste_contact(-1, $source, 0, '', 1); + $numcontact = count($tab); if (!empty($numcontact)) { foreach ($tab as $contacttask) { @@ -936,14 +954,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; - $selected = 0; - if (in_array($lines[$i]->id, $arrayofselected)) { - $selected = 1; - } - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $selected = 0; + if (in_array($lines[$i]->id, $arrayofselected)) { + $selected = 1; + } + print ''; - print '
'.$langs->trans("Total").''; + // Check if Extrafields is totalizable + foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { + if (!empty($arrayfields['ef.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { + print ''; if ($value == 1) { - print $totalarray['totalizable'][$key]['total']; + print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; } print '
'."\n"; -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { // Customer Categories print 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) { } } if ($mysoc->useLocalTax(2)) { - if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { + if (( isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); } else { $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 6a54ee53e79..f2e72ef4fd2 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -27,7 +27,7 @@ if (empty($conf) || !is_object($conf)) { } // DDOS protection -$size = (int) $_SERVER['CONTENT_LENGTH']; +$size = (int) ($_SERVER['CONTENT_LENGTH'] ?? 0); if ($size > 10000) { $langs->loadLangs(array("errors", "install")); httponly_accessforbidden('
'.$langs->trans("ErrorRequestTooLarge").'
'.$langs->trans("ClickHereToGoToApp").'
', 413, 1); diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 6bdaeb1aca6..5290b2eb085 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -120,6 +120,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); } $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + // For merge event, we add a mention + if (!empty($object->context['mergefromname'])) { + $object->actionmsg = dol_concatdesc($object->actionmsg, $langs->trans("DataFromWasMerged", $object->context['mergefromname'])); + } $object->sendtoid = 0; $object->socid = $object->id; @@ -1077,8 +1081,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; - $actioncomm->label = $object->actionmsg2; - $actioncomm->note_private = $object->actionmsg; + $actioncomm->label = $object->actionmsg2; // Label of event + $actioncomm->note_private = $object->actionmsg; // Description $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 768ddd216d7..126e711f5c5 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -116,7 +116,7 @@ class ActionsDatapolicy $object->state_id = ''; $object->socialnetworks = ''; $object->country_id = ''; - $object->note_private = $object->note_private.'
'.$langs->trans('ANONYMISER_AT', dol_print_date(time())); + $object->note_private = dol_concatdesc($object->note_private, $langs->trans('ANONYMISER_AT', dol_print_date(dol_now()))); if ($object->update($object->id, $user, 0)) { // On supprime les contacts associé diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index abed76cff93..478b58cd1af 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -442,7 +442,7 @@ if ($action == 'create') { // Incoterms if (isModEnabled('incoterm')) { print ' - +
'; + print ''."\n"; } -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { // Customer Categories print '
'; $i = 0; foreach ($dirthemes as $dir) { @@ -470,7 +470,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; } - //Dark mode + // Dark mode if ($foruserprofile) { //Nothing } else { @@ -527,7 +527,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print '
'; if ($edit) { //print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); - print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, isset($conf->global->THEME_TOPMENU_DISABLE_IMAGE)?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:0); + print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, isset($conf->global->THEME_TOPMENU_DISABLE_IMAGE)?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:0, 0, 0, 0, '', 0, 0, 0, '', 'widthcentpercentminusx maxwidth500'); } else { $listoftopmenumodes[$conf->global->THEME_TOPMENU_DISABLE_IMAGE]; //print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE); diff --git a/htdocs/core/login/functions_googleoauth.php b/htdocs/core/login/functions_googleoauth.php index 7130f9c6f2a..dd5c7ac15bb 100644 --- a/htdocs/core/login/functions_googleoauth.php +++ b/htdocs/core/login/functions_googleoauth.php @@ -49,7 +49,7 @@ function check_user_password_googleoauth($usertotest, $passwordtotest, $entityto if (GETPOST('actionlogin') == 'login') { if (GETPOST('beforeoauthloginredirect')) { // We post the form on the login page by clicking on the link to login using Google. - dol_syslog("We post the form on the login page by clicking on the link to login using Google"); + dol_syslog("We post the form on the login page by clicking on the link to login using Google. We save _SESSION['datafromloginform']"); // We save data of form into a variable $_SESSION['datafromloginform'] = array( @@ -114,7 +114,7 @@ function check_user_password_googleoauth($usertotest, $passwordtotest, $entityto } // If googleoauth_login has been set (by google_oauthcallback after a successfull OAUTH2 request on openid scope - if (dol_verifyHash($conf->file->instance_unique_id.$usertotest, $_SESSION['googleoauth_receivedlogin'], '0')) { + if (!empty($_SESSION['googleoauth_receivedlogin']) && dol_verifyHash($conf->file->instance_unique_id.$usertotest, $_SESSION['googleoauth_receivedlogin'], '0')) { unset($_SESSION['googleoauth_receivedlogin']); $login = $usertotest; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 1b65074a82e..0cdb8e9bfae 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -139,7 +139,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/list.php?mainmenu=products', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/movement_list.php?mainmenu=products', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock") && isModEnabled("supplier_order")', __HANDLER__, 'left', 3105__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/replenish.php?mainmenu=products', 'Replenishments', 1, 'stocks', '$user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php?init=1&mainmenu=products', 'MassStockTransferShort', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/stockatdate.php?mainmenu=products', 'StockAtDate', 1, 'stocks', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("stock")', __HANDLER__, 'left', 3107__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php?init=1&mainmenu=products', 'MassStockTransferShort', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __ENTITY__); -- Product - Categories insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("categorie")', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?mainmenu=products&leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->hasRight("categorie","lire")', '', 2, 4, __ENTITY__); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index ea05679b2d7..091f2b7e969 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -374,8 +374,8 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $db->free($resql); } - if (isModEnabled('accounting') && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account - $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->rights->accounting->comptarapport->lire, '', 'accountancy', 'accountancy', 10); + if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { // Entry in accountancy journal for each bank account + $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', 'accountancy', 'accountancy_journal', 10); // Multi journal $sql = "SELECT rowid, code, label, nature"; @@ -430,13 +430,13 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t if ($nature) { $langs->load('accountancy'); $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ... - $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire); + $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->hasRight('accounting', 'comptarapport', 'lire')); } $i++; } } else { // Should not happend. Entries are added - $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); + $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->hasRight('accounting', 'comptarapport', 'lire')); } } else { dol_print_error($db); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 91d2f5a86b4..f87e01f75cd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1169,16 +1169,16 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if ($user->hasRight('user', 'user', 'read')) { if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") { $newmenu->add("", $langs->trans("Users"), 1, $user->hasRight('user', 'user', 'lire') || $user->admin); - $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home'); + $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->hasRight("user", "user", "write") || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)), '', 'home'); $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin); $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->hasRight('user', 'user', 'lire') || $user->admin); if (isModEnabled('categorie')) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } - $newmenu->add("", $langs->trans("Groups"), 1, ($user->hasRight('user', 'user', 'lire') || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); - $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "create")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); - $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'lire')) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); + $newmenu->add("", $langs->trans("Groups"), 1, ($user->hasRight('user', 'user', 'lire') || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); + $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "create")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); + $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'lire')) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); } } } @@ -1677,7 +1677,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef // Journals if (isModEnabled('accounting') && $user->hasRight('accounting', 'comptarapport', 'lire') && $mainmenu == 'accountancy') { - $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', '', ''); + $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->hasRight('accounting', 'comptarapport', 'lire'), '', $mainmenu, 'accountancy_journal'); // Multi journal $sql = "SELECT rowid, code, label, nature"; @@ -2166,9 +2166,9 @@ function get_left_menu_mrp($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = if (isModEnabled('mrp')) { $langs->load("mrp"); - $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mo', 0, '', '', '', img_picto('', 'mrp', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/mrp/mo_card.php?leftmenu=mo&action=create", $langs->trans("NewMO"), 1, $user->hasRight('mrp', 'write'), '', $mainmenu, 'mo'); - $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mo'); + $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->hasRight('mrp', 'read'), '', $mainmenu, 'mrp', 0, '', '', '', img_picto('', 'mrp', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/mrp/mo_card.php?leftmenu=mo&action=create", $langs->trans("NewMO"), 1, $user->hasRight('mrp', 'write'), '', $mainmenu, ''); + $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->hasRight('mrp', 'read'), '', $mainmenu, ''); } } } diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index a68b8fd2354..657bf4fee22 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -46,18 +46,11 @@ class doc_generic_asset_odt extends ModelePDFAsset */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ public $version = 'dolibarr'; - /** * Constructor * @@ -269,8 +262,8 @@ class doc_generic_asset_odt extends ModelePDFAsset //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index d62a1eb6ada..75fb8025e42 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -68,12 +68,6 @@ class pdf_standard_asset extends ModelePDFAsset */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index d34844f14f2..8ef4046c466 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -46,12 +46,6 @@ class doc_generic_bom_odt extends ModelePDFBom */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -280,8 +274,8 @@ class doc_generic_bom_odt extends ModelePDFBom //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9172115903b..f37c35b185a 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -46,12 +46,6 @@ class doc_generic_order_odt extends ModelePDFCommandes */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -286,8 +280,8 @@ class doc_generic_order_odt extends ModelePDFCommandes // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 20e738f14c8..9f8008dda11 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -72,12 +72,6 @@ class pdf_einstein extends ModelePDFCommandes */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index ccb68a003bb..458cc39dd27 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -72,12 +72,6 @@ class pdf_eratosthene extends ModelePDFCommandes */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index aec1a96109a..478799d4518 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -44,12 +44,6 @@ class doc_generic_contract_odt extends ModelePDFContract */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -284,8 +278,8 @@ class doc_generic_contract_odt extends ModelePDFContract // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 2f434af93a6..fe6f77b9b9a 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -70,12 +70,6 @@ class pdf_strato extends ModelePDFContract */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index c84c9b7e6a0..fc55f6fe0f3 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -64,12 +64,6 @@ class pdf_storm extends ModelePDFDeliveryOrder */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index af2fda0f7a8..31c46438992 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -63,12 +63,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index bf264b45c94..5f216bb0ac6 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -46,12 +46,6 @@ class doc_generic_shipment_odt extends ModelePdfExpedition */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -284,8 +278,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 9592330da2e..297013ed8ac 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -61,12 +61,6 @@ class pdf_espadon extends ModelePdfExpedition */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 130608be433..1d8e0c3f19e 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -62,12 +62,6 @@ class pdf_merou extends ModelePdfExpedition */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index f7c6599647b..11635c6511b 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -62,12 +62,6 @@ class pdf_rouget extends ModelePdfExpedition */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 5568cd28840..b8a58d3b517 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -69,12 +69,6 @@ class pdf_standard extends ModeleExpenseReport */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index cc9bc723635..9e203e8d5ce 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -45,12 +45,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -284,8 +278,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index a0aa602b9c7..7941815ee24 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -69,12 +69,6 @@ class pdf_crabe extends ModelePDFFactures */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -354,6 +348,15 @@ class pdf_crabe extends ModelePDFFactures $heightforfooter += 6; } + $heightforqrinvoice_firstpage = 0; + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { + $heightforqrinvoice_firstpage = $this->getHeightForQRInvoice(1, $object, $langs); + if ($heightforqrinvoice_firstpage > 0) { + // Shrink infotot to a base 30 + $heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part + } + } + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); @@ -487,9 +490,10 @@ class pdf_crabe extends ModelePDFFactures $qrcodestring = ''; if (!empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) { $qrcodestring = $object->buildZATCAQRString(); - } elseif (!empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) { + } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1') { $qrcodestring = $object->buildSwitzerlandQRString(); } + if ($qrcodestring) { $qrcodecolor = array('25', '25', '25'); // set style for QR-code @@ -597,7 +601,8 @@ class pdf_crabe extends ModelePDFFactures } $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs); + $pdf->setPageOrientation('', 1, $page_bottom_margin); $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; @@ -605,7 +610,7 @@ class pdf_crabe extends ModelePDFFactures $posYAfterDescription = 0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - $page_bottom_margin)) { // If photo too high, we moved completely on new page $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); @@ -648,7 +653,7 @@ class pdf_crabe extends ModelePDFFactures $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // There is no space left for total+free text if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); if (!empty($tplidx)) { @@ -832,11 +837,11 @@ class pdf_crabe extends ModelePDFFactures while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs)); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -850,11 +855,11 @@ class pdf_crabe extends ModelePDFFactures } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs)); // New page $pdf->AddPage(); if (!empty($tplidx)) { @@ -870,8 +875,8 @@ class pdf_crabe extends ModelePDFFactures // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0, $object->multicurrency_code); + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; @@ -890,11 +895,18 @@ class pdf_crabe extends ModelePDFFactures } // Pagefoot - $this->_pagefoot($pdf, $object, $outputlangs); + $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pageposbefore, $object, $langs)); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { + $result = $this->addBottomQRInvoice($pdf, $object, $outputlangs); + if (!$result) { + $pdf->Close(); + return 0; + } + } $pdf->Close(); $pdf->Output($file, 'F'); @@ -2190,11 +2202,12 @@ class pdf_crabe extends ModelePDFFactures * @param Facture $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text + * @param int $heightforqrinvoice Height for QR invoices * @return int Return height of bottom margin including footer text */ - protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0) { $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); - return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); + return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 254337d9bbb..fbf1907ec7d 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -70,12 +70,6 @@ class pdf_sponge extends ModelePDFFactures */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -382,6 +376,14 @@ class pdf_sponge extends ModelePDFFactures $this->heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $this->heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + $heightforqrinvoice = $heightforqrinvoice_firstpage = 0; + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { + if ($this->getHeightForQRInvoice(1, $object, $langs) > 0) { + // Shrink infotot to a base 30 + $this->heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part + } + } + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); @@ -498,7 +500,7 @@ class pdf_sponge extends ModelePDFFactures $qrcodestring = ''; if (!empty($conf->global->INVOICE_ADD_ZATCA_QR_CODE)) { $qrcodestring = $object->buildZATCAQRString(); - } elseif (!empty($conf->global->INVOICE_ADD_SWISS_QR_CODE)) { + } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1') { $qrcodestring = $object->buildSwitzerlandQRString(); } if ($qrcodestring) { @@ -534,7 +536,7 @@ class pdf_sponge extends ModelePDFFactures // Define heigth of table for lines (for first page) - $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext; + $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->getHeightForQRInvoice(1, $object, $langs); $nexY = $this->tab_top - 1; @@ -612,7 +614,6 @@ class pdf_sponge extends ModelePDFFactures if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } - // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($this->tab_top_newpage); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext); @@ -657,7 +658,7 @@ class pdf_sponge extends ModelePDFFactures // Add footer $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs)); $i++; } @@ -728,7 +729,8 @@ class pdf_sponge extends ModelePDFFactures } $pdf->setTopMargin($this->tab_top_newpage); - $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs); + $pdf->setPageOrientation('', 1, $page_bottom_margin); $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; @@ -737,7 +739,7 @@ class pdf_sponge extends ModelePDFFactures if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) { // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - $page_bottom_margin)) { // If photo too high, we moved completely on new page $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); @@ -778,7 +780,7 @@ class pdf_sponge extends ModelePDFFactures $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($this->heightforfooter+$this->heightforfreetext+$this->heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot))) { // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // There is no space left for total+free text if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); if (!empty($tplidx)) { @@ -983,12 +985,13 @@ class pdf_sponge extends ModelePDFFactures // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); + $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs); if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); + $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); } else { - $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); + $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs)); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -1001,12 +1004,13 @@ class pdf_sponge extends ModelePDFFactures } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { + $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs); if ($pagenb == $pageposafter) { - $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); + $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis); } else { - $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); + $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis); } - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs)); // New page $pdf->AddPage(); if (!empty($tplidx)) { @@ -1020,12 +1024,13 @@ class pdf_sponge extends ModelePDFFactures } // Show square + $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs); if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); - $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1; + $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); + $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1; } else { - $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis); - $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1; + $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis); + $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1; } // Display infos area @@ -1040,11 +1045,14 @@ class pdf_sponge extends ModelePDFFactures } // Pagefoot - $this->_pagefoot($pdf, $object, $outputlangs); + $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pageposbefore, $object, $langs)); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { + $this->addBottomQRInvoice($pdf, $object, $outputlangs); + } $pdf->Close(); $pdf->Output($file, 'F'); @@ -1530,7 +1538,7 @@ class pdf_sponge extends ModelePDFFactures foreach ($TPreviousIncoice as &$fac) { if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) { - $this->_pagefoot($pdf, $object, $outputlangs, 1); + $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs)); $pdf->addPage(); if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); @@ -2442,12 +2450,13 @@ class pdf_sponge extends ModelePDFFactures * @param Facture $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text + * @param int $heightforqrinvoice Height for QR invoices * @return int Return height of bottom margin including footer text */ - protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0) { $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); - return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); + return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } /** diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 8fda383291d..9524e0d9be3 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit +use Sprain\SwissQrBill; /** * Parent class of invoice document generators @@ -78,6 +79,160 @@ abstract class ModelePDFFactures extends CommonDocGenerator return $list; } + + /** + * Get the SwissQR object, including validation + * + * @param Facture $object Invoice object + * @param Translate $langs Translation object + * @return SwissQrBill\QrBill|bool The valid SwissQR object, or false + */ + private function getSwissQrBill(Facture $object, Translate $langs) + { + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') != 'bottom') { + return false; + } + + if ($object->mode_reglement_code != 'VIR') { + $this->error = $langs->transnoentities("SwissQrOnlyVIR"); + return false; + } + + if (empty($object->fk_account)) { + $this->error = 'Bank account must be defined to use this experimental feature'; + return false; + } + + require_once DOL_DOCUMENT_ROOT.'/includes/sprain/swiss-qr-bill/autoload.php'; + + // Create a new instance of SwissQrBill, containing default headers with fixed values + $qrBill = SwissQrBill\QrBill::create(); + + // First, set creditor address + $address = SwissQrBill\DataGroup\Element\CombinedAddress::create( + $this->emetteur->name, + $this->emetteur->address, + $this->emetteur->zip . " " . $this->emetteur->town, + $this->emetteur->country_code + ); + if (!$address->isValid()) { + $this->error = $langs->transnoentities("SwissQrCreditorAddressInvalid", (string) $address->getViolations()); + return false; + } + $qrBill->setCreditor($address); + + // Get IBAN from account. + $account = new Account($this->db); + $account->fetch($object->fk_account); + + $creditorInformation = SwissQrBill\DataGroup\Element\CreditorInformation::create($account->iban); + if (!$creditorInformation->isValid()) { + $this->error = $langs->transnoentities("SwissQrCreditorInformationInvalid", $account->iban, (string) $creditorInformation->getViolations()); + return false; + } + $qrBill->setCreditorInformation($creditorInformation); + + if ($creditorInformation->containsQrIban()) { + $this->error = $langs->transnoentities("SwissQrIbanNotImplementedYet", $account->iban); + return false; + } + + // Add payment reference CLASSIC-IBAN + // This is what you will need to identify incoming payments. + $qrBill->setPaymentReference( + SwissQrBill\DataGroup\Element\PaymentReference::create( + SwissQrBill\DataGroup\Element\PaymentReference::TYPE_NON + ) + ); + + // Add payment amount, with currency + $pai = SwissQrBill\DataGroup\Element\PaymentAmountInformation::create($object->multicurrency_code, $object->total_ttc); + if (!$pai->isValid()) { + $this->error = $langs->transnoentities("SwissQrPaymentInformationInvalid", $object->total_ttc, (string) $pai->getViolations()); + return false; + } + $qrBill->setPaymentAmountInformation($pai); + + // Add some human-readable information about what the bill is for. + $qrBill->setAdditionalInformation( + SwissQrBill\DataGroup\Element\AdditionalInformation::create( + $object->ref + ) + ); + + // Set debtor address; We _know_ zip&town have to be filled, so skip that if unfilled. + if (!empty($object->thirdparty->zip) && !empty($object->thirdparty->town)) { + $address = SwissQrBill\DataGroup\Element\CombinedAddress::create( + $object->thirdparty->name, + $object->thirdparty->address, + $object->thirdparty->zip . " " . $object->thirdparty->town, + $object->thirdparty->country_code + ); + if (!$address->isValid()) { + $this->error = $langs->transnoentities("SwissQrDebitorAddressInvalid", (string) $address->getViolations()); + return false; + } + $qrBill->setUltimateDebtor($address); + } + + return $qrBill; + } + + /** + * Get the height for bottom-page QR invoice in mm, depending on the page number. + * + * @param int $pagenbr Page number + * @param Facture $object Invoice object + * @param Translate $langs Translation object + * @return int Height in mm of the bottom-page QR invoice. Can be zero if not on right page; not enabled + */ + protected function getHeightForQRInvoice(int $pagenbr, Facture $object, Translate $langs) : int + { + if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') { + // Keep it, to reset it after QRinvoice getter + $error = $this->error; + + if (!$this->getSwissQrBill($object, $langs)) { + // Reset error to previous one if exists + if (!empty($error)) { + $this->error = $error; + } + return 0; + } + // SWIFT's requirementis 105, but we get more room with 100 and the page number is in a nice place. + return $pagenbr == 1 ? 100 : 0; + } + + return 0; + } + + /** + * Add SwissQR invoice at bottom of page 1 + * + * @param TCPDF $pdf TCPDF object + * @param Facture $object Invoice object + * @param Translate $langs Translation object + * @return bool True for for success + */ + public function addBottomQRInvoice(TCPDF $pdf, Facture $object, Translate $langs) : bool + { + if (!($qrBill = $this->getSwissQrBill($object, $langs))) { + return false; + } + + try { + $pdf->startTransaction(); + + $pdf->setPage(1); + $pdf->SetTextColor(0, 0, 0); + $output = new SwissQrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput($qrBill, in_array($langs->shortlang, ['de', 'fr', 'it']) ? $langs->shortlang : 'en', $pdf); + $output->setPrintable(false)->getPaymentPart(); + } catch (Exception $e) { + $pdf->rollbackTransaction(true); + return false; + } + return true; + } } /** diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index cd1cdf48f5e..d42f85cb3cf 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -64,12 +64,6 @@ class pdf_soleil extends ModelePDFFicheinter */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index c742affdf26..29cd8ca5a21 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -782,26 +782,26 @@ class ImportCsv extends ModeleImports // Previously we processed the ->import_fields_array. if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { - if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) { + foreach ($objimport->array_import_fieldshidden[0] as $tmpkey => $tmpval) { + if (!preg_match('/^'.preg_quote($alias, '/').'\./', $tmpkey)) { continue; // Not a field of current table } - if ($val == 'user->id') { - $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + if ($tmpval == 'user->id') { + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $tmpkey); $listvalues[] = ((int) $user->id); - } elseif (preg_match('/^lastrowid-/', $val)) { - $tmp = explode('-', $val); + } elseif (preg_match('/^lastrowid-/', $tmpval)) { + $tmp = explode('-', $tmpval); $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; - $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $tmpkey); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; - //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; - } elseif (preg_match('/^const-/', $val)) { - $tmp = explode('-', $val, 2); - $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + //print $tmpkey."-".$tmpval."-".$listfields."-".$listvalues."
";exit; + } elseif (preg_match('/^const-/', $tmpval)) { + $tmp = explode('-', $tmpval, 2); + $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $tmpkey); $listvalues[] = "'".$this->db->escape($tmp[1])."'"; - } elseif (preg_match('/^rule-/', $val)) { - $fieldname = $key; + } elseif (preg_match('/^rule-/', $tmpval)) { + $fieldname = $tmpkey; if (!empty($objimport->array_import_convertvalue[0][$fieldname])) { if ($objimport->array_import_convertvalue[0][$fieldname]['rule'] == 'compute') { $file = (empty($objimport->array_import_convertvalue[0][$fieldname]['classfile']) ? $objimport->array_import_convertvalue[0][$fieldname]['file'] : $objimport->array_import_convertvalue[0][$fieldname]['classfile']); @@ -823,7 +823,7 @@ class ImportCsv extends ModeleImports } } } else { - $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['lib'] = 'Bad value of profile setup '.$tmpval.' for array_import_fieldshidden'; $this->errors[$error]['type'] = 'Import profile setup'; $error++; } diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 07405c9f7ad..3e947b6ed93 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -32,7 +32,7 @@ class mailing_partnership extends MailingTargets public $require_admin = 0; - public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated + public $require_module = array('partnership'); // This module allows to select by categories must be also enabled if category module is not activated /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index f38f61e6d8a..024248a0ce1 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -41,12 +41,6 @@ class doc_generic_member_odt extends ModelePDFMember */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -274,8 +268,8 @@ class doc_generic_member_odt extends ModelePDFMember // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index 77ab5621915..41fbbacf2b3 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -67,6 +67,15 @@ abstract class ModelePDFMember extends CommonDocGenerator */ abstract class ModeleNumRefMembers { + + public $code_modifiable; // Editable code + + public $code_modifiable_invalide; // Modified code if it is invalid + + public $code_modifiable_null; // Modified code if it is null + + public $code_null; // + /** * @var string Error code (or message) */ diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 63e619a2370..f3d237c35dd 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -480,7 +480,7 @@ class modAgenda extends DolibarrModules 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)) { + if (!$user->hasRight('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/modDav.class.php b/htdocs/core/modules/modDav.class.php index 356f043cea0..7c0929891a8 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -91,7 +91,7 @@ class modDav extends DolibarrModules $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("admin"); - $this->phpmin = array(7, 0); // Minimum version of PHP required by module + $this->phpmin = array(7, 1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(7, 0); // Minimum version of Dolibarr required by module $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 3a8f5a47497..0a8f67016e1 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -296,8 +296,9 @@ class modEmailCollector extends DolibarrModules $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)'."\n".'socid=SETIFEMPTY:1'."\n".'usage_opportunity=SET:1'."\n".'description=EXTRACT:BODY:(.*)'."\n".'title=SET:Lead or message from __tmp_from__ received by email'; $sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)"; - $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'project', 'tmp_from=EXTRACT:HEADER:^From:(.*);socid=SETIFEMPTY:1;usage_opportunity=SET:1;description=EXTRACT:BODY:(.*);title=SET:Lead or message from __tmp_from__ received by email', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'project', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sql[] = $sqlforexampleC1; @@ -327,8 +328,9 @@ class modEmailCollector extends DolibarrModules $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)"; $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'to', 'jobs@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)(<.*>)?'."\n".'fk_recruitmentjobposition=EXTRACT:HEADER:^To:[^\n]*\+([^\n]*)'."\n".'description=EXTRACT:BODY:(.*)'."\n".'lastname=SET:__tmp_from__'; $sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)"; - $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'candidature', 'tmp_from=EXTRACT:HEADER:^From:(.*)(<.*>)?;fk_recruitmentjobposition=EXTRACT:HEADER:^To:[^\n]*\+([^\n]*);description=EXTRACT:BODY:(.*);lastname=SET:__tmp_from__', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; + $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'candidature', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)"; $sql[] = $sqlforexampleC1; diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 4d4d482db50..ae1b98e63f7 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -402,7 +402,7 @@ class modEventOrganization extends DolibarrModules 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)) { + if (!$user->hasRight('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/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index c1d50648b24..81a8e6224cf 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -466,7 +466,7 @@ class modFournisseur extends DolibarrModules 'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'uv.login'=>'UserValidation', 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.total_tva'=>"LineTotalVAT", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode', - 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId', + 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'SupplierRef', 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel' ); if (isModEnabled("multicurrency")) { @@ -814,6 +814,7 @@ class modFournisseur extends DolibarrModules 'cd.fk_commande' => 'PurchaseOrder*', 'cd.fk_parent_line' => 'ParentLine', 'cd.fk_product' => 'IdProduct', + 'cd.ref' => 'SupplierRef', 'cd.description' => 'LineDescription', 'cd.tva_tx' => 'LineVATRate', 'cd.qty' => 'LineQty', diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index 499b6419982..c33c9a5daa6 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -265,7 +265,7 @@ class modRecruitment extends DolibarrModules 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); @@ -293,7 +293,7 @@ class modRecruitment extends DolibarrModules 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); @@ -321,7 +321,7 @@ class modRecruitment extends DolibarrModules 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000 + $r, 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->hasRight("recruitment", "recruitmentjobposition", "read")', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 2904f5afd66..938829fc577 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -318,9 +318,9 @@ class modSociete extends DolibarrModules 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", - 'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", + 'd.nom'=>'Text', 'r.nom'=>'Text', 'c.label'=>'List:c_country:label:label', 'c.code'=>'Text', 's.phone'=>"Text", 's.fax'=>"Text", - 's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Canvas", + 's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index f7c0919f930..eb543a10c91 100644 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -63,7 +63,7 @@ class modWorkstation extends DolibarrModules // Used only if file README.md and README-LL.md not found. $this->descriptionlong = "WorkstationsDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'dolibarr'; + $this->version = 'experimental'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index 2d7a7e8f9fc..abdb0cc24af 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -62,12 +62,6 @@ class pdf_standard extends ModelePDFMovement */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 2f0c11d0649..a87c920e40b 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -46,12 +46,6 @@ class doc_generic_mo_odt extends ModelePDFMo */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -273,8 +267,8 @@ class doc_generic_mo_odt extends ModelePDFMo //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index a36234b1026..e4d46662197 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -67,12 +67,6 @@ class pdf_vinci extends ModelePDFMo */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/oauth/generic_oauthcallback.php b/htdocs/core/modules/oauth/generic_oauthcallback.php index a394c7f4986..da8949ecbfb 100644 --- a/htdocs/core/modules/oauth/generic_oauthcallback.php +++ b/htdocs/core/modules/oauth/generic_oauthcallback.php @@ -127,6 +127,10 @@ if ($action == 'delete') { setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } + header('Location: '.$backtourl); exit(); } diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php index 7656a1cda37..d1c057d5c33 100644 --- a/htdocs/core/modules/oauth/github_oauthcallback.php +++ b/htdocs/core/modules/oauth/github_oauthcallback.php @@ -139,6 +139,10 @@ if (GETPOST('code')) { // We are coming from oauth provider page $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; unset($_SESSION["backtourlsavedbeforeoauthjump"]); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } + header('Location: '.$backtourl); exit(); } catch (Exception $e) { diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 67b027b0f1d..a043cf23e57 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -28,7 +28,7 @@ // Force keyforprovider $forlogin = 0; -if (preg_match('/^forlogin-/', $_GET['state'])) { +if (!empty($_GET['state']) && preg_match('/^forlogin-/', $_GET['state'])) { $forlogin = 1; $_GET['keyforprovider'] = 'Login'; } @@ -103,8 +103,14 @@ if ($state) { $statewithanticsrfonly = preg_replace('/^.*\-/', '', $state); } -if ($action != 'delete' && (empty($statewithscopeonly) || empty($requestedpermissionsarray))) { +// Add a test to check that the state parameter is provided into URL when we make the first call to ask the redirect or when we receive the callback +// but not when callback was ok and we recall the page +if ($action != 'delete' && !GETPOST('afteroauthloginreturn', 'int') && (empty($statewithscopeonly) || empty($requestedpermissionsarray))) { + dol_syslog("state or statewithscopeonly and/or requestedpermissionsarray are empty"); setEventMessages($langs->trans('ScopeUndefined'), null, 'errors'); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } header('Location: '.$backtourl); exit(); } @@ -147,12 +153,32 @@ if ($action == 'delete') { } if (!GETPOST('code')) { - // If we enter this page without 'code' parameter, we arrive here. This is the case when we want to get the redirect + dol_syslog("Page is called without code parameter defined"); + + // If we enter this page without 'code' parameter, it means we click on the link from login page and we want to get the redirect // to the OAuth provider login page. $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl; $_SESSION["oauthkeyforproviderbeforeoauthjump"] = $keyforprovider; $_SESSION['oauthstateanticsrf'] = $state; + // Save more data into session + // Not required. All data are savec into $_SESSION['datafromloginform'] when form is posted with a click on Login with + // Google with param actionlogin=login and beforeoauthloginredirect=1, by the functions_googleoauth.php. + /* + if (!empty($_POST["tz"])) { + $_SESSION["tz"] = $_POST["tz"]; + } + if (!empty($_POST["tz_string"])) { + $_SESSION["tz_string"] = $_POST["tz_string"]; + } + if (!empty($_POST["dst_first"])) { + $_SESSION["dst_first"] = $_POST["dst_first"]; + } + if (!empty($_POST["dst_second"])) { + $_SESSION["dst_second"] = $_POST["dst_second"]; + } + */ + if ($forlogin) { $apiService->setApprouvalPrompt('force'); } @@ -227,6 +253,7 @@ if (!GETPOST('code')) { $extraparams = $token->getExtraParams(); $jwt = explode('.', $extraparams['id_token']); + $username = ''; $useremail = ''; // Extract the middle part, base64 decode, then json_decode it @@ -272,6 +299,7 @@ if (!GETPOST('code')) { } // If you specified a hd parameter value in the request, verify that the ID token has a hd claim that matches an accepted G Suite hosted domain. + // $userinfo['hd'] is the domain name of Gmail account. // TODO } @@ -293,7 +321,7 @@ if (!GETPOST('code')) { $username = $tmpuser->login; $_SESSION['googleoauth_receivedlogin'] = dol_hash($conf->file->instance_unique_id.$username, '0'); - dol_syslog('$_SESSION[\'googleoauth_receivedlogin\']='.$_SESSION['googleoauth_receivedlogin']); + dol_syslog('We set $_SESSION[\'googleoauth_receivedlogin\']='.$_SESSION['googleoauth_receivedlogin']); } else { $errormessage = "Failed to login using Google. User with the Email '".$useremail."' was not found"; if ($entitytosearchuser > 0) { @@ -301,6 +329,8 @@ if (!GETPOST('code')) { } $_SESSION["dol_loginmesg"] = $errormessage; $errorincheck++; + + dol_syslog($errormessage); } } } else { @@ -321,12 +351,13 @@ if (!GETPOST('code')) { unset($_SESSION["backtourlsavedbeforeoauthjump"]); if (empty($backtourl)) { - $backtourl = DOL_URL_ROOT; + $backtourl = DOL_URL_ROOT.'/'; } - // If call back to url for a OAUTH2 login + // If call back to this url was for a OAUTH2 login if ($forlogin) { - $backtourl .= '?actionlogin=login&afteroauthloginreturn=1&username='.urlencode($username).'&token='.newToken(); + // _SESSION['googleoauth_receivedlogin'] has been set to the key to validate the next test by function_googleoauth(), so we can make the redirect + $backtourl .= '?actionlogin=login&afteroauthloginreturn=1'.($username ? '&username='.urlencode($username) : '').'&token='.newToken(); if (!empty($tmparray['entity'])) { $backtourl .= '&entity='.$tmparray['entity']; } diff --git a/htdocs/core/modules/oauth/microsoft_oauthcallback.php b/htdocs/core/modules/oauth/microsoft_oauthcallback.php index bf057676cf3..15ceccea0f3 100644 --- a/htdocs/core/modules/oauth/microsoft_oauthcallback.php +++ b/htdocs/core/modules/oauth/microsoft_oauthcallback.php @@ -134,6 +134,10 @@ if ($action == 'delete') { setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } + header('Location: '.$backtourl); exit(); } diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php index bc16b44461a..784ca628314 100644 --- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -117,6 +117,10 @@ if ($action == 'delete') { setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } + header('Location: '.$backtourl); exit(); } @@ -162,6 +166,10 @@ if (GETPOST('code')) { // We are coming from oauth provider page $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->$keyforparamid.'&scope=read_write'; } + if (empty($url)) { + $url = DOL_URL_ROOT.'/'; + } + // we go on oauth provider authorization page header('Location: '.$url); exit(); diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php index 12d133da14c..8f4a15d7e77 100644 --- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php @@ -141,6 +141,10 @@ if (GETPOST('code')) { // We are coming from oauth provider page $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; unset($_SESSION["backtourlsavedbeforeoauthjump"]); + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT.'/'; + } + header('Location: '.$backtourl); exit(); } catch (Exception $e) { @@ -162,6 +166,10 @@ if (GETPOST('code')) { // We are coming from oauth provider page $url = 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->$keyforparamid.'&scope=read_write'; } + if (empty($url)) { + $url = DOL_URL_ROOT.'/'; + } + // we go on oauth provider authorization page header('Location: '.$url); exit(); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index ba98d74fb3f..0b8d6676bbf 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -43,12 +43,6 @@ class doc_generic_product_odt extends ModelePDFProduct */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -282,8 +276,8 @@ class doc_generic_product_odt extends ModelePDFProduct // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index b244f01e0fa..afcb9503997 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -57,12 +57,6 @@ class pdf_standard extends ModelePDFProduct */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 853060f3b2c..4a94dc85521 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Gauthier VERDOL * @@ -83,12 +83,6 @@ class doc_generic_project_odt extends ModelePDFProjects */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -201,6 +195,8 @@ class doc_generic_project_odt extends ModelePDFProjects 'task_fk_parent'=>$task->fk_parent, 'task_duration'=>$task->duration, 'task_duration_hour'=>convertSecondToTime($task->duration, 'all'), + 'task_planned_workload'=>$task->planned_workload, + 'task_planned_workload_hour'=>convertSecondToTime($task->planned_workload, 'all'), 'task_progress'=>$task->progress, 'task_public'=>$task->public, 'task_date_start'=>dol_print_date($task->date_start, 'day'), @@ -563,8 +559,8 @@ class doc_generic_project_odt extends ModelePDFProjects //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 06f6e400b75..0a048837d7a 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -63,12 +63,6 @@ class pdf_baleine extends ModelePDFProjects */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 525c3bd2ece..b4ee7ec83b0 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -79,12 +79,6 @@ class pdf_beluga extends ModelePDFProjects */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 31a8127f733..c00ae37ab22 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -62,12 +62,6 @@ class pdf_timespent extends ModelePDFProjects */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 921b68f492b..ba1d04023f3 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -150,7 +150,8 @@ class mod_project_simple extends ModeleNumRefProjects $date = (empty($project->date_c) ? dol_now() : $project->date_c); //$yymm = strftime("%y%m",time()); - $yymm = strftime("%y%m", $date); + //$yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 96a5b75c626..fe87287cf54 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -82,12 +82,6 @@ class doc_generic_task_odt extends ModelePDFTask */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 8a35edc7968..161eead8533 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -44,12 +44,6 @@ class doc_generic_proposal_odt extends ModelePDFPropales */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -318,8 +312,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 093a8c5b6be..d282d29d262 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -73,12 +73,6 @@ class pdf_azur extends ModelePDFPropales */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -1597,7 +1591,8 @@ class pdf_azur extends ModelePDFPropales $displaydate = "day"; } - $posy += 4; + //$posy += 4; + $posy = $pdf->getY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DatePropal")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R'); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 24ccb210f12..fce233a5667 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -66,12 +66,6 @@ class pdf_cyan extends ModelePDFPropales */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -1662,7 +1656,8 @@ class pdf_cyan extends ModelePDFPropales $displaydate = "day"; } - $posy += 4; + //$posy += 4; + $posy = $pdf->getY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R'); diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 463a794faee..86d69220ca7 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -41,12 +41,6 @@ class doc_generic_reception_odt extends ModelePdfReception */ public $emetteur; // Objet societe qui emet - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -277,8 +271,8 @@ class doc_generic_reception_odt extends ModelePdfReception //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 286dcd59cb2..8c1f571aa0c 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -677,10 +677,10 @@ class pdf_squille extends ModelePdfReception if ($totalVolume != '') { $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } - if ($object->trueWeight) { + if (isset($object->trueWeight) && !empty($object->trueWeight)) { $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs, -1, 'no', 1); } - if ($object->trueVolume) { + if (isset($object->trueVolume) && !empty($object->trueVolume)) { $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs, -1, 'no', 1); } @@ -946,7 +946,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', '', $default_font_size - 2); $text = $linkedobject->ref; - if ($linkedobject->ref_client) { + if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) { $text .= ' ('.$linkedobject->ref_client.')'; } $Yoff = $Yoff + 8; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index e8d6c8317dc..985fe9dfd60 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -42,13 +42,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - - /** * Constructor * @@ -259,8 +252,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)) . '-' . $newfiletmp; $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax) } - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 4ce652dd55b..f7cdf97f2e5 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -43,18 +43,11 @@ class doc_generic_stock_odt extends ModelePDFStock */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ public $version = 'dolibarr'; - /** * Constructor * @@ -285,8 +278,8 @@ class doc_generic_stock_odt extends ModelePDFStock // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index a5c1d87691d..338d81edc44 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -58,12 +58,6 @@ class pdf_standard extends ModelePDFStock */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 449bd69f17d..e9bcdad28b3 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -59,12 +59,6 @@ class pdf_eagle extends ModelePdfStockTransfer */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.5 = array(5, 5) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 123048bbb2d..69c1ed27a51 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -68,12 +68,6 @@ class pdf_eagle_proforma extends ModelePDFCommandes */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.5 = array(5, 5) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 41ce5795ae6..2b36d7a7a40 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -47,12 +47,6 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices */ public $issuer; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -277,8 +271,8 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index e0a4e0694dd..982d7a4ba85 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -63,12 +63,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -370,6 +364,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Displays notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; + // Extrafields in note + if (!empty($conf->global->INVOICE_ADD_EXTRAFIELD_IN_NOTE)) { + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + } + if ($notetoshow) { $tab_top -= 2; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 3d8f62ce3ca..253faa62882 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -88,7 +88,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** - * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. + * Tests if the numbers already in the database do not cause conflicts that would prevent this numbering. * * @return boolean false if conflict, true if ok */ @@ -164,6 +164,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } + + return true; } /** @@ -172,7 +174,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices * @param Societe $objsoc Object third party * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string Value if OK, <=0 if KO */ public function getNextValue($objsoc, $object, $mode = 'next') { @@ -244,6 +246,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices return $prefix.$yymm."-".$num; } else { dol_print_error('', 'Bad parameter for getNextValue'); + return -1; } } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 0aacecc69da..1a86dfbe611 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -67,7 +67,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices */ public function info() { - global $conf, $langs, $db; + global $langs, $db; // Load translation files required by the page $langs->loadLangs(array("bills", "admin")); diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 8e40a21a1e4..ed5fd1fa126 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -47,12 +47,6 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders */ public $issuer; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * @var string Dolibarr version of the loaded document */ @@ -272,8 +266,8 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } @@ -331,7 +325,6 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // Call the ODTSubstitution hook $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - // Line of free text $newfreetext = ''; $paramfreetext = 'ORDER_FREE_TEXT'; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index c6e8434c955..cf94376b285 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -66,12 +66,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 31cee8d94ed..1206d91a794 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -66,12 +66,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index e8b66bb84cf..5f099a33d39 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -37,6 +37,23 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir */ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator { + public $posxpicture; + public $posxtva; + public $posxup; + public $posxqty; + public $posxunit; + public $posxdesc; + public $posxdiscount; + public $postotalht; + + public $tva; + public $tva_array; + public $localtax1; + public $localtax2; + + public $atleastoneratenotnull = 0; + public $atleastonediscount = 0; + /** * @var string Error code (or message) */ diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index bede0cc948e..ec3ec568a30 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -64,12 +64,6 @@ class pdf_standard extends ModelePDFSuppliersPayments */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 6a8ecbc28c6..acb0774e8a0 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -44,12 +44,6 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -306,8 +300,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 95b661364ad..046c72cd06b 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -63,12 +63,6 @@ class pdf_aurore extends ModelePDFSupplierProposal */ public $type; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index de316dbc4b1..0e42d2fda58 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -41,12 +41,6 @@ class doc_generic_ticket_odt extends ModelePDFTicket */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -272,8 +266,8 @@ class doc_generic_ticket_odt extends ModelePDFTicket // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 76d8e4f8d79..fdd3cbab86b 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -147,7 +147,7 @@ class mod_ticket_simple extends ModeleNumRefTicket $date = empty($ticket->datec) ? dol_now() : $ticket->datec; //$yymm = strftime("%y%m",time()); - $yymm = strftime("%y%m", $date); + $yymm = dol_print_date($date, "%y%m"); if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 81328821261..ca43431055c 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -41,12 +41,6 @@ class doc_generic_user_odt extends ModelePDFUser */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -306,8 +300,8 @@ class doc_generic_user_odt extends ModelePDFUser // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 5ff9d4c8526..6df859ed5b1 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -44,12 +44,6 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup */ public $emetteur; - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 7.0 = array(7, 0) - */ - public $phpmin = array(7, 0); - /** * Dolibarr version of the loaded document * @var string @@ -288,8 +282,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index b35e7748570..c73a2dcfb9f 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -51,7 +51,7 @@ if (empty($modulepart)) { $accessallowed = 0; if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') { $result = restrictedArea($user, 'produit|service', $id, 'product&product'); - if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) { + if ($modulepart == 'produit|service' && (!$user->hasRight('produit', 'lire') && !$user->hasRight('service', 'lire'))) { accessforbidden(); } $accessallowed = 1; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 7e33d5e8364..294aea5e8e7 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -172,16 +172,18 @@ $css = $extrafields->attributes[$elementtype]['css'][$attrname]; $cssview = $extrafields->attributes[$elementtype]['cssview'][$attrname]; $csslist = $extrafields->attributes[$elementtype]['csslist'][$attrname]; -if ((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { - $param_chain = ''; - foreach ($param['options'] as $key => $value) { - if (strlen($key)) { - $param_chain .= $key.','.$value."\n"; +if (is_array($param)) { + if (($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) { + $param_chain = ''; + foreach ($param['options'] as $key => $value) { + if (strlen($key)) { + $param_chain .= $key.','.$value."\n"; + } } + } elseif (($type == 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) { + $paramlist = array_keys($param['options']); + $param_chain = $paramlist[0]; } -} elseif (($type == 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate')) { - $paramlist = array_keys($param['options']); - $param_chain = $paramlist[0]; } ?> diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index 2e0b800e022..702c6641e76 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } @@ -254,7 +254,7 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) { print '
'.$langs->trans("CustomersCategoryShort"); if (!empty($array_query['cust_categ'])) { @@ -446,7 +446,7 @@ print '
'; print '
'."\n"; print '
'.$langs->trans("ContactCategoriesShort"); if (!empty($array_query['contact_categ'])) { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index ed6f9c0fbfb..0c812cc7609 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -269,7 +269,7 @@ if ($action == 'presend') { if (is_object($object) && is_object($object->thirdparty)) { $checkRead= 'global->MAILING_EMAIL_UNSUBSCRIBE_KEY)?urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY):""); + $checkRead.='&securitykey='.(!empty(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY'))?urlencode(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')):""); $checkRead.='" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = $checkRead; } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 25e0f914807..0b6c6fb9939 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -59,7 +59,7 @@ if ($module == 'propal') { } elseif ($module == 'project') { $permission = $user->rights->projet->creer; } elseif ($module == 'action') { - $permission = $user->rights->agenda->myactions->create; + $permission = $user->hasRight('agenda', 'myactions', 'create'); } elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } elseif ($module == 'reception') { @@ -151,7 +151,7 @@ if ($permission) { $nbofcontacts = $form->num; $newcardbutton = ''; - if (!empty($object->socid) && $object->socid > 1 && $user->rights->societe->creer) { + if (!empty($object->socid) && $object->socid > 1 && $user->hasRight('societe', 'creer')) { $newcardbutton .= ''; } print $newcardbutton; diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 01bad2e8f44..f02f736de2a 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -238,10 +238,9 @@ if ($action == 'convertimgwebp' && $permtoadd) { foreach ($filelist as $filename) { $filepath = $filename['fullname']; if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { - if (image_format_supported($filepath) == 1) { - $filepathnoext = preg_replace("/\.[a-z0-9]+$/i", "", $filepath); - - if (! dol_is_file($filepathnoext.'.webp')) { // If file does not exists yet + if (!empty($file) || !dol_is_file($filepathnoext.'.webp')) { // If file does not exists yet + if (image_format_supported($filepath) == 1) { + $filepathnoext = preg_replace("/\.[a-z0-9]+$/i", "", $filepath); $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp', 90); if (!dol_is_file($result)) { $error++; diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index d18349dd107..21f86a8f242 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,7 +13,7 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - switch ($totalarray['type'][$i]) { + switch ($totalarray['pos'][$i]) { case 'duration'; print ''; print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin') : 0); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 2b4eff09aa6..54557539b26 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -282,7 +282,7 @@ if ($massaction == 'presend') { $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; - $substitutionarray['__CHECK_READ__'] = ''; + $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__PERSONALIZED__'] = ''; // deprecated $substitutionarray['__CONTACTCIVNAME__'] = ''; @@ -326,6 +326,10 @@ if ($massaction == 'edit_extrafields') { if (!empty($extrafields_list)) { $myParamExtra = $object->showOptionals($extrafields, 'create'); + foreach ($extrafields_list as $extraKey => $extraLabel) { + $extrafields_list[$extraKey] = $langs->trans($extraLabel); + } + $formquestion[] = array( 'type' => 'other', 'value' => $form->selectarray('extrafield-key-to-update', $extrafields_list, GETPOST('extrafield-key-to-update'), 1) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 321a2a44672..aaf568fc724 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -423,7 +423,8 @@ if ($nolinesbefore) { $coldisplay++; ?> - "> + global->MAIN_OBJECTLINE_CREATE_EMPTY_QTY_BY_DEFAULT) ? 1 : ''); ?> + ">
'; - print ''; // Number -print ''; +print ''; // Amount print ''; // Note public -print ''; +print ''; // Bank account if (isModEnabled("banque")) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 78e19dbca1c..4cad20d119c 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -131,6 +131,8 @@ class EmailCollector extends CommonObject 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflowmax125'), 'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflowmax50', 'default'=>'993'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)', 'default'=>'UTF-8'), + 'imap_encryption' => array('type'=>'varchar(16)', 'label'=>'ImapEncryption', 'visible'=>-1, 'enabled'=>1, 'position'=>93, 'searchall'=>0, 'comment'=>"IMAP encryption", 'help'=>'ImapEncryptionHelp', 'arrayofkeyval'=> array('ssl'=>'SSL', 'tls' => 'TLS', 'notls' => 'NOTLS'), 'default'=>'ssl'), + 'norsh' => array('type'=>'integer', 'label'=>'NoRSH', 'visible'=>-1, 'enabled'=>"!getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>94, 'searchall'=>0, 'help'=>'NoRSHHelp', 'arrayofkeyval'=> array(0 =>'No', 1 => 'Yes'), 'default'=> 0), 'acces_type' => array('type'=>'integer', 'label'=>'accessType', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login type", 'arrayofkeyval'=>array('0'=>'loginPassword', '1'=>'oauthToken'), 'default'=>'0', 'help'=>''), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>"1", 'position'=>103, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'), @@ -213,6 +215,8 @@ class EmailCollector extends CommonObject public $password; public $acces_type; public $oauth_service; + public $imap_encryption; + public $norsh; public $source_directory; public $target_directory; public $maxemailpercollect; @@ -775,11 +779,9 @@ class EmailCollector extends CommonObject /** * Return the connectstring to use with IMAP connection function * - * @param int $ssl Add /ssl tag - * @param int $norsh Add /norsh to connectstring * @return string */ - public function getConnectStringIMAP($ssl = 1, $norsh = 0) + public function getConnectStringIMAP() { global $conf; @@ -787,15 +789,16 @@ class EmailCollector extends CommonObject $flags = '/service=imap'; // IMAP if (!empty($conf->global->IMAP_FORCE_TLS)) { $flags .= '/tls'; - } elseif (empty($conf->global->IMAP_FORCE_NOSSL)) { - if ($ssl) { - $flags .= '/ssl'; - } + } elseif (empty($this->imap_encryption) || ($this->imap_encryption == 'ssl' && !empty($conf->global->IMAP_FORCE_NOSSL))) { + $flags .= ''; + } else { + $flags .= '/' . $this->imap_encryption; } + $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; - if ($norsh || !empty($conf->global->IMAP_FORCE_NORSH)) { + if (!empty($this->norsh) || !empty($conf->global->IMAP_FORCE_NORSH)) { $flags .= '/norsh'; } //Used in shared mailbox from Office365 @@ -1191,7 +1194,7 @@ class EmailCollector extends CommonObject $client = $cm->make([ 'host' => $this->host, 'port' => $this->port, - 'encryption' => 'ssl', + 'encryption' => !empty($this->imap_encryption) ? $this->imap_encryption : false, 'validate_cert' => true, 'protocol' => 'imap', 'username' => $this->login, @@ -1204,7 +1207,7 @@ class EmailCollector extends CommonObject $client = $cm->make([ 'host' => $this->host, 'port' => $this->port, - 'encryption' => 'ssl', + 'encryption' => !empty($this->imap_encryption) ? $this->imap_encryption : false, 'validate_cert' => true, 'protocol' => 'imap', 'username' => $this->login, diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 5544f790585..49940ef7881 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -828,7 +828,6 @@ print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - //print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } foreach ($object->fields as $key => $val) { diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 0a67866ce62..9636e7e8d0f 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -293,7 +293,7 @@ if ($object->ismultientitymanaged == 1) { $sql .= " WHERE 1 = 1"; } if (!empty($projectstatic->id)) { - $sql .= " AND t.fk_project=".((int) $projectstatic->id); + $sql .= " AND t.fk_project = ".((int) $projectstatic->id); } foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { @@ -375,7 +375,7 @@ $num = $db->num_rows($resql); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$id); + header("Location: ".DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?id='.((int) $id)); exit; } @@ -600,7 +600,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) { //print ''; print ''; - // Note on several rows - //print ''; print ''; // Delivery delay diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 9fe196ad9f2..1a3955f11d6 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -58,8 +58,8 @@ class ExpenseReports extends DolibarrApi * * Return an array with Expense Report informations * - * @param int $id ID of Expense Report - * @return array|mixed Data without useless information + * @param int $id ID of Expense Report + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index bb188c3fafc..da22037e771 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -176,7 +176,7 @@ $arrayfields = array( // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; -$canedituser = (!empty($user->admin) || $user->rights->user->user->creer); +$canedituser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer')); $objectuser = new User($db); diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index bdc7b51312a..8c5f603d03f 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -105,19 +105,19 @@ print '
'; print '
'; + print ''; print '"; // Note Private print ''; print '"; */ diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 426e2a8ced9..7c78275e913 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -56,8 +56,8 @@ class Donations extends DolibarrApi * * Return an array with donation informations * - * @param int $id ID of order - * @return array|mixed data without useless information + * @param int $id ID of order + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index f2417aa4859..c730c7d0b08 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -478,7 +478,7 @@ class Don extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs, $conf; + global $langs; $error = 0; @@ -566,7 +566,6 @@ class Don extends CommonObject */ public function delete($user, $notrigger = 0) { - global $user, $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -629,8 +628,6 @@ class Don extends CommonObject */ public function fetch($id, $ref = '') { - global $conf; - $sql = "SELECT d.rowid, d.datec, d.date_valid, d.tms as datem, d.datedon,"; $sql .= " d.fk_soc as socid,d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, "; $sql .= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, d.email, d.phone, "; @@ -728,7 +725,7 @@ class Don extends CommonObject public function valid_promesse($id, $userid, $notrigger = 0) { // phpcs:enable - global $langs, $user; + global $user; $error = 0; @@ -763,23 +760,6 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Classify the donation as paid, the donation was received - * - * @deprecated - * @see setPaid() - * @param int $id id of donation - * @param int $modepayment mode of payment - * @return int <0 if KO, >0 if OK - */ - public function set_paid($id, $modepayment = 0) - { - // phpcs:enable - dol_syslog(get_class($this)."::set_paid is deprecated, use setPaid instead", LOG_NOTICE); - return $this->setPaid($id, $modepayment); - } - /** * Classify the donation as paid, the donation was received * @@ -897,8 +877,6 @@ class Don extends CommonObject public function load_state_board() { // phpcs:enable - global $conf; - $this->nb = array(); $sql = "SELECT count(d.rowid) as nb"; @@ -1042,7 +1020,7 @@ class Don extends CommonObject } } - $modelpath = "core/modules/dons/"; + //$modelpath = "core/modules/dons/"; // TODO Restore use of commonGenerateDocument instead of dedicated code here //return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index df950a5e349..7aa4918fc92 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -35,6 +35,8 @@ if (isModEnabled('project')) { // Load translation files required by the page $langs->loadLangs(array('companies', 'donations')); +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist'; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -65,9 +67,6 @@ $search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $moreforfilter = GETPOST('moreforfilter', 'alpha'); -if (!$user->rights->don->lire) { - accessforbidden(); -} if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers $search_all = ""; @@ -80,7 +79,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('orderlist')); +$hookmanager->initHooks(array('donationlist')); // List of fields to search into when doing a "search in all" @@ -94,6 +93,22 @@ $fieldstosearchall = array( // Security check $result = restrictedArea($user, 'don'); +$permissiontoread = $user->hasRight('don', 'read'); +$permissiontoadd = $user->hasRight('don', 'write'); +$permissiontodelete = $user->hasRight('don', 'delete'); + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} @@ -101,20 +116,24 @@ $result = restrictedArea($user, 'don'); * View */ -$donationstatic = new Don($db); $form = new Form($db); +$donationstatic = new Don($db); if (isModEnabled('project')) { $projectstatic = new Project($db); } +$title = $langs->trans("Donations"); $help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; -llxHeader('', $langs->trans("Donations"), $help_url); -// Genere requete de liste des dons +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,"; $sql .= " d.amount, d.fk_statut as status,"; $sql .= " p.rowid as pid, p.ref, p.title, p.public"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; $sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; if ($search_status != '' && $search_status != '-4') { @@ -136,240 +155,342 @@ if ($search_amount) { $sql .= natural_search('d.amount', $search_amount, 1); } -$sql .= $db->order($sortfield, $sortorder); - +// Count total nb of records $nbtotalofrecords = ''; if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; +if (!$resql) { + dol_print_error($db); + exit; +} - $param = ''; - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($search_status && $search_status != -1) { - $param .= '&search_status='.urlencode($search_status); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_name) { - $param .= '&search_name='.urlencode($search_name); - } - if ($search_amount) { - $param .= '&search_amount='.urlencode($search_amount); - } +$num = $db->num_rows($resql); - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - if ($user->rights->don->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); - } - - print ''."\n"; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +// Direct jump if only one record found +if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); + exit; +} +// Output page +// -------------------------------------------------------------------- - print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll - if ($search_all) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +// Example : Adding jquery code +// print ''; + +$arrayofselected = is_array($toselect) ? $toselect : array(); + +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($search_status && $search_status != -1) { + $param .= '&search_status='.urlencode($search_status); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_company) { + $param .= '&search_company='.urlencode($search_company); +} +if ($search_name) { + $param .= '&search_name='.urlencode($search_name); +} +if ($search_amount) { + $param .= '&search_amount='.urlencode($search_amount); +} + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); +if (!empty($permissiontodelete)) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +if ($user->rights->don->creer) { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); +} + +print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); + +if ($search_all) { + $setupstring = ''; + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} - print '
'; - print '
'; print $langs->trans('IncotermLabel'); print ''; if ($user->rights->expedition->delivery->creer) { @@ -465,13 +465,13 @@ if ($action == 'create') { // Note Public print '
'.$langs->trans("NotePublic").''; - print nl2br($object->note_public); + print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_public)); print "
'.$langs->trans("NotePrivate").''; - print nl2br($object->note_private); + print dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)); print "
'."\n"; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - // Filters lines - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - print '
'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - print ''; +print '
'; +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - print ''; - } else { - print ''; - } +} +print ''; +if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { print ''; - print ''; +} +print ''; +print ''; +if (isModEnabled('project')) { + print ''; - if (isModEnabled('project')) { - print ''; - } - print ''; - print ''; +print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - print "\n"; +} +print ''."\n"; - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); - } - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder); - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "d.fk_soc", "", $param, "", $sortfield, $sortorder); +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre(''); + $totalarray['nbfield']++; +} +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", $param, "", $sortfield, $sortorder); +$totalarray['nbfield']++; +if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "d.fk_soc", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} else { + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder); +$totalarray['nbfield']++; +print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center '); +$totalarray['nbfield']++; +if (isModEnabled('project')) { + $langs->load("projects"); + print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} +print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right '); +$totalarray['nbfield']++; +print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +$totalarray['nbfield']++; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre(''); + $totalarray['nbfield']++; +} +print ''."\n"; + +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray = array(); +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + + $donationstatic->setVarsFromFetchObj($obj); + + $company = new Societe($db); + $result = $company->fetch($obj->socid); + + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } } else { - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "d.societe", "", $param, "", $sortfield, $sortorder); - } - print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center '); - if (isModEnabled('project')) { - $langs->load("projects"); - print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); - } - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre(''); - } - print "\n"; - - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { - $objp = $db->fetch_object($resql); - $donationstatic->setVarsFromFetchObj($objp); - $company = new Societe($db); - $result = $company->fetch($objp->socid); - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + $donationstatic->id = $obj->rowid; + $donationstatic->ref = $obj->rowid; + $donationstatic->lastname = $obj->lastname; + $donationstatic->firstname = $obj->firstname; + print ""; + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($obj->socid) && $company->id > 0) { + print ""; } else { - $donationstatic->societe = $objp->societe; - } - - print $donationstatic->getKanbanView('', array('selected' => in_array($donationstatic->id, $arrayofselected))); - if ($i == ($imaxinloop - 1)) { - print ''; - print ''; + print ""; } } else { - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - $donationstatic->id = $objp->rowid; - $donationstatic->ref = $objp->rowid; - $donationstatic->lastname = $objp->lastname; - $donationstatic->firstname = $objp->firstname; - print ""; - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - if (!empty($objp->socid) && $company->id > 0) { - print ""; - } else { - print ""; - } - } else { - print ""; - } - print ""; - print ''; - if (isModEnabled('project')) { - print "\n"; - } - print ''; - print ''; - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - print ""; + print ""; } - $i++; + print ""; + print ''; + if (isModEnabled('project')) { + print "\n"; + } + print ''; + print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ""; } - print "
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; print ''; - print ''; - print ''; - print ''; - print ''; +print ''; +print ''; - print ''; + print ''; print ''; +} else { + print ''; + print ''; + print ''; +print ''; +print ''; +print ' '; +print ''; print ' '; print ''; - print ' '; - print ''; - $liststatus = array( - Don::STATUS_DRAFT=>$langs->trans("DonationStatusPromiseNotValidated"), - Don::STATUS_VALIDATED=>$langs->trans("DonationStatusPromiseValidated"), - Don::STATUS_PAID=>$langs->trans("DonationStatusPaid"), - Don::STATUS_CANCELED=>$langs->trans("Canceled") - ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); +} +print ''; +$liststatus = array( + Don::STATUS_DRAFT=>$langs->trans("DonationStatusPromiseNotValidated"), + Don::STATUS_VALIDATED=>$langs->trans("DonationStatusPromiseValidated"), + Don::STATUS_PAID=>$langs->trans("DonationStatusPaid"), + Don::STATUS_CANCELED=>$langs->trans("Canceled") +); +print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); +print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + print '
'; + } + // Output Kanban + $donationstatic->amount = $obj->amount; + $donationstatic->date = $obj->datedon; + $donationstatic->labelStatus = $obj->status; + $donationstatic->id = $obj->rowid; + $donationstatic->ref = $obj->rowid; + + if (!empty($obj->socid) && $company->id > 0) { + $donationstatic->societe = $company->getNomUrl(1); + } else { + $donationstatic->societe = $obj->societe; + } + + $object = $donationstatic; + + $selected = -1; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + } + print $donationstatic->getKanbanView('', array('selected' => $selected)); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; - print '
'; - } - // Output Kanban - $donationstatic->amount = $objp->amount; - $donationstatic->date = $objp->datedon; - $donationstatic->labelStatus = $objp->status; - $donationstatic->id = $objp->rowid; - $donationstatic->ref = $objp->rowid; - - if (!empty($objp->socid) && $company->id > 0) { - $donationstatic->societe = $company->getNomUrl(1); + print '
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."
".$obj->societe."
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."".$objp->societe."".$objp->societe."".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon), 'day').'"; - if ($objp->pid) { - $projectstatic->id = $objp->pid; - $projectstatic->ref = $objp->ref; - $projectstatic->id = $objp->pid; - $projectstatic->public = $objp->public; - $projectstatic->title = $objp->title; - print $projectstatic->getNomUrl(1); - } else { - print ' '; - } - print "'.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
".$obj->societe."".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($obj->datedon), 'day').'"; + if ($obj->pid) { + $projectstatic->id = $obj->pid; + $projectstatic->ref = $obj->ref; + $projectstatic->id = $obj->pid; + $projectstatic->public = $obj->public; + $projectstatic->title = $obj->title; + print $projectstatic->getNomUrl(1); + } else { + print ' '; + } + print "'.price($obj->amount).''.$donationstatic->LibStatut($obj->status, 5).'
"; - print '
'; - print "\n"; - $db->free($resql); -} else { - dol_print_error($db); + $i++; } +print "
"; +print ''; +print "\n"; +$db->free($resql); + llxFooter(); $db->close(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 416e848d271..8a63efbc69d 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -116,13 +116,13 @@ print '
'.$langs->trans('Date').''.dol_print_ print '
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_payment.'
'.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note_public).'
'.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_public)).'
'; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$projectstatic->id; - $encodedsecurekey = dol_hash(getDolUserString("EVENTORGANIZATION_SECUREKEYEVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5'); + $encodedsecurekey = dol_hash(getDolGlobalString("EVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); //print ''; $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.$projectstatic->id.'&type=global'; - $encodedsecurekey = dol_hash(getDolUserString("EVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5'); + $encodedsecurekey = dol_hash(getDolGlobalString("EVENTORGANIZATION_SECUREKEY").'conferenceorbooth'.$projectstatic->id, 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print ''; } // If the user can view prospects other than his' -if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); @@ -644,7 +644,7 @@ if (isModEnabled('categorie') && $user->rights->categorie->lire && ($user->right $moreforfilter .= '
'; } -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 0470da549e5..740cd7c380f 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -378,10 +378,6 @@ if ($id > 0 || !empty($ref)) { } } print '
'.$langs->trans('NotePublic').' :
'; - //print nl2br($object->note_public); - //print '
'."\n"; // Date payment -print ''; +print ''; // Mode -print ''; +print ''; // Number -print ''; +print ''; // Amount -print ''; +print ''; // Note public -print ''; +print ''; $disable_delete = 0; // Bank account diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 6563e9d6338..ce232ee8c3b 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -198,7 +198,7 @@ class Export $this->array_export_TypeFields[$i] = (isset($module->export_TypeFields_array[$r]) ? $module->export_TypeFields_array[$r] : ''); // Table of entities for export / Tableau des entites a exporter (cle=champ, valeur=entite) $this->array_export_entities[$i] = $module->export_entities_array[$r]; - // Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records) + // Table of entities requiring DISTINCT abandonment / Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records) $this->array_export_dependencies[$i] = (!empty($module->export_dependencies_array[$r]) ? $module->export_dependencies_array[$r] : ''); // Table of special field operations / Tableau des operations speciales sur champ $this->array_export_special[$i] = (!empty($module->export_special_array[$r]) ? $module->export_special_array[$r] : ''); @@ -207,7 +207,7 @@ class Export // Array of help tooltips $this->array_export_help[$i] = (!empty($module->export_help_array[$r]) ? $module->export_help_array[$r] : ''); - // Requete sql du dataset + // SQL dataset query / Requete SQL du dataset $this->array_export_sql_start[$i] = $module->export_sql_start[$r]; $this->array_export_sql_end[$i] = $module->export_sql_end[$r]; $this->array_export_sql_order[$i] = (!empty($module->export_sql_order[$r]) ? $module->export_sql_order[$r] : null); @@ -285,7 +285,7 @@ class Export $sql .= $sqlWhere; } - // Add the order + // Add the sort order $sql .= $this->array_export_sql_order[$indice]; // Add the HAVING part. @@ -632,7 +632,7 @@ class Export $sql = $this->build_sql($indice, $array_selected, $array_filterValue); } - // Run the sql + // Run the SQL $this->sqlusedforexport = $sql; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -656,10 +656,10 @@ class Export $result = $objmodel->open_file($dirname."/".$filename, $outputlangs); if ($result >= 0) { - // Genere en-tete + // Generate header $objmodel->write_header($outputlangs); - // Genere ligne de titre + // Generate title line $objmodel->write_title($this->array_export_fields[$indice], $array_selected, $outputlangs, isset($this->array_export_TypeFields[$indice]) ? $this->array_export_TypeFields[$indice] : null); while ($obj = $this->db->fetch_object($resql)) { @@ -723,7 +723,7 @@ class Export $objmodel->write_record($array_selected, $obj, $outputlangs, isset($this->array_export_TypeFields[$indice]) ? $this->array_export_TypeFields[$indice] : null); } - // Genere en-tete + // Generate Footer $objmodel->write_footer($outputlangs); // Close file @@ -857,7 +857,7 @@ class Export // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output list all export models - * TODO Move this into a class htmlxxx.class.php + * --TODO Move this into a class htmlxxx.class.php-- * * @return void */ @@ -882,7 +882,7 @@ class Export print ''; print ''; } - // suppression de l'export + // remove export / suppression de l'export print '"; print ''; diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index a6ce28fdc44..b3e3ff44ff5 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -55,8 +55,8 @@ class Mos extends DolibarrApi * * Return an array with MO informations * - * @param int $id ID of MO - * @return array|mixed data without useless information + * @param int $id ID of MO + * @return Object Object with cleaned properties * * @url GET {id} * @throws RestException diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 1ec339ee333..3e31bf3f6fa 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -203,7 +203,7 @@ if ($object->id > 0) { $objcon = new stdClass(); $out = '&origin='.$object->element.'&originid='.$object->id; - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -228,7 +228,7 @@ if ($object->id > 0) { print ''; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/multicurrency/class/api_multicurrencies.class.php b/htdocs/multicurrency/class/api_multicurrencies.class.php index eb77b9c6d6d..99fc1c2bb95 100644 --- a/htdocs/multicurrency/class/api_multicurrencies.class.php +++ b/htdocs/multicurrency/class/api_multicurrencies.class.php @@ -109,7 +109,7 @@ class MultiCurrencies extends DolibarrApi * Return an array with Currency informations * * @param int $id ID of Currency - * @return array|mixed Data without useless information + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index f1f8fe95210..3f28d9cf1b8 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -488,6 +488,8 @@ class MultiCurrency extends CommonObject $this->rate = new CurrencyRate($this->db); return $this->rate->fetch($obj->rowid); } + + return -1; } /** @@ -559,15 +561,20 @@ class MultiCurrency extends CommonObject /** * Get the conversion of amount with invoice rate * - * @param int $fk_facture id of facture + * @param int $fk_facture Id of invoice * @param double $amount amount to convert * @param string $way 'dolibarr' mean the amount is in dolibarr currency - * @param string $table facture or facture_fourn + * @param string $table 'facture' or 'facture_fourn' + * @param float|null $invoice_rate Invoice rate if known (to avoid to make the getInvoiceRate call) * @return double|boolean amount converted or false if conversion fails */ - public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture') + public static function getAmountConversionFromInvoiceRate($fk_facture, $amount, $way = 'dolibarr', $table = 'facture', $invoice_rate = null) { - $multicurrency_tx = self::getInvoiceRate($fk_facture, $table); + if (!is_null($invoice_rate)) { + $multicurrency_tx = $invoice_rate; + } else { + $multicurrency_tx = self::getInvoiceRate($fk_facture, $table); + } if ($multicurrency_tx) { if ($way == 'dolibarr') { @@ -677,6 +684,8 @@ class MultiCurrency extends CommonObject return -1; } + } else { + return -1; } } diff --git a/htdocs/partnership/class/api_partnership.class.php b/htdocs/partnership/class/api_partnership.class.php index 288b4966ebe..47e801cf662 100644 --- a/htdocs/partnership/class/api_partnership.class.php +++ b/htdocs/partnership/class/api_partnership.class.php @@ -59,8 +59,8 @@ class PartnershipApi extends DolibarrApi * * Return an array with partnership informations * - * @param int $id ID of partnership - * @return array|mixed data without useless information + * @param int $id ID of partnership + * @return Object Object with cleaned properties * * @url GET partnerships/{id} * diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php index ba0f2c2a1ab..58e2fac591d 100644 --- a/htdocs/partnership/class/partnership_type.class.php +++ b/htdocs/partnership/class/partnership_type.class.php @@ -95,7 +95,7 @@ class PartnershipType extends CommonObject } // Example to show how to set values of fields definition dynamically - /*if ($user->rights->mymodule->myobject->read) { + /*if ($user->hasRight('mymodule', 'myobject', 'read')) { $this->fields['myfield']['visible'] = 1; $this->fields['myfield']['noteditable'] = 0; }*/ diff --git a/htdocs/partnership/partnership_agenda.php b/htdocs/partnership/partnership_agenda.php index f4b8275a8f6..3a2af03c5e1 100644 --- a/htdocs/partnership/partnership_agenda.php +++ b/htdocs/partnership/partnership_agenda.php @@ -158,7 +158,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($permissiontoadd) { @@ -212,7 +212,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -237,7 +237,7 @@ if ($object->id > 0) { print ''; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/partnership/partnership_contact.php b/htdocs/partnership/partnership_contact.php index 270645c0d52..415b24c3fdf 100644 --- a/htdocs/partnership/partnership_contact.php +++ b/htdocs/partnership/partnership_contact.php @@ -141,7 +141,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/partnership/partnership_document.php b/htdocs/partnership/partnership_document.php index 8651590e37a..481bf2793de 100644 --- a/htdocs/partnership/partnership_document.php +++ b/htdocs/partnership/partnership_document.php @@ -136,7 +136,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/partnership/partnership_note.php b/htdocs/partnership/partnership_note.php index b0e16f7f3a5..e75e28e273e 100644 --- a/htdocs/partnership/partnership_note.php +++ b/htdocs/partnership/partnership_note.php @@ -76,7 +76,8 @@ if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') ac * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } @@ -114,7 +115,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 671b74a2714..e77aacc195d 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -199,11 +199,11 @@ if ($id > 0 || $ref) { $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$_SERVER["PHP_SELF"].'?id='.$object->id; } - $linktocreatetimeBtnStatus = !empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create'); + $linktocreatetimeBtnStatus = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create'); $morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus); } - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { print '
'; $param = '&id='.$id; diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index d9a20ac7f3e..324cdc1324c 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -111,7 +111,7 @@ class ActionsCardProduct $this->tpl['status'] = $this->object->getLibStatut(2); // Note - $this->tpl['note'] = nl2br($this->object->note_private); + $this->tpl['note'] = $this->object->note_private; if ($action == 'create') { // Price @@ -168,7 +168,7 @@ class ActionsCardProduct $this->tpl['status_buy'] = $form->selectarray('statut_buy', $statutarray, $this->object->status_buy); $this->tpl['description'] = $this->object->description; - $this->tpl['note'] = $this->object->note; + $this->tpl['note'] = $this->object->note_private; // Finished $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index b8e6ad19ca6..7e44b0daf2f 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -49,12 +49,12 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - + - +photos) { ?> - + - + - + - + - + - + - +
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('PaymentMode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('PaymentMode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_payment.'
'.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note_public).'
'.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_public)).'
'; print img_object($this->array_export_module[$keyModel]->getName(), $this->array_export_icon[$keyModel]).' '; print $this->array_export_module[$keyModel]->getName().' - '; - // recuperation du nom de l'export + // recover export name / recuperation du nom de l'export $string = $langs->trans($this->array_export_label[$keyModel]); print ($string != $this->array_export_label[$keyModel] ? $string : $this->array_export_label[$keyModel]); @@ -894,7 +894,7 @@ class Export print ''.str_replace(',', ' , ', $filter['field']).''.str_replace(',', ' , ', $filter['value']).''; print 'rowid.'">'; print img_delete(); diff --git a/htdocs/externalsite/admin/index.php b/htdocs/externalsite/admin/index.php index deb05ade024..3f90c53721a 100644 --- a/htdocs/externalsite/admin/index.php +++ b/htdocs/externalsite/admin/index.php @@ -59,7 +59,7 @@ if ($action == 'update') { // exturl can be an url or a HTML string $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml'); - $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1); + $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1); $exturl = dol_string_onlythesehtmlattributes($exturl); $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity); @@ -112,7 +112,7 @@ print ''.$langs->trans("ExternalSiteURL")."'; $texte .= '
'; $texte .= ''; @@ -163,7 +163,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Scan directories $nbofiles = count($listoffiles); - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) { + if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'))) { $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; $texte .= count($listoffiles); @@ -283,8 +283,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) { + $format = getDolGlobalInt('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } @@ -317,7 +317,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $contactobject = null; if (!empty($usecontact)) { // We can use the company of contact instead of thirdparty company - if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) { + if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) { $object->contact->fetch_thirdparty(); $socobject = $object->contact->thirdparty; $contactobject = $object->contact; @@ -346,8 +346,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; $paramfreetext = 'MYMODULE_MYOBJECT_FREE_TEXT'; - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); + if (getDolGlobalString($paramfreetext)) { + $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); } // Open and load template @@ -473,7 +473,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + if (getDolGlobalInt('MAIN_ODT_AS_PDF')) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 6b66dea857e..d3c717bcd3c 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -172,32 +172,32 @@ class pdf_standard_myobject extends ModelePDFMyObject $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) { + if (getDolGlobalInt('MAIN_USE_FPDF')) { $outputlangs->charset_output = 'ISO-8859-1'; } // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); - $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies")); } $nblines = (is_array($object->lines) ? count($object->lines) : 0); $hidetop = 0; - if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { - $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) { + $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'); } // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); $this->atleastonephoto = false; /* - if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) + if (getDolGlobalInt('MAIN_GENERATE_MYOBJECT_WITH_PICTURE'))) { $objphoto = new Product($this->db); @@ -285,7 +285,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $heightforinfotot = 50; // Height reserved to output the info and total part and payment part $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + $heightforfooter = $this->marge_basse + (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -294,8 +294,8 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { - $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { + $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -316,7 +316,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT; // If user has no certificate, we try to take the company one if (!$cert) { - $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT; + $cert = getDolGlobalString('CERTIFICATE_CRT') ? '' : getDolGlobalString('CERTIFICATE_CRT'); } // If a certificate is found if ($cert) { @@ -344,10 +344,10 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 0); $tab_top = 90 + $top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); $tab_height = 130 - $top_shift; $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $tab_height_newpage -= $top_shift; } @@ -391,7 +391,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } // $this->_pagefoot($pdf,$object,$outputlangs,1); @@ -449,7 +449,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; @@ -471,7 +471,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -528,7 +528,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; @@ -569,7 +569,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } else { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; @@ -689,7 +689,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $nexY = max($nexY, $posYAfterImage); // Add line - if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + if (getDolGlobalInt('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); @@ -709,7 +709,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } if (!empty($tplidx)) { @@ -730,7 +730,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->useTemplate($tplidx); } $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -753,7 +753,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Display payment area /* - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalInt('INVOICE_NO_PAYMENT_DETAILS'))) { $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } @@ -842,7 +842,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); } @@ -850,8 +850,8 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -937,7 +937,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("PdfTitle"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('MAIN_ODT_AS_PDF') && is_object($outputlangsbis)) { $title .= ' - '; $title .= $outputlangsbis->transnoentities("PdfTitle"); } @@ -965,7 +965,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $posy += 3; @@ -975,7 +975,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $outputlangs->load("projects"); @@ -991,7 +991,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("Date"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (getDolGlobalInt('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("Date"); } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); @@ -1004,7 +1004,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + if (getDolGlobalInt('DOC_SHOW_FIRST_SALES_REP')) { $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $usertmp = new User($this->db); @@ -1031,15 +1031,15 @@ class pdf_standard_myobject extends ModelePDFMyObject $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->page_largeur - $this->marge_droite - 80; } - $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82; // Show sender frame @@ -1085,14 +1085,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100; if ($this->page_largeur < 210) { $widthrecbox = 84; // To work with US executive format } - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->marge_gauche; } @@ -1133,7 +1133,7 @@ class pdf_standard_myobject extends ModelePDFMyObject protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 0 : getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS'); return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1145,7 +1145,7 @@ class pdf_standard_myobject extends ModelePDFMyObject * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return null + * @return void */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { @@ -1203,7 +1203,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', @@ -1215,7 +1215,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { + if (getDolGlobalInt('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1231,7 +1231,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { + if (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) { $this->cols['vat']['status'] = true; } diff --git a/htdocs/modulebuilder/template/doc/Documentation.asciidoc b/htdocs/modulebuilder/template/doc/Documentation.asciidoc index a6dc59eea14..e649ad16fe2 100644 --- a/htdocs/modulebuilder/template/doc/Documentation.asciidoc +++ b/htdocs/modulebuilder/template/doc/Documentation.asciidoc @@ -37,7 +37,7 @@ This document was generated using Dolibarr ERP CRM process :toc: manual :toc-placement: preamble -<<< + == INTRODUCTION diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index d75f69a47f5..9f4bc9654fa 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -65,7 +65,7 @@ function myobjectPrepareHead($object) $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.$nbNote.'' : ''); } $head[$h][2] = 'note'; $h++; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 2f503de107f..b93c503fda4 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -187,7 +187,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + //if (!empty(getDolGlobalString('MAIN_HTML_TITLE')) && preg_match('/thirdpartynameonly/',getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) $title=$object->name." - ".$title; $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); @@ -265,7 +265,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} -$parameters = array('fieldstosearchall'=>$fieldstosearchall); -$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook > 0) { - $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']; -} elseif ($reshook == 0) { - $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']); -} +// $fieldstosearchall = array(); +// foreach ($object->fields as $key => $val) { +// if (!empty($val['searchall'])) { +// $fieldstosearchall['t.'.$key] = $val['label']; +// } +// } +// $parameters = array('fieldstosearchall'=>$fieldstosearchall); +// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +// if ($reshook > 0) { +// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']; +// } elseif ($reshook == 0) { +// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']); +// } // Definition of array of fields for columns $arrayfields = array(); @@ -411,7 +411,7 @@ $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { +if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); @@ -702,13 +702,14 @@ while ($i < $imaxinloop) { print '
'; } // Output Kanban + $selected = -1; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($object->id, $arrayofselected)) { $selected = 1; } } - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); + print $object->getKanbanView('', array('selected' => $selected)); if ($i == ($imaxinloop - 1)) { print '
'; print '
trans("Ref"); ?>ref; ?>ref); ?>
trans("Label") ?>label; ?>label); ?> @@ -66,37 +66,37 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
trans("Description"); ?>description; ?>description); ?>
trans("Nature"); ?>finished; ?>finished); ?>
trans("Weight"); ?>weight; ?>weight); ?>
trans("Length"); ?>length; ?>length); ?>
trans("Surface"); ?>surface; ?>surface); ?>
trans("Volume"); ?>volume; ?>volume); ?>
trans("Note"); ?>note; ?>note)); ?>
diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index e639568459e..d5ff0945a59 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -151,7 +151,7 @@ class ActionsCardService $this->tpl['label'] = $this->object->label; $this->tpl['id'] = $this->object->id; $this->tpl['type'] = $this->object->type; - $this->tpl['note'] = $this->object->note; + $this->tpl['note'] = $this->object->note_private; $this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte; // Duration diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index c816a36ae34..3236e7e7074 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -76,7 +76,7 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
trans("Note"); ?>note; ?>note)); ?>
diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 99071758252..ce79d07155d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -242,7 +242,7 @@ if (empty($reshook)) { $action = ''; } // merge products - if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) { + if ($action == 'confirm_merge' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) { $error = 0; $productOriginId = GETPOST('product_origin', 'int'); $productOrigin = new Product($db); @@ -358,12 +358,10 @@ if (empty($reshook)) { // External modules should update their ones too if (!$error) { + $parameters = array('soc_origin' => $productOrigin->id, 'soc_dest' => $object->id); $reshook = $hookmanager->executeHooks( 'replaceProduct', - array( - 'soc_origin' => $productOrigin->id, - 'soc_dest' => $object->id, - ), + $parameters, $object, $action ); @@ -878,92 +876,88 @@ if (empty($reshook)) { if (!GETPOST('clone_content') && !GETPOST('clone_prices')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $db->begin(); - - $originalId = $id; if ($object->id > 0) { - $object->ref = GETPOST('clone_ref', 'alphanohtml'); - $object->status = 0; - $object->status_buy = 0; - $object->id = null; - $object->barcode = -1; + $error = 0; + $clone = dol_clone($object, 2); - if ($object->check()) { - $object->context['createfromclone'] = 'createfromclone'; - $id = $object->create($user); + $clone->id = null; + $clone->ref = GETPOST('clone_ref', 'alphanohtml'); + $clone->status = 0; + $clone->status_buy = 0; + $clone->barcode = -1; + + if ($clone->check()) { + $db->begin(); + + $clone->context['createfromclone'] = 'createfromclone'; + $id = $clone->create($user); if ($id > 0) { if (GETPOST('clone_composition')) { - $result = $object->clone_associations($originalId, $id); - + $result = $clone->clone_associations($object->id, $id); if ($result < 1) { - $db->rollback(); setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); - exit; + setEventMessages($clone->error, $clone->errors, 'errors'); + $error++; } } - if (GETPOST('clone_categories')) { - $result = $object->cloneCategories($originalId, $id); - + if (!$error && GETPOST('clone_categories')) { + $result = $clone->cloneCategories($object->id, $id); if ($result < 1) { - $db->rollback(); setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); - exit; + setEventMessages($clone->error, $clone->errors, 'errors'); + $error++; } } - if (GETPOST('clone_prices')) { - $result = $object->clone_price($originalId, $id); - + if (!$error && GETPOST('clone_prices')) { + $result = $clone->clone_price($object->id, $id); if ($result < 1) { - $db->rollback(); setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$originalId); - exit(); + setEventMessages($clone->error, $clone->errors, 'errors'); + $error++; } } - // $object->clone_fournisseurs($originalId, $id); - - $db->commit(); - $db->close(); - - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; + // $clone->clone_fournisseurs($object->id, $id); } else { - $id = $originalId; - - if ($object->error == 'ErrorProductAlreadyExists') { - $db->rollback(); - + if ($clone->error == 'ErrorProductAlreadyExists') { $refalreadyexists++; $action = ""; - $mesg = $langs->trans("ErrorProductAlreadyExists", $object->ref); - $mesg .= ' '.$langs->trans("ShowCardHere").'.'; + $mesg = $langs->trans("ErrorProductAlreadyExists", $clone->ref); + $mesg .= ' ' . $langs->trans("ShowCardHere") . '.'; setEventMessages($mesg, null, 'errors'); - $object->fetch($id); } else { - $db->rollback(); - if (count($object->errors)) { - setEventMessages($object->error, $object->errors, 'errors'); - dol_print_error($db, $object->errors); + if (count($clone->errors)) { + setEventMessages($clone->error, $clone->errors, 'errors'); + dol_print_error($db, $clone->errors); } else { - setEventMessages($langs->trans($object->error), null, 'errors'); - dol_print_error($db, $object->error); + setEventMessages($langs->trans($clone->error), null, 'errors'); + dol_print_error($db, $clone->error); } } + $error++; } - unset($object->context['createfromclone']); + unset($clone->context['createfromclone']); + + if ($error) { + $db->rollback(); + } else { + $db->commit(); + $db->close(); + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewRefForClone")), null, 'errors'); } } else { - $db->rollback(); dol_print_error($db, $object->error); } } + $action = 'clone'; } // Delete a product @@ -1469,7 +1463,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse', 'int'), 'fk_default_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'minwidth300 widthcentpercentminusxx maxwidth500'); - print ' '; + print ' '; print ''; print ''; print '
'.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1); - print ' '; + print ' '; + print ''; print '
'.$langs->trans("StockLimit").''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b703340be37..ec9d4d3f787 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3101,11 +3101,12 @@ class Product extends CommonObject if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) { // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice. $adeduire = 0; - $sql = "SELECT sum(fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; - $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid "; + $sql = "SELECT SUM(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd "; + $sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid"; $sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; - $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid "; + $sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid"; $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id); + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); if ($resql) { @@ -3122,11 +3123,12 @@ class Product extends CommonObject // For every order having invoice already validated we need to decrease stock cause it's in physical stock $adeduire = 0; - $sql = 'SELECT sum(fd.qty) as count FROM '.MAIN_DB_PREFIX.'facturedet as fd '; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture as f ON fd.fk_facture = f.rowid '; - $sql .= ' JOIN '.MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'commande as c ON el.fk_source = c.rowid '; - $sql .= ' WHERE c.fk_statut IN ('.$this->db->sanitize($filtrestatut).') AND f.fk_statut > '.Facture::STATUS_DRAFT.' AND fd.fk_product = '.((int) $this->id); + $sql = "SELECT sum(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd "; + $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON fd.fk_facture = f.rowid"; + $sql .= " JOIN ".MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; + $sql .= " JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid"; + $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND f.fk_statut > ".Facture::STATUS_DRAFT." AND fd.fk_product = ".((int) $this->id); + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); if ($resql) { @@ -3134,6 +3136,9 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); $adeduire += $obj->count; } + } else { + $this->error = $this->db->error(); + return -1; } $this->stats_commande['qty'] -= $adeduire; @@ -5457,6 +5462,8 @@ class Product extends CommonObject return -1; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 3f3d23b764c..bb1d64d3f9b 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -6,6 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2023 Benjamin Falière * * 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 @@ -75,8 +76,8 @@ if ($object->id > 0) { } else { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); $usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); @@ -89,7 +90,7 @@ if ($cancel) { } // Add subproduct to product -if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'add_prod' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $error = 0; $maxprod = GETPOST("max_prod", 'int'); @@ -160,12 +161,22 @@ if ($action == 'search') { if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= ', pl.label as labelm, pl.description as descriptionm'; } + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + if ($key != "") { // For natural search $params = array('p.ref', 'p.label', 'p.description', 'p.note'); @@ -214,7 +225,7 @@ if ($id > 0 || !empty($ref)) { /* * Product card */ - if ($user->rights->produit->lire || $user->rights->service->lire) { + if ($user->rights->produit->lire || $user->hasRight('service', 'lire')) { $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; @@ -449,7 +460,7 @@ if ($id > 0 || !empty($ref)) { } // Qty + IncDec - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } print '
'; - /*if($user->rights->produit->creer || $user->rights->service->creer) { + /*if($user->rights->produit->creer || $user->hasRight('service', 'creer')) { print ''; }*/ @@ -587,7 +598,7 @@ if ($id > 0 || !empty($ref)) { // Form with product to add - if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ((empty($action) || $action == 'view' || $action == 'edit' || $action == 'search' || $action == 're-edit') && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print '
'; $rowspan = 1; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5d62485f3bc..6ec32b5551a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -106,8 +106,8 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { @@ -139,6 +139,7 @@ if (empty($reshook)) { if ($action == 'setcost_price') { if ($id) { $result = $object->fetch($id); + $object->oldcopy = dol_clone($object); $object->cost_price = price2num($cost_price); $result = $object->update($object->id, $user); if ($result > 0) { diff --git a/htdocs/product/index.php b/htdocs/product/index.php index d31e365295f..528bb77660b 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -93,7 +93,7 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This may be useless due to the global search combo // Search contract - if ((isModEnabled("product") || isModEnabled("service")) && ($user->rights->produit->lire || $user->rights->service->lire)) { + if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { $listofsearchfields['search_product'] = array('text'=>'ProductOrService'); } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 874c1918de2..7db7f5af6a4 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -314,7 +314,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f6a852b0c63..8f595abcc53 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -493,7 +493,7 @@ $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $ // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project -if (!empty($conf->project->enabled)) +if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 3d07b00446e..09b01686b07 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -476,7 +476,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': '; $tmptitle = $langs->transnoentities('ProductsCategoriesShort'); $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); diff --git a/htdocs/product/note.php b/htdocs/product/note.php index a3f02813ee0..54c214224d5 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -70,7 +70,9 @@ $hookmanager->initHooks(array('productnote')); /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2c583fda1db..4f3bae2b3cb 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -120,7 +120,7 @@ if (empty($reshook)) { $action = ''; } - if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { + if (($action == 'update_vat') && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' // We must define tva_tx, npr and local taxes @@ -615,7 +615,7 @@ if (empty($reshook)) { * Price by customer * **************************************************** */ - if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'add_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $maxpricesupplier = $object->min_recommended_price(); $update_child_soc = GETPOST('updatechildprice', 'int'); @@ -734,7 +734,7 @@ if (empty($reshook)) { $action = ''; } - if ($action == 'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'update_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $maxpricesupplier = $object->min_recommended_price(); $update_child_soc = GETPOST('updatechildprice', 'int'); @@ -1108,7 +1108,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '
 
'.price($prices['unitprice']).''.price($prices['remise_percent']).' %'; - if (($user->rights->produit->creer || $user->rights->service->creer)) { + if (($user->rights->produit->creer || $user->hasRight('service', 'creer'))) { print ''; print img_edit().''; print ''; @@ -1140,7 +1140,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print '
'.price($prices['unitprice']).''.price($prices['remise_percent']).' %'; - if (($user->rights->produit->creer || $user->rights->service->creer)) { + if (($user->rights->produit->creer || $user->hasRight('service', 'creer'))) { print ''; print img_edit().''; print ''; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index ab7020a5df8..a91927e77d4 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -464,10 +464,10 @@ if ($result || !($id > 0)) { if ($graphfiles == 'propal' && empty($user->rights->propal->lire)) { continue; } - if ($graphfiles == 'order' && empty($user->rights->commande->lire)) { + if ($graphfiles == 'order' && !$user->hasRight('commande', 'lire')) { continue; } - if ($graphfiles == 'invoices' && empty($user->rights->facture->lire)) { + if ($graphfiles == 'invoices' && !$user->hasRight('facture', 'lire')) { continue; } if ($graphfiles == 'proposals_suppliers' && empty($user->rights->supplier_proposal->lire)) { diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 349b41584d4..ab95a3c6e48 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); - if ($user->rights->fournisseur->facture->lire) { + if ($user->hasRight('fournisseur', 'facture', 'lire')) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle as label, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; if (empty($user->rights->societe->client->voir) && !$socid) { diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php index 149a6aacf41..74cca76c6c2 100644 --- a/htdocs/product/stats/facturerec.php +++ b/htdocs/product/stats/facturerec.php @@ -154,7 +154,7 @@ if ($id > 0 || !empty($ref)) { if ($showmessage && $nboflines > 1) { print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; - } elseif ($user->rights->facture->lire) { + } elseif ($user->hasRight('facture', 'lire')) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= "f.titre, f.datec, f.rowid as facid, f.suspended as suspended,"; $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index f93c5022fd2..f7bb4d6051d 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -138,7 +138,7 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; $sql .= " p.ref_client,"; $sql .= "p.datep, p.fk_statut as statut, d.rowid, d.qty"; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index f2957ffaeb1..e6c07c4cb58 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); - if ($user->rights->propal->lire) { + if ($user->hasRight('propal', 'lire')) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, p.rowid as propalid, p.ref, d.total_ht as amount,"; //$sql .= " p.ref_supplier,"; $sql .= "p.date_valid, p.fk_statut as statut, d.rowid, d.qty"; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index bb8b15d7c10..5baf343556e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -201,7 +201,7 @@ if (empty($reshook)) { $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); $object->fk_project = GETPOST('projectid'); - $object->description = GETPOST("desc"); + $object->description = GETPOST("desc", 'restricthtml'); $object->statut = GETPOST("statut"); $object->lieu = GETPOST("lieu"); $object->address = GETPOST("address"); @@ -280,7 +280,7 @@ $form = new Form($db); $formproduct = new FormProduct($db); $formcompany = new FormCompany($db); $formfile = new FormFile($db); -if (!empty($conf->project->enabled)) { +if (isModEnabled('project')) { $formproject = new FormProjets($db); } @@ -318,7 +318,7 @@ if ($action == 'create') { print '
'.$langs->trans('Project').''; print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); @@ -330,7 +330,7 @@ if ($action == 'create') { print '
'.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, empty($conf->fckeditor->enabled) ? '' : $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', (!empty($object->description) ? $object->description : ''), '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); print '
'.$langs->trans('Project').''; @@ -900,7 +900,7 @@ if ($action == 'create') { print '
'.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); print '
'; - if (!empty($user->rights->produit->creer)) { + if ($user->hasRight('produit', 'creer')) { print ''; print ''; print ''; @@ -1294,7 +1294,7 @@ if (!$variants) { print ''; print ''; print ''; - if (!empty($user->rights->produit->creer)) { + if ($user->hasRight('produit', 'creer')) { print ''; } print ''; @@ -1303,7 +1303,7 @@ if (!$variants) { print "
'.$formproduct->selectWarehouses('', 'fk_entrepot').'
'.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].''.img_delete().'
"; - if (!empty($user->rights->produit->creer)) { + if ($user->hasRight('produit', 'creer')) { print ''; } } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 0e00476455e..372af1496cc 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -153,7 +153,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editeatby'; + $action = 'editeatby'; } else { $action = 'view'; } @@ -164,7 +164,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editsellby'; + $action = 'editsellby'; } else { $action = 'view'; } @@ -175,7 +175,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editeol_date'; + $action = 'editeol_date'; } else { $action = 'view'; } @@ -186,7 +186,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editmanufacturing_date'; + $action = 'editmanufacturing_date'; } else { $action = 'view'; } @@ -197,7 +197,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editscrapping_date'; + $action = 'editscrapping_date'; } else { $action = 'view'; } @@ -218,7 +218,7 @@ if (empty($reshook)) { $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { // Prévoir un test de format de durée setEventMessages($object->error, null, 'errors'); - $action == 'editqc_frequency'; + $action = 'editqc_frequency'; } else { $action = 'view'; } diff --git a/htdocs/product/stock/productlot_note.php b/htdocs/product/stock/productlot_note.php index c8cd43f2091..e0e274f05bd 100644 --- a/htdocs/product/stock/productlot_note.php +++ b/htdocs/product/stock/productlot_note.php @@ -64,8 +64,8 @@ $permissionnote = $user->rights->produit->lire; // Used by the include of action /* * Actions */ - -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 039c6ff9e4a..9fabf33fee7 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -579,7 +579,7 @@ print ''.$langs->trans("ReplenishmentStatusDesc").'< //$link = ''.$langs->trans("MenuNewWarehouse").''; -if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { +if (empty($fk_entrepot) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."\n"; } print '

'; diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index e2b8b7a306f..d88013fb8d1 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -81,7 +81,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_year = ''; } -if (!$user->rights->produit->lire) accessforbidden(); +if (!$user->hasRight('produit', 'lire')) accessforbidden(); /* diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index 29dd7a5b6d9..991f3a0d665 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -81,7 +81,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_year = ''; } -if (!$user->rights->produit->lire) accessforbidden(); +if (!$user->hasRight('produit', 'lire')) accessforbidden(); /* diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 7609cdaf346..5355d9e9cff 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -74,7 +74,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_year = ''; } -if (!$user->rights->produit->lire) accessforbidden(); +if (!$user->hasRight('produit', 'lire')) accessforbidden(); /* diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f423e7a1f5a..0ee2219cbce 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -81,7 +81,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_year = ''; } -if (!$user->rights->produit->lire) accessforbidden(); +if (!$user->hasRight('produit', 'lire')) accessforbidden(); /* diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 8a97d2f8478..0e16bf8d68b 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -145,8 +145,9 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined $sql .= " SUM(ps.reel) AS stock"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE w.entity IN (".getEntity('stock').")"; - $sql .= " AND w.rowid = ps.fk_entrepot"; + $sql .= " AND w.rowid = ps.fk_entrepot AND p.rowid = ps.fk_product"; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } @@ -156,6 +157,12 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined if (! empty($search_fk_warehouse)) { $sql .= " AND ps.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")"; } + if ($search_ref) { + $sql .= natural_search("p.ref", $search_ref); + } + if ($search_nom) { + $sql .= natural_search("p.label", $search_nom); + } $sql .= " GROUP BY fk_product, fk_entrepot"; //print $sql; @@ -195,8 +202,9 @@ if ($date && $dateIsValid) { $sql = "SELECT sm.fk_product, sm.fk_entrepot, SUM(sm.value) AS stock, COUNT(sm.rowid) AS nbofmovement"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as sm"; $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE w.entity IN (".getEntity('stock').")"; - $sql .= " AND w.rowid = sm.fk_entrepot"; + $sql .= " AND w.rowid = sm.fk_entrepot AND p.rowid = sm.fk_product "; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } @@ -211,7 +219,14 @@ if ($date && $dateIsValid) { if (!empty($search_fk_warehouse)) { $sql .= " AND sm.fk_entrepot IN (".$db->sanitize(join(",", $search_fk_warehouse)).")"; } + if ($search_ref) { + $sql .= " AND p.ref LIKE '%".$db->escape($search_ref)."%' "; + } + if ($search_nom) { + $sql .= " AND p.label LIKE '%".$db->escape($search_nom)."%' "; + } $sql .= " GROUP BY sm.fk_product, sm.fk_entrepot"; + $resql = $db->query($sql); if ($resql) { @@ -289,6 +304,12 @@ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (!empty($canvas)) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} +if ($search_nom) { + $sql .= natural_search('p.label', $search_nom); +} $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price, p.pmp, p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; $sql .= ' p.tms, p.duration, p.tobuy, p.stock'; // Add where from hooks diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php index 55545a6868c..a8426376fc0 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php @@ -135,7 +135,7 @@ if ($object->id > 0) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; @@ -188,7 +188,7 @@ if ($object->id > 0) { $objcon = new stdClass(); $out = '&origin='.$object->element.'&originid='.$object->id; - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.=''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -211,7 +211,7 @@ if ($object->id > 0) { print ''; - if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { $param = '&id='.$object->id.'&socid='.$socid; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.((int) $limit); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 171408df070..5dade5dc874 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -563,7 +563,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= $langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '').'
'; } // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.=$langs->trans('Project') . ' '; if ($permissiontoadd) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 045af2dd42a..7265fd992a1 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -134,7 +134,7 @@ if ($object->id > 0) { $morehtmlref .= '
' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); } // Project - if (!empty($conf->project->enabled)) { + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->stocktransfer->stocktransfer->write) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_document.php b/htdocs/product/stock/stocktransfer/stocktransfer_document.php index 7220581bc52..d4d3bc2d91d 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_document.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_document.php @@ -122,7 +122,7 @@ if ($object->id) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_note.php b/htdocs/product/stock/stocktransfer/stocktransfer_note.php index 2176af2803a..0aee6e59124 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_note.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_note.php @@ -95,7 +95,7 @@ if ($id > 0 || !empty($ref)) { // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); // Project - if (!empty($conf->project->enabled)) + if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 793c0dcd1e4..e13ac6d7c23 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -182,7 +182,7 @@ if (ismodEnabled('productbatch') && print '
'.$langs->trans("UnitPurchaseValue").''.$langs->trans('Project').''; print img_picto('', 'project'); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index ba4dc956d08..1544df1ca2c 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -1,8 +1,9 @@ * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2010-2012 Destailleur Laurent - * Copyright (C) 2014 Henry Florian + * Copyright (C) 2010-2012 Destailleur Laurent + * Copyright (C) 2014 Henry Florian + * Copyright (C) 2023 Benjamin Falière * * 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 @@ -91,7 +92,7 @@ if (empty($reshook)) { } // Add translation - if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -126,7 +127,7 @@ if (empty($reshook)) { } // Edit translation - if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $object = new Product($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -136,6 +137,8 @@ if (empty($reshook)) { $object->label = GETPOST("libelle-" . $key); $object->description = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml')); $object->other = dol_htmlcleanlastbr(GETPOST("other-" . $key, 'restricthtml')); + + $object->update($object->id, $user); } else { $object->multilangs[$key]["label"] = GETPOST("libelle-" . $key); $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-" . $key, 'restricthtml')); @@ -153,7 +156,7 @@ if (empty($reshook)) { } // Delete translation - if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { + if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { $object = new Product($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); @@ -231,7 +234,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been if (empty($reshook)) { if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print '' . $langs->trans("Add") . ''; if ($cnt_trans > 0) { print '' . $langs->trans("Modify") . ''; @@ -318,7 +321,7 @@ if ($action == 'edit') { * Form to add a new translation */ -if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'add' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index ccd5b0b88db..b3095b2a8e1 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -97,7 +97,7 @@ $morehtml .= 'rights->projet->all->lire && !$socid) { + if ($user->hasRight('projet', 'all', 'lire') && !$socid) { $tooltiphelp = $langs->trans("TasksDesc"); } else { $tooltiphelp = $langs->trans("TasksPublicDesc"); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9c4e47037c2..ff29924edec 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -485,7 +485,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index bff135b713f..481652a5349 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -399,7 +399,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 1d3a6ef3c2c..daf1dd0ac7b 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -499,7 +499,7 @@ print img_picto('', 'projecttask', 'class="pictofixedwidth"'); $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess); print ''; print ' '; -print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position', 0, 'maxwidth150onsmartphone'); print ''; print ''; diff --git a/htdocs/projet/agenda.php b/htdocs/projet/agenda.php index df078354315..5e8f0dfafbf 100644 --- a/htdocs/projet/agenda.php +++ b/htdocs/projet/agenda.php @@ -112,7 +112,7 @@ if ($id > 0 || !empty($ref)) { } $object->info($object->id); } -$agenda = (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) ? '/'.$langs->trans("Agenda") : ''; +$agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/'.$langs->trans("Agenda") : ''; $title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); @@ -162,7 +162,7 @@ print dol_get_fiche_end(); // Actions buttons $out = ''; -$permok = $user->rights->agenda->myactions->create; +$permok = $user->hasRight('agenda', 'myactions', 'create'); if ($permok) { $out .= '&projectid='.$object->id; } @@ -198,7 +198,7 @@ if (!empty($object->id)) { // Show link to add event if (isModEnabled('agenda')) { - $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create'); + $addActionBtnRight = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create'); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 1d2f0817c20..b5153689158 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -777,7 +777,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Budget - print '
'.$langs->trans("Budget").'
'.$langs->trans("Budget").''; print ' '.$langs->getCurrencySymbol($conf->currency); print ''; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print ''; print ''; - -$sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= ", spe.accountancy_code_customer as compta"; -} else { - $sql .= ", s.code_compta"; -} -$sql .= ", s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country "; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); -} -$sql .= ", ".MAIN_DB_PREFIX."facture as f"; -$sql .= ", ".MAIN_DB_PREFIX."c_country as cp"; -$sql .= " WHERE f.fk_soc = s.rowid"; -$sql .= " AND s.fk_pays = cp.rowid"; -if (!empty($date_start) && !empty($date_end)) { - $sql .= " AND f.datec >= '".$db->idate($date_start)."' AND f.datec <= '".$db->idate($date_end)."'"; -} -$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; -if ($socid > 0) { - $sql .= " AND f.fk_soc = ".((int) $socid); -} -$sql .= " GROUP BY name"; -$sql .= ")"; -$sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, , "; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= ", spe.accountancy_code_supplier as compta"; -} else { - $sql .= ", s.code_compta_fournisseur as compta"; -} -$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country "; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); -} -$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as ff"; -$sql .= ", ".MAIN_DB_PREFIX."c_country as cp"; -$sql .= " WHERE ff.fk_soc = s.rowid"; -$sql .= " AND s.fk_pays = cp.rowid"; -if (!empty($date_start) && !empty($date_end)) { - $sql .= " AND ff.datec >= '".$db->idate($date_start)."' AND ff.datec <= '".$db->idate($date_end)."'"; -} -$sql .= " AND ff.entity = ".$conf->entity; -if ($socid > 0) { - $sql .= " AND f.fk_soc = ".((int) $socid); -} -$sql .= " GROUP BY name"; -$sql .= ")"; - -$sql .= "ORDER BY name ASC"; - -dol_syslog('accountancy/admin/thirdpartyaccount.php:: $sql='.$sql); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - // export csv - if (GETPOST('action', 'aZ09') == 'export_csv') { - header('Content-Type: text/csv'); - header('Content-Disposition: attachment;filename=export_csv.csv'); - - $obj = $db->fetch_object($resql); - - print '"'.$obj->compta.'",'; - print '"'.$obj->address.'",'; - print '"'.$obj->zip.'",'; - print '"'.$obj->town.'",'; - print '"'.$obj->country.'",'; - print '"'.$obj->phone.'",'; - print '"'.$obj->fax.'",'; - print "\n"; - $i++; - } - - - $thirdpartystatic = new Societe($db); - - print '

'; - - print ''; - print "
\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - while ($obj = $db->fetch_object($resql)) { - print ''; - print ''; - print ''."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $i++; - } - - print "
'.$langs->trans("ThirdParties").''.$langs->trans("AccountNumber").''.$langs->trans("RaisonSociale").''.$langs->trans("Address").''.$langs->trans("Zip").''.$langs->trans("Town").''.$langs->trans("Country").''.$langs->trans("Contact").''.$langs->trans("Phone").''.$langs->trans("Fax").'
'; - $thirdpartystatic->id = $obj->rowid; - $thirdpartystatic->name = $obj->name; - $thirdpartystatic->client = $obj->client; - $thirdpartystatic->canvas = $obj->canvas; - $thirdpartystatic->status = $obj->status; - print $thirdpartystatic->getNomUrl(1); - print ''.$obj->compta.''.$obj->address.''.$obj->zip.''.$obj->town.''.$obj->country.''.$obj->phone.''.$obj->fax.'
"; - $db->free($resql); -} else { - dol_print_error($db); -} - -llxFooter(); -$db->close(); diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index d9876ca008c..a0e896b8064 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -204,6 +204,9 @@ if ($resql) { } $i = 0; + $total = 0; + $totald = 0; + $totalc = 0; while ($i < $numrows) { $thirdparty = ''; $accountelem = ''; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 606ac32ca66..d8c8dc1bd37 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -109,7 +109,7 @@ if ($resql) { print "We found ".$num." couples (unpayed validated invoice - sale representative) qualified\n"; dol_syslog("We found ".$num." couples (unpayed validated invoice - sale representative) qualified"); $message = ''; - + $oldsalerepresentative = 0; if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index b19398eda50..a2e6f1c5241 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -78,6 +78,12 @@ $filter = array(); $regenerate = ''; // Ask regenerate (contains name of model to use) $option = ''; $fileprefix = 'mergedpdf'; +$dateafterdate = ''; +$datebeforedate = ''; +$paymentdateafter = ''; +$paymentdatebefore = ''; +$paymentonbankid = 0; +$thirdpartiesid = 0; foreach ($argv as $key => $value) { $found = false; diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index b40a267d62e..083ae81bd3e 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -187,7 +187,8 @@ $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result >= 0) { $justthese = array(); - + $pricefirst = 0; + $pricelast = 0; // We disable synchro Dolibarr-LDAP $conf->global->LDAP_MEMBER_ACTIVE = 0; diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 2d321752fe9..076389ece38 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -54,7 +54,7 @@ if (empty($user->id)) { $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; - +$conf->global->MAIN_UMASK='666'; /** diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index ace8d4ff32a..a3873b2614d 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -176,26 +176,26 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname', SORT_ASC, 0, 1, '', 1); foreach ($filesarray as $key => $file) { - if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/includes\//', $file['fullname'])) { continue; } - if (preg_match('/\/htdocs\/install\/doctemplates\/websites\//', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/install\/doctemplates\/websites\//', $file['fullname'])) { continue; } - if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/custom\//', $file['fullname'])) { continue; } - if (preg_match('/\/htdocs\/dolimed/', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/dolimed/', $file['fullname'])) { continue; } - if (preg_match('/\/htdocs\/nltechno/', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/nltechno/', $file['fullname'])) { continue; } - if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) { + if (preg_match('/\/(htdocs|html)\/teclib/', $file['fullname'])) { continue; } - print 'Check php file '.$file['fullname']."\n"; + //print 'Check php file '.$file['relativename']."\n"; $filecontent=file_get_contents($file['fullname']); if (preg_match('/\.class\.php/', $file['relativename']) @@ -234,7 +234,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'objectline_view.tpl.php', 'extrafieldsinexport.inc.php', 'extrafieldsinimport.inc.php', - 'DolQueryCollector.php' + 'DolQueryCollector.php', + 'DoliStorage.php' ))) { // Must not found $this->db-> $ok=true; @@ -267,20 +268,22 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase // Check if a var_dump has been forgotten if (!preg_match('/test\/phpunit/', $file['fullname'])) { - $ok=true; - $matches=array(); - preg_match_all('/(.)\s*var_dump/', $filecontent, $matches, PREG_SET_ORDER); - //var_dump($matches); - foreach ($matches as $key => $val) { - if ($val[1] != '/' && $val[1] != '*') { - $ok=false; + if (! in_array($file['name'], array('class.nusoap_base.php'))) { + $ok=true; + $matches=array(); + preg_match_all('/(.)\s*var_dump\(/', $filecontent, $matches, PREG_SET_ORDER); + //var_dump($matches); + foreach ($matches as $key => $val) { + if ($val[1] != '/' && $val[1] != '*') { + $ok=false; + break; + } break; } - break; + //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; + $this->assertTrue($ok, 'Found string var_dump that is not just after /* or // in '.$file['relativename']); + //exit; } - //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; - $this->assertTrue($ok, 'Found string var_dump that is not just after /* or // in '.$file['relativename']); - //exit; } // Check get_class followed by __METHOD__ diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 85a5f525e47..287f759982c 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -185,16 +185,16 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // An attempt for SQL injection $filter='if(now()=sysdate()%2Csleep(6)%2C0)'; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, 'Filter syntax error'); + $this->assertEquals($sql, 'Filter syntax error - Bad syntax of the search string'); // A real search string $filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, ' AND (((statut = 1 or entity IN (__AAA__)) and abc < 2 and abc <> 1.23))'); + $this->assertEquals($sql, ' AND ((((statut = 1) or (entity IN (__AAA__))) and (abc < 2) and (abc <> 1.23)))'); $filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)"; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, " AND (t.ref LIKE 'SO-%' or t.date_creation < '20160101' or t.date_creation < 0 or t.nature IS NULL)"); + $this->assertEquals($sql, " AND ((t.ref LIKE 'SO-%') or (t.date_creation < '20160101') or (t.date_creation < 0) or (t.nature IS NULL))"); return true; } diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index c4021d2deff..6ef14f7a227 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -212,13 +212,14 @@ class LangTest extends PHPUnit\Framework\TestCase unset($tmplangs); + print "Check also some syntax rules into the language file\n"; $filesarray2 = scandir(DOL_DOCUMENT_ROOT.'/langs/'.$code); foreach ($filesarray2 as $key => $file) { if (! preg_match('/\.lang$/', $file)) { continue; } - print 'Check lang file '.$file."\n"; + //print 'Check lang file '.$file."\n"; $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/langs/'.$code.'/'.$file); $result=preg_match('/=--$/m', $filecontent); // A special % char we don't want. We want the common one. diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 8a54893d890..148adb20808 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -204,6 +204,11 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=testSqlAndScriptInject($test, 0); $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c'); + $test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; + $result=testSqlAndScriptInject($test, 1); + print "test=".$test." result=".$result."\n"; + $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url'); + // Should detect attack $expectedresult=1; @@ -691,6 +696,14 @@ class SecurityTest extends PHPUnit\Framework\TestCase $decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1); $this->assertEquals('bbbڴ', $decodedstring, 'Function did not sanitize correclty with test 3'); + $stringtotest = 'text text'; + $decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1, 0, array(), 0); + $this->assertEquals('text text', $decodedstring, 'Function did not sanitize correclty with test 4a'); + + $stringtotest = 'text text'; + $decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1, 0, array(), 1); + $this->assertEquals('text text', $decodedstring, 'Function did not sanitize correclty with test 4b'); + return 0; } @@ -782,7 +795,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow print __METHOD__." url=".$url."\n"; - $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 without a follow -> 301'); + $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 response and stop here'); $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 diff --git a/test/phpunit/pdfwithjs.pdf b/test/phpunit/pdfwithjs.pdf new file mode 100644 index 00000000000..299ceee23d9 Binary files /dev/null and b/test/phpunit/pdfwithjs.pdf differ