From 08702a0d1a1dade205a587c65076f7824fb21ed7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 26 Aug 2020 14:16:49 +0200 Subject: [PATCH 001/173] on going version 3 --- build/docker/Dockerfile | 62 +++++++++++++++++----------- build/docker/docker-compose.yml | 73 ++++++++++++++++++++------------- htdocs/install/fileconf.php | 2 +- 3 files changed, 83 insertions(+), 54 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 9264eed5ef2..bf50a585a41 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,20 +1,34 @@ -FROM php:7.2-apache +FROM php:7.3-apache -ENV HOST_USER_ID 33 +ENV WWW_USER_ID 33 +ENV WWW_GROUP_ID 33 ENV PHP_INI_DATE_TIMEZONE 'UTC' +ENV PHP_INI_MEMORY_LIMIT 256M -RUN apt-get update && apt-get install -y libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++\ - && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-install gd \ - && docker-php-ext-install zip \ - && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ - && docker-php-ext-install ldap \ - && docker-php-ext-install mysqli \ - && docker-php-ext-install calendar \ - && docker-php-ext-configure intl \ - && docker-php-ext-install intl \ - && apt-get autoremove --purge -y libpng-dev libjpeg62-turbo-dev libldap2-dev zlib1g-dev libicu-dev g++ +RUN apt-get update -y \ + && apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libjpeg62-turbo \ + libpng-dev \ + libpng16-16 \ + libldap2-dev \ + libxml2-dev \ + libzip-dev \ + zlib1g-dev \ + libicu-dev \ + g++ \ + default-mysql-client \ + unzip \ + curl \ + apt-utils \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ + && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ + && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \ + && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ + && docker-php-ext-install -j$(nproc) ldap && \ + mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini RUN mkdir /var/documents RUN chown www-data /var/documents @@ -23,16 +37,16 @@ COPY docker-run.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-run.sh RUN pecl install xdebug && docker-php-ext-enable xdebug -RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_autostart=0' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.default_enable=0' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_host=docker.host' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_connect_back=0' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.profiler_enable=0' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> /usr/local/etc/php/php.ini -RUN echo '172.17.0.1 docker.host' >> /etc/hosts +RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_autostart=0' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.default_enable=0' >> ${PHP_INI_DIR}/php.ini +#RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_connect_back=0' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini +#RUN echo '172.17.0.1 docker.host' >> /etc/hosts EXPOSE 80 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index cc839810e7f..5e3a4444e41 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -1,32 +1,47 @@ -mariadb: - build: mariadb - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: dolibarr +version: '3' -phpmyadmin: - image: phpmyadmin/phpmyadmin - environment: - PMA_HOST: mariadb - links: - - mariadb - ports: - - "8080:80" +networks: + internal-pod: + internal: true + external-pod: + internal: false -web: - build: . - environment: - HOST_USER_ID: $HOST_USER_ID - volumes: - - ../../htdocs:/var/www/html - links: - - mariadb - - mail - ports: - - "80:80" +services: + mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: dolibarr + networks: + - internal-pod -mail: - image: maildev/maildev - ports: - - "8081:80" - - "25:25" \ No newline at end of file + phpmyadmin: + image: phpmyadmin/phpmyadmin + environment: + PMA_HOST: mariadb + depends_on: + - mariadb + ports: + - "8080:80" + + web: + build: + context: . + environment: + HOST_USER_ID: $HOST_USER_ID + volumes: + - ../../htdocs:/var/www/html/ + ports: + - "80:80" + depends_on: + - mariadb + - mail + networks: + - internal-pod + - external-pod + + mail: + image: maildev/maildev + ports: + - "8081:80" + - "25:25" diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 4e914e1a4f3..14f3d19bdf9 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -31,7 +31,7 @@ include_once 'inc.php'; global $langs; -$err = 0; +$err = 0 $setuplang = GETPOST("selectlang", '', 3) ?GETPOST("selectlang", '', 3) : (isset($_GET["lang"]) ? $_GET["lang"] : 'auto'); $langs->setDefaultLang($setuplang); From b7f4162721a8ac7e5e50b1bb7781c2a2d19b1dc1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 28 Aug 2020 12:10:08 +0200 Subject: [PATCH 002/173] use new version docker file --- build/docker/Dockerfile | 12 ++++++------ build/docker/docker-compose.yml | 3 +++ build/docker/docker-run.sh | 5 ++--- htdocs/install/fileconf.php | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index bf50a585a41..ca5f990a802 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update -y \ && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \ && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ && docker-php-ext-install -j$(nproc) ldap && \ - mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini + mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini RUN mkdir /var/documents RUN chown www-data /var/documents @@ -38,15 +38,15 @@ RUN chmod +x /usr/local/bin/docker-run.sh RUN pecl install xdebug && docker-php-ext-enable xdebug RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"' >> ${PHP_INI_DIR}/php.ini -RUN echo 'xdebug.remote_autostart=0' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_autostart=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini -RUN echo 'xdebug.default_enable=0' >> ${PHP_INI_DIR}/php.ini -#RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.default_enable=1' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini -RUN echo 'xdebug.remote_connect_back=0' >> ${PHP_INI_DIR}/php.ini +RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini -#RUN echo '172.17.0.1 docker.host' >> /etc/hosts +RUN echo '172.17.0.1 docker.host' >> /etc/hosts EXPOSE 80 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 5e3a4444e41..1f8f7e3063b 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -23,6 +23,8 @@ services: - mariadb ports: - "8080:80" + networks: + - internal-pod web: build: @@ -33,6 +35,7 @@ services: - ../../htdocs:/var/www/html/ ports: - "80:80" + - "9000:9001" depends_on: - mariadb - mail diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh index df7272c317d..cec7e138b4a 100644 --- a/build/docker/docker-run.sh +++ b/build/docker/docker-run.sh @@ -1,7 +1,7 @@ #!/bin/bash -usermod -u $HOST_USER_ID www-data -groupmod -g $HOST_USER_ID www-data +usermod -u "${HOST_USER_ID}" www-data +groupmod -g "${HOST_USER_ID}" www-data chgrp -hR www-data /var/www/html chmod g+rwx /var/www/html/conf @@ -9,7 +9,6 @@ chmod g+rwx /var/www/html/conf if [ ! -f /usr/local/etc/php/php.ini ]; then cat < /usr/local/etc/php/php.ini date.timezone = $PHP_INI_DATE_TIMEZONE -display_errors = On EOF fi diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 14f3d19bdf9..4e914e1a4f3 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -31,7 +31,7 @@ include_once 'inc.php'; global $langs; -$err = 0 +$err = 0; $setuplang = GETPOST("selectlang", '', 3) ?GETPOST("selectlang", '', 3) : (isset($_GET["lang"]) ? $_GET["lang"] : 'auto'); $langs->setDefaultLang($setuplang); From fba614632f4615d10bcec61a1ef2fd6905d58f98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 29 Aug 2020 18:31:42 +0200 Subject: [PATCH 003/173] working on docker image --- build/docker/Dockerfile | 6 ++---- build/docker/README.md | 2 ++ build/docker/docker-compose.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index ca5f990a802..aa756f1e975 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,7 +1,5 @@ FROM php:7.3-apache -ENV WWW_USER_ID 33 -ENV WWW_GROUP_ID 33 ENV PHP_INI_DATE_TIMEZONE 'UTC' ENV PHP_INI_MEMORY_LIMIT 256M @@ -41,12 +39,12 @@ RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-2018073 RUN echo 'xdebug.remote_autostart=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_enable=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.default_enable=1' >> ${PHP_INI_DIR}/php.ini -RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini +#RUN echo 'xdebug.remote_host=docker.host' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini -RUN echo '172.17.0.1 docker.host' >> /etc/hosts +#RUN echo '172.17.0.1 docker.host' >> /etc/hosts EXPOSE 80 diff --git a/build/docker/README.md b/build/docker/README.md index 616cbd8fa78..13b89567766 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -1,6 +1,8 @@ # How to use it ? The docker-compose.yml file is used to build and run Dolibarr in the current workspace. +This docker image intended for developpement usage. +For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr Before build/run, define the variable HOST_USER_ID as following: diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 1f8f7e3063b..9c40fbe7fc6 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -35,7 +35,7 @@ services: - ../../htdocs:/var/www/html/ ports: - "80:80" - - "9000:9001" + - "9000:9000" depends_on: - mariadb - mail From 9614dcf9ec83fed72d3abec76b3cf4c387209ad2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 29 Aug 2020 18:38:26 +0200 Subject: [PATCH 004/173] fix comment --- .../mysql/tables/llx_recruitment_recruitmentcandidature.key.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_recruitment_recruitmentcandidature.key.sql b/htdocs/install/mysql/tables/llx_recruitment_recruitmentcandidature.key.sql index 93fb231dc35..eae967704b4 100644 --- a/htdocs/install/mysql/tables/llx_recruitment_recruitmentcandidature.key.sql +++ b/htdocs/install/mysql/tables/llx_recruitment_recruitmentcandidature.key.sql @@ -23,5 +23,5 @@ ALTER TABLE llx_recruitment_recruitmentcandidature ADD INDEX idx_recruitment_rec ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid); ---ALTER TABLE llx_recruitment_recruitmentcandidature ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid); +-- ALTER TABLE llx_recruitment_recruitmentcandidature ADD CONSTRAINT llx_mymodule_myobject_fk_field FOREIGN KEY (fk_field) REFERENCES llx_mymodule_myotherobject(rowid); From ffb3d810def9e2988a941f43bd58aabf9fc477a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Aug 2020 16:21:59 +0200 Subject: [PATCH 005/173] Complete fix for #14580 for v10 (backport of change of develop) --- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/langs/en_US/other.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 98c55c71232..347ce29df1c 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1208,7 +1208,7 @@ class FormMail extends Form elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } - elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } + elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentGeneric"); } $ret->label = 'default'; $ret->lang = $outputlangs->defaultlang; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 5dd7422539a..83db92bd9e2 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -97,6 +97,7 @@ PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNA PredefinedMailContentContact=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.\n\n%s\n\n +PredefinedMailContentGeneric=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) From e9ff43ad44d2847b962334facf194760191c2c2b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 1 Sep 2020 14:31:54 +0200 Subject: [PATCH 006/173] ongoing --- build/docker/Dockerfile | 2 +- build/docker/docker-compose.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index aa756f1e975..2be287c2db9 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -29,7 +29,7 @@ RUN apt-get update -y \ mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini RUN mkdir /var/documents -RUN chown www-data /var/documents +RUN chown www-data:www-data /var/documents COPY docker-run.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-run.sh diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 9c40fbe7fc6..45a1a76d6fc 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -25,6 +25,7 @@ services: - "8080:80" networks: - internal-pod + - external-pod web: build: @@ -33,6 +34,7 @@ services: HOST_USER_ID: $HOST_USER_ID volumes: - ../../htdocs:/var/www/html/ + - ../../documents:/var/documents ports: - "80:80" - "9000:9000" From 134a47a93f2b97356627a6f332f43ee2c1f8229a Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Tue, 1 Sep 2020 15:36:35 +0200 Subject: [PATCH 007/173] FIX 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename --- htdocs/core/class/CMailFile.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 853f2f98b05..7c12f4f9d5b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -463,6 +463,9 @@ class CMailFile { //$this->message->attach(Swift_Attachment::fromPath($filename_list[$i],$mimetype_list[$i])); $attachment = Swift_Attachment::fromPath($filename_list[$i], $mimetype_list[$i]); + if (!empty($mimefilename_list[$i])) { + $attachment->setFilename($mimefilename_list[$i]); + } $this->message->attach($attachment); } } From f6b902ad365a64c6c9e1b3a229aa7805a668d7bf Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 3 Sep 2020 09:58:28 +0200 Subject: [PATCH 008/173] Show counts and add links in shipment area --- htdocs/expedition/index.php | 46 +++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 849e2054cd6..2a4e92d28d6 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -84,7 +85,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= $clause." sc.fk_user = ".$user->id; $clause = " AND "; } -$sql .= $clause." e.fk_statut = 0"; +$sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT; $sql .= " AND e.entity IN (".getEntity('expedition').")"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; @@ -96,7 +97,13 @@ if ($resql) print '
'; print ''; print ''; - print ''; + print ''; + print ''; if ($num) { @@ -156,13 +163,21 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + + print '
'; + print '
'.$langs->trans("SendingsToValidate").'
'; + print $langs->trans("SendingsToValidate").' '; + print ''; + print ''.$num.''; + print ''; + print '
'; + print ''; + print ''; + print ''; + if ($num) { $i = 0; - print '
'; - print '
'; + print $langs->trans("LastSendings").' '; + print ''; + print ''.$num.''; + print ''; + print '
'; - print ''; - print ''; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -190,6 +205,8 @@ if ($resql) $i++; } print "
'.$langs->trans("LastSendings", $num).'

"; + } else { + print ''.$langs->trans("None").''; } $db->free($resql); } else dol_print_error($db); @@ -214,13 +231,20 @@ if ($resql) $langs->load("orders"); $num = $db->num_rows($resql); + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($num) { $i = 0; - print '
'; - print '
'.$langs->trans("OrdersToProcess").' '; + print ''; + print ''.$num.''; + print ''; + print '
'; - print ''; - print ''; while ($i < $num && $i < 10) { $obj = $db->fetch_object($resql); @@ -256,6 +280,8 @@ if ($resql) } print "
'.$langs->trans("OrdersToProcess").' '.$num.'

"; + } else { + print ''.$langs->trans("None").''; } } else dol_print_error($db); From c17bc8b3c8c89b410430b148a3a622959c8733bf Mon Sep 17 00:00:00 2001 From: John Botella Date: Thu, 3 Sep 2020 10:45:03 +0200 Subject: [PATCH 009/173] Fix missing param for hook --- htdocs/societe/class/societe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9becbd199cc..f10cead50fd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2412,7 +2412,15 @@ class Societe extends CommonObject global $action; $hookmanager->initHooks(array('thirdpartydao')); - $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $parameters = array( + 'id'=>$this->id, + 'getnomurl'=>$result, + 'withpicto '=> $withpicto, + 'option'=> $option, + 'maxlen'=> $maxlen, + 'notooltip'=> $notooltip, + 'save_lastsearch_value'=> $save_lastsearch_value + ); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; From bb92e64e433f068beb28a6c3758a726928e4e23d Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 3 Sep 2020 12:43:38 +0200 Subject: [PATCH 010/173] FIX: #14474 Error when deleting --- htdocs/comm/propal/class/propal.class.php | 10 ++++- htdocs/commande/class/commande.class.php | 7 ++- htdocs/compta/facture/class/facture.class.php | 8 +++- htdocs/core/class/commonobject.class.php | 45 ++++++++++++++++++- htdocs/expedition/class/expedition.class.php | 8 +++- htdocs/fichinter/class/fichinter.class.php | 8 +++- .../class/fournisseur.commande.class.php | 8 +++- .../fourn/class/fournisseur.facture.class.php | 8 +++- .../class/supplier_proposal.class.php | 8 +++- 9 files changed, 100 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a2d1e934d35..325a0894302 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2019 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2010-2017 Philippe Grand * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -1063,7 +1063,7 @@ class Propal extends CommonObject $ret = $this->add_object_linked(); if (! $ret) dol_print_error($this->db); } - + /* * Insertion du detail des produits dans la base * Insert products detail in database @@ -2900,6 +2900,12 @@ class Propal extends CommonObject if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref)) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7d8e2680977..47ffec60592 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -3327,6 +3327,11 @@ class Commande extends CommonOrder if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } // Remove directory with files $comref = dol_sanitizeFileName($this->ref); if ($conf->commande->dir_output && !empty($this->ref)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 12d60b067fa..21f68e1c329 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Cédric Salvador @@ -2019,6 +2019,12 @@ class Facture extends CommonInvoice $resql=$this->db->query($sql); if ($resql) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // On efface le repertoire de pdf provisoire $ref = dol_sanitizeFileName($this->ref); if ($conf->facture->dir_output && !empty($this->ref)) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 157fc718700..ccbcb9d6789 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2013 Regis Houssin - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2019 Philippe Grand * Copyright (C) 2012-2015 Marcos García @@ -7734,4 +7734,47 @@ abstract class CommonObject } } } + + /** + * Delete related files of object in database + * + * @return bool + */ + public function delete_ecmfiles(){ + global $conf; + $this->db->begin(); + + switch ($this->element){ + case 'propal': + $element = 'propale'; + break; + case 'product': + $element = 'produit'; + break; + case 'order_supplier': + $element ='fournisseur/commande'; + break; + case 'invoice_supplier': + $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); + break; + case 'shipping': + $element = 'expedition/sending'; + break; + default: + $element = $this->element; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; + $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql.= " AND filepath = '".$element."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + + if (!$this->db->query($sql)) { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return false; + } + + $this->db->commit(); + return true; + } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8417ddb9bfb..b3584327f3c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2011-2017 Juanjo Menent + * Copyright (C) 2011-2020 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García @@ -1310,6 +1310,12 @@ class Expedition extends CommonObject { $this->db->commit(); + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // We delete PDFs $ref = dol_sanitizeFileName($this->ref); if (! empty($conf->expedition->dir_output)) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 4ce2aa954b2..a9ec1ba588e 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2013 Juanjo Menent + * Copyright (C) 2011-2020 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Charlie Benke * Copyright (C) 2018 Nicolas ZABOURI @@ -1003,6 +1003,12 @@ class Fichinter extends CommonObject if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // Remove directory with files $fichinterref = dol_sanitizeFileName($this->ref); if ($conf->ficheinter->dir_output) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ef8d4b4d93f..6d73ee59f4d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2010-2018 Philippe Grand * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2013 Florian Henry @@ -1979,6 +1979,12 @@ class CommandeFournisseur extends CommonOrder if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->fournisseur->commande->dir_output) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e20a3f9e7de..f1bd120f082 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2017 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2013-2019 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García @@ -1157,6 +1157,12 @@ class FactureFournisseur extends CommonInvoice if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // We remove directory if ($conf->fournisseur->facture->dir_output) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 2e6c0f45397..4279925054d 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2020 Juanjo Menent * Copyright (C) 2010-2018 Philippe Grand * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -2065,6 +2065,12 @@ class SupplierProposal extends CommonObject if (! $error) { + // On delete ecm_files database info + if (!$this->delete_ecmfiles()) { + $this->db->rollback(); + return 0; + } + // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->supplier_proposal->dir_output && !empty($this->ref)) From 9bd5ed627f195f6cc927ce372d75d697ab0230de Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 4 Sep 2020 09:55:02 +0200 Subject: [PATCH 011/173] Fix travis issues --- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/class/commonobject.class.php | 3 ++- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 325a0894302..3000fb8b2e3 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2901,7 +2901,7 @@ class Propal extends CommonObject if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 47ffec60592..d56329c93d9 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3328,7 +3328,7 @@ class Commande extends CommonOrder if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 21f68e1c329..5ea423fa942 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2020,7 +2020,7 @@ class Facture extends CommonInvoice if ($resql) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ccbcb9d6789..103d704a546 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7740,7 +7740,8 @@ abstract class CommonObject * * @return bool */ - public function delete_ecmfiles(){ + public function deleteEcmFiles() + { global $conf; $this->db->begin(); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b3584327f3c..fd764aca981 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1311,7 +1311,7 @@ class Expedition extends CommonObject $this->db->commit(); // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index a9ec1ba588e..8e7d23a8cd8 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1004,7 +1004,7 @@ class Fichinter extends CommonObject if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6d73ee59f4d..663d72b26b1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1980,7 +1980,7 @@ class CommandeFournisseur extends CommonOrder if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f1bd120f082..b5339d913c5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1158,7 +1158,7 @@ class FactureFournisseur extends CommonInvoice if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 4279925054d..0014db887a1 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2066,7 +2066,7 @@ class SupplierProposal extends CommonObject if (! $error) { // On delete ecm_files database info - if (!$this->delete_ecmfiles()) { + if (!$this->deleteEcmFiles()) { $this->db->rollback(); return 0; } From 0375f5fd37e575ae3122d2b2337f1949c3efff7b Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 4 Sep 2020 15:24:45 +0200 Subject: [PATCH 012/173] Add helper function for table headers with numbers --- htdocs/comm/index.php | 28 +++----------- htdocs/core/lib/functions.lib.php | 62 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 602cde69163..56e5071a250 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -168,10 +168,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; + StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); if ($num > 0) { @@ -253,10 +250,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("ProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); if ($num > 0) { @@ -335,10 +329,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("SupplierProposalsDraft").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); if ($num > 0) { @@ -422,10 +413,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - print '
'; - print '
'.$langs->trans("DraftOrders").' '.$num.'
'; - print ''; - print ''; + StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); if ($num > 0) { @@ -727,9 +715,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -831,9 +817,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - print '
'; - print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; - print ''; + StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 74916ec62e1..7feb9aa8655 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8670,3 +8670,65 @@ function currentToken() { return $_SESSION['token']; } + +/** + * Start a table with headers and a optinal clickable number + * (don't forget to close the table with a HTML TABLE and a HTML DIV element) + * + * @param string|array $headers The header(s) of the table (headers inside a array are automatic translated) + * @param integer $emptyRows (optional) The count of empty rows after the first header (use this instead of empty headers) + * @param integer $number (optional) The number that is shown right after the first header + * @param string $internalLink (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @return void + */ +function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +{ + global $langs; + + print '
'; + print '
'.$langs->trans("OrdersOpened").' '.$num.'
'; + print ''; + + print $emptyRows < 1 ? ''; + + if(!is_array($headers) || count($headers) < 2) + { + print ''; + return; + } + + foreach(array_slice($headers, 1) as $header) + { + print ''; + } + + print ''; +} From 10d34052199fd61cf8c90d28b1aec3bfc950a29b Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 7 Sep 2020 12:21:00 +0200 Subject: [PATCH 013/173] FIX: lang fr retained warranty --- htdocs/langs/fr_FR/bills.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 5fdf44538e1..5da6bda8133 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -212,7 +212,7 @@ AmountOfBillsByMonthHT=Montant de factures par mois (HT) UseSituationInvoices=Autoriser les factures de situation UseSituationInvoicesCreditNote=Autoriser les avoirs de factures de situation Retainedwarranty=Retenue de garantie -AllowedInvoiceForRetainedWarranty=Garantie conservée utilisable sur les types de factures suivants +AllowedInvoiceForRetainedWarranty=Rendre la retenue de garantie utilisable sur les types de factures suivants RetainedwarrantyDefaultPercent=Pourcentage par défaut de la retenue de garantie RetainedwarrantyOnlyForSituation=Rendre la "retenue de garantie" disponible uniquement pour les factures de situation RetainedwarrantyOnlyForSituationFinal=Sur les factures de situation, la déduction globale pour "retenue de garantie" n'est appliquée que sur la facture de situation finale From ca6e57b2f7eec21cb55b7b189319b1b370cd10c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2020 14:25:50 +0200 Subject: [PATCH 014/173] FIX Filter in "billed" of orders was not saved --- htdocs/commande/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 0cc9fa6634b..1e7e0d1d9d7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -65,7 +65,7 @@ $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); -$search_state = trim(GETPOST("search_state")); +$search_state = GETPOST("search_state", 'alpha'); $search_country = GETPOST("search_country", 'int'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -82,9 +82,9 @@ $search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'a $search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); $search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); -$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_categ_cus = GETPOST("search_categ_cus", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$billed = GETPOST('billed', 'int'); +$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); $search_status = GETPOST('search_status', 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); @@ -223,7 +223,7 @@ if (empty($reshook)) $search_project_ref = ''; $search_project = ''; $search_status = ''; - $billed = ''; + $search_billed = ''; $toselect = ''; $search_array_options = array(); $search_categ_cus = 0; @@ -308,7 +308,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc if ($search_ref) $sql .= natural_search('c.ref', $search_ref); if ($search_ref_customer) $sql .= natural_search('c.ref_client', $search_ref_customer); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($billed != '' && $billed >= 0) $sql .= ' AND c.facture = '.$billed; +if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND c.facture = '.$search_billed; if ($search_status <> '') { if ($search_status < 4 && $search_status > -3) @@ -467,7 +467,7 @@ if ($resql) if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); if ($show_files) $param .= '&show_files='.urlencode($show_files); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($billed != '') $param .= '&billed='.urlencode($billed); + if ($search_billed != '') $param .= '&search_billed='.urlencode($search_billed); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -758,7 +758,7 @@ if ($resql) } if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - // Amount + // Amount VAT print ''; @@ -820,7 +820,7 @@ if ($resql) if (!empty($arrayfields['c.facture']['checked'])) { print ''; } // Action column From 16bb33b619047b744c40c4f8f02e989afb568aa6 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 7 Sep 2020 14:29:36 +0200 Subject: [PATCH 015/173] Add missing translations for permissions --- htdocs/langs/en_US/admin.lang | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 36ee351e33d..09f99504c93 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -671,7 +671,7 @@ Module63000Name=Resources Module63000Desc=Manage resources (printers, cars, rooms, ...) for allocating to events Permission11=Read customer invoices Permission12=Create/modify customer invoices -Permission13=Unvalidate customer invoices +Permission13=Invalidate customer invoices Permission14=Validate customer invoices Permission15=Send customer invoices by email Permission16=Create payments for customer invoices @@ -688,6 +688,7 @@ Permission32=Create/modify products Permission34=Delete products Permission36=See/manage hidden products Permission38=Export products +Permission39=Ignore minimum price Permission41=Read projects and tasks (shared project and projects I'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet) Permission42=Create/modify projects (shared project and projects I'm contact for). Can also create tasks and assign users to project and tasks Permission44=Delete projects (shared project and projects I'm contact for) @@ -696,6 +697,9 @@ Permission61=Read interventions Permission62=Create/modify interventions Permission64=Delete interventions Permission67=Export interventions +Permission68=Send interventions by email +Permission69=Validate interventions +Permission70=Invalidate interventions Permission71=Read members Permission72=Create/modify members Permission74=Delete members @@ -718,6 +722,7 @@ Permission95=Read reports Permission101=Read sendings Permission102=Create/modify sendings Permission104=Validate sendings +Permission105=Send sendings by email Permission106=Export sendings Permission109=Delete sendings Permission111=Read financial accounts @@ -843,6 +848,9 @@ Permission561=Read payment orders by credit transfer Permission562=Create/modify payment order by credit transfer Permission563=Send/Transmit payment order by credit transfer Permission564=Record Debits/Rejections of credit transfer +Permission601=Read stickers +Permission602=Create/modify stickers +Permission609=Delete stickers Permission650=Read Bills of Materials Permission651=Create/Update Bills of Materials Permission652=Delete Bills of Materials @@ -884,7 +892,9 @@ Permission1185=Approve purchase orders Permission1186=Order purchase orders Permission1187=Acknowledge receipt of purchase orders Permission1188=Delete purchase orders +Permission1189=Check/Uncheck a supplier order reception Permission1190=Approve (second approval) purchase orders +Permission1191=Export supplier orders and their attributes Permission1201=Get result of an export Permission1202=Create/Modify an export Permission1231=Read vendor invoices @@ -898,6 +908,8 @@ Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments Permission1322=Reopen a paid bill Permission1421=Export sales orders and attributes +Permission1521=Read documents +Permission1522=Delete documents Permission2401=Read actions (events or tasks) linked to his user account (if owner of event or just assigned to) Permission2402=Create/modify actions (events or tasks) linked to his user account (if owner of event) Permission2403=Delete actions (events or tasks) linked to his user account (if owner of event) @@ -932,9 +944,13 @@ Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job Permission23003=Delete Scheduled job Permission23004=Execute Scheduled job -Permission50101=Use Point of Sale +Permission50101=Use Point of Sale (SimplePOS) +Permission50151=Use Point of Sale (TakePOS) Permission50201=Read transactions Permission50202=Import transactions +Permission50330=Read objects of Zapier +Permission50331=Create/Update objects of Zapier +Permission50332=Delete objects of Zapier Permission50401=Bind products and invoices with accounting accounts Permission50411=Read operations in ledger Permission50412=Write/Edit operations in ledger @@ -958,6 +974,14 @@ Permission63001=Read resources Permission63002=Create/modify resources Permission63003=Delete resources Permission63004=Link resources to agenda events +Permission64001=Allow direct printing +Permission67000=Allow printing of receipts +Permission941601=Read receipts +Permission941602=Create and modify receipts +Permission941603=Validate receipts +Permission941604=Send receipts by email +Permission941605=Export receipts +Permission941606=Delete receipts DictionaryCompanyType=Third-party types DictionaryCompanyJuridicalType=Third-party legal entities DictionaryProspectLevel=Prospect potential level for companies From c6cb179447df6e8a964d3e0d476a1250c051e95d Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Mon, 7 Sep 2020 15:43:36 +0200 Subject: [PATCH 016/173] Added filterable table columns --- htdocs/product/fournisseurs.php | 184 +++++++++++++++++++++----------- 1 file changed, 121 insertions(+), 63 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 77073763503..5a8b0fbeda7 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -858,6 +858,52 @@ SCRIPT; print_barre_liste($langs->trans('SupplierPrices'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit, 1); + // Definition of fields for lists + // Some fields are missing because they are not included in the database query + $arrayfields = array( + 'pfp.datec'=>array('label'=>$langs->trans("AppliedPricesFrom"), 'checked'=>1, 'position'=>1), + 's.nom'=>array('label'=>$langs->trans("Suppliers"), 'checked'=>1, 'position'=>2), + 'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => !empty($conf->global->FOURN_PRODUCT_AVAILABILITY), 'checked'=>0, 'position'=>4), + 'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5), + 'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9), + 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10), + 'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13), + 'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14), + 'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15), + 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>16), + 'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => !empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING), 'checked'=>0, 'position'=>17), + 'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => $conf->barcode->enabled, 'checked'=>1, 'position'=>18), + ); + + // fetch optionals attributes and labels + $extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + + if (!empty($extralabels)) { + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + else $extratitle = $langs->trans($value); + $arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position']+1)); + } + } + } + + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + // Suppliers list title print '
'; print '
' : ''; + + print is_array($headers) ? $langs->trans($headers[0]) : $headers; + + if($number > -1) + { + // extra space between the first header and the number + print ' '; + } + + if(!empty($internalLink)) + { + print ''; + } + + if($number > -1) + { + print ''.$number.''; + } + + if(!empty($internalLink)) + { + print ''; + } + + print '
'; + print print $langs->trans($header); + print '
'; print ''; print ''; - print $form->selectyesno('billed', $billed, 1, 0, 1); + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); print '
'; @@ -865,42 +911,37 @@ SCRIPT; $param = "&id=".$object->id; print ''; - print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['pfp.datec']['checked'])) print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.fk_availability']['checked'])) print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['pfp.quantity']['checked'])) print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if ($conf->multicurrency->enabled) { - print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); - if ($conf->multicurrency->enabled) { - print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); - } + if ($conf->multicurrency->enabled) print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.unitprice']['checked'])) print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + if ($conf->multicurrency->enabled) print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); - if ($conf->barcode->enabled) { - print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['pfp.barcode']['checked'])) print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['pfp.packaging']['checked'])) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['pfp.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right '); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + if (!empty($extralabels)) { foreach ($extralabels as $key => $value) { // Show field if not hidden if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - else $extratitle = $langs->trans($value); - print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + else $extratitle = $langs->trans($value); + if (!empty($arrayfields['ef.'.$key]['checked'])) print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right '); } } } @@ -910,7 +951,7 @@ SCRIPT; $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } - print_liste_field_titre(''); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; if (is_array($product_fourn_list)) @@ -920,10 +961,14 @@ SCRIPT; print ''; // Date from - print ''; + if (!empty($arrayfields['pfp.datec']['checked'])) { + print ''; + } // Supplier - print ''; + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } // Supplier ref if ($usercancreate) // change required right here @@ -934,7 +979,7 @@ SCRIPT; } // Availability - if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) + if (!empty($arrayfields['pfp.fk_availability']['checked'])) { $form->load_cache_availability(); $availability = $form->cache_availability[$productfourn->fk_availability]['label']; @@ -942,16 +987,18 @@ SCRIPT; } // Quantity - print ''; + if (!empty($arrayfields['pfp.quantity']['checked'])) { + print ''; + } // VAT rate print ''; + if (!empty($arrayfields['pfp.unitprice']['checked'])) { + print ''; + } - if ($conf->multicurrency->enabled) { - // Unit price in currency + // Unit price in currency + if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) { print ''; + print '';} - // Currency + // Currency + if ($conf->multicurrency->enabled) { print ''; @@ -994,24 +1044,30 @@ SCRIPT; print ''; // Delivery delay - print ''; + if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) { + print ''; + } // Reputation - print ''; } - print''; - if ($conf->barcode->enabled) { - // Barcode + // Barcode + if (!empty($arrayfields['pfp.barcode']['checked'])) { print ''; - - // Barcode type + print ''; + } + + // Barcode type + if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { print ''; } // Date - print ''; + if (!empty($arrayfields['pfp.tms']['checked'])) { + print ''; + } // Extrafields if (!empty($extralabels)) { @@ -1045,14 +1102,14 @@ SCRIPT; if ($resql) { if ($db->num_rows($resql) != 1) { foreach ($extralabels as $key => $value) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print ""; } } } else { $obj = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { print '"; } } @@ -1087,6 +1144,7 @@ SCRIPT; print '
'.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').''.dol_print_date(($productfourn->fourn_date_creation ? $productfourn->fourn_date_creation : $productfourn->date_creation), 'dayhour').''.$productfourn->getSocNomUrl(1, 'supplier').''.$productfourn->getSocNomUrl(1, 'supplier').''; - print $productfourn->fourn_qty; - // Units - if ($conf->global->PRODUCT_USE_UNITS) { - $unit = $object->getLabelOfUnit(); - if ($unit !== '') { - print '  '.$langs->trans($unit); - } - } - print ''; + print $productfourn->fourn_qty; + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $unit = $object->getLabelOfUnit(); + if ($unit !== '') { + print '  '.$langs->trans($unit); + } + } + print ''; @@ -971,18 +1018,21 @@ SCRIPT; } // Unit price - print ''; - print price($productfourn->fourn_unitprice); - //print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" "); - print ''; + print price($productfourn->fourn_unitprice); + //print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" "); + print ''; print price($productfourn->fourn_multicurrency_unitprice); - print ''; print $productfourn->fourn_multicurrency_code ? currency_name($productfourn->fourn_multicurrency_code) : ''; print ''; - print $productfourn->delivery_time_days; - print ''; + print $productfourn->delivery_time_days; + print ''; - if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) { - print $object->reputations[$productfourn->supplier_reputation]; + if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) { + print ''; + if (!empty($productfourn->supplier_reputation) && !empty($object->reputations[$productfourn->supplier_reputation])) { + print $object->reputations[$productfourn->supplier_reputation]; + } + print''; print $productfourn->barcode; - print ''; $productfourn->barcode_type = !empty($productfourn->fk_barcode_type) ? $productfourn->fk_barcode_type : 0; $productfourn->fetch_barcode(); @@ -1020,17 +1076,18 @@ SCRIPT; } // Packaging - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - { + if (!empty($arrayfields['pfp.packaging']['checked'])) { print ''; print price2num($productfourn->packaging); print ''; - print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour"); - print ''; + print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour"); + print ''.$extrafields->showOutputField($key, $obj->{$key})."
'; print '
'; + print ''; } } } From a9a95c8a839a3ace9e91b0632a48935faba86c43 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 7 Sep 2020 13:47:26 +0000 Subject: [PATCH 017/173] Fixing style errors. --- htdocs/product/fournisseurs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5a8b0fbeda7..6c6e4dbfd3a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -893,7 +893,7 @@ SCRIPT; // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -1065,7 +1065,7 @@ SCRIPT; print $productfourn->barcode; print ''; } - + // Barcode type if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { print ''; From 1dc84c571584dc314b8c398775b8e4e47daebca9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 7 Sep 2020 16:04:06 +0200 Subject: [PATCH 018/173] update docker to new standard --- build/docker/README.md | 1 + build/docker/docker-compose.yml | 3 +-- build/docker/docker-run.sh | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build/docker/README.md b/build/docker/README.md index 13b89567766..2fd278a531f 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -28,3 +28,4 @@ The URL to go to PhpMyAdmin is (login/password is root/root) : Setup the database connection during the installation process, please use mariad b (name of the database container) as database host. +Setup documents folder, during the installation process, to /var/documents diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 45a1a76d6fc..efdc95d2858 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -28,8 +28,7 @@ services: - external-pod web: - build: - context: . + build: . environment: HOST_USER_ID: $HOST_USER_ID volumes: diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh index cec7e138b4a..e57d9adfad0 100644 --- a/build/docker/docker-run.sh +++ b/build/docker/docker-run.sh @@ -1,11 +1,18 @@ #!/bin/bash -usermod -u "${HOST_USER_ID}" www-data -groupmod -g "${HOST_USER_ID}" www-data +usermod -u ${HOST_USER_ID} www-data +groupmod -g ${HOST_USER_ID} www-data chgrp -hR www-data /var/www/html chmod g+rwx /var/www/html/conf +if [ ! -d /var/documents ]; then + echo "[docker-run] => create volume directory /var/documents ..." + mkdir -p /var/documents +fi +echo "[docker-run] => Set Permission to www-data for /var/documents" +chown -R www-data:www-data /var/documents + if [ ! -f /usr/local/etc/php/php.ini ]; then cat < /usr/local/etc/php/php.ini date.timezone = $PHP_INI_DATE_TIMEZONE From ca32a93c0b555f767c32262d8527beb4242d4719 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 7 Sep 2020 22:03:41 +0200 Subject: [PATCH 019/173] NEW Link on balance to bookkeeping --- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/class/accountingaccount.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 059e1eb57b1..358fdc36a2a 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -290,7 +290,7 @@ if ($action != 'export_csv') { $accountingaccountstatic->fetch(null, $line->numero_compte, true); if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); } else { $accounting_account = length_accountg($line->numero_compte); } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 7cb30a74bc6..aee1c4c2f29 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -460,7 +460,7 @@ class AccountingAccount extends CommonObject $result = ''; - if (empty($option)) { + if (empty($option) || $option == 'bookkeeping') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; } elseif ($option == 'bookkeepinglistbyaccount') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; From 939933f4f7fbaedf0a785e14c6cefeaee72c7231 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Sep 2020 04:24:18 +0200 Subject: [PATCH 020/173] Add some language key --- htdocs/accountancy/bookkeeping/balance.php | 4 ++-- htdocs/accountancy/class/accountingaccount.class.php | 7 +++++-- htdocs/langs/en_US/accountancy.lang | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 358fdc36a2a..b06a3ffc63a 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -252,8 +252,8 @@ if ($action != 'export_csv') print $langs->trans('to'); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); + print ''; + $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index aee1c4c2f29..6936d7499fa 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -462,10 +462,13 @@ class AccountingAccount extends CommonObject if (empty($option) || $option == 'bookkeeping') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $labelurl = $langs->trans("ShowAccountingAccountInBookKeeping"); } elseif ($option == 'bookkeepinglistbyaccount') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $labelurl = $langs->trans("ShowAccountingAccountInBookKeepingByAccount"); } elseif ($option == 'accountcard') { $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + $labelurl = $langs->trans("ShowAccountingAccount"); } // Add param to save lastsearch_values or not @@ -483,7 +486,7 @@ class AccountingAccount extends CommonObject $labeltoshow = $this->labelshort; } - $label = ''.$langs->trans("ShowAccountingAccount").''; + $label = ''.$labelurl.''; if (!empty($this->account_number)) $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); if (!empty($labeltoshow)) @@ -495,7 +498,7 @@ class AccountingAccount extends CommonObject { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowAccountingAccount"); + $label = $labelurl; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 29a857c914b..6fb2a152d8f 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -89,6 +89,8 @@ SubledgerAccount=Subledger account SubledgerAccountLabel=Subledger account label ShowAccountingAccount=Show accounting account ShowAccountingJournal=Show accounting journal +ShowAccountingAccountInBookKeeping=Show accounting account in ledger +ShowAccountingAccountInBookKeepingByAccount=Show accounting account in ledger by account AccountAccountingSuggest=Accounting account suggested MenuDefaultAccounts=Default accounts MenuBankAccounts=Bank accounts From a050ee8385f2951c5616dbf29ea8b77ccbcfa889 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Sep 2020 04:24:27 +0200 Subject: [PATCH 021/173] Typo --- htdocs/core/class/html.form.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c6ebb7511bb..5f5a7bcf0ff 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7538,11 +7538,11 @@ class Form } /** - * Return HTML to show the search and clear seach button + * Return HTML to show the search and clear search button * * @param string $cssclass CSS class * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes - * @param string $massactionname Mass action button name that will launch an action on the selected items + * @param string $massactionname Mass action button name that will launch an action on the selected items * @return string */ public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0, $massactionname = "massaction") @@ -7610,7 +7610,7 @@ class Form */ public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) { - global $db, $conf, $langs, $user; + global $db, $langs, $user; $out = ''; $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; @@ -7930,7 +7930,7 @@ class Form */ public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array()) { - global $conf, $langs; + global $langs; $ret = ''; From a4c581b34d402e29ef6f542376e84b57af788f28 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Sep 2020 04:44:04 +0200 Subject: [PATCH 022/173] Modify link on chart of accounts --- htdocs/accountancy/admin/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index f6a4adac21e..e6264648159 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -390,7 +390,7 @@ if ($resql) if (!empty($arrayfields['aa.account_number']['checked'])) { print ""; - print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); + print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard'); print "\n"; if (!$i) $totalarray['nbfield']++; } From df7ca14b2c770308d8b833ed1b54388034ed91ec Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Sep 2020 04:58:25 +0200 Subject: [PATCH 023/173] Security access --- htdocs/accountancy/admin/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index bc695da0203..4ad131f5170 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -44,6 +44,8 @@ $cancel = GETPOST('cancel', 'alpha'); $accountingaccount = GETPOST('accountingaccount', 'alpha'); // Security check +if ($user->socid > 0) accessforbidden(); +if (!$user->rights->accounting->chartofaccount) accessforbidden(); $object = new AccountingAccount($db); From 6a04f39fbef46085b48e424ac03377fc6e9951dd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 8 Sep 2020 04:58:42 +0200 Subject: [PATCH 024/173] Wrong language key --- htdocs/core/lib/accounting.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 16b124443da..f2d1f6a2763 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -56,7 +56,7 @@ function accounting_prepare_head(AccountingAccount $object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("Asset"); + $head[$h][1] = $langs->trans("AccountAccounting"); $head[$h][2] = 'card'; $h++; From 650bb54051a9c516c4b25b7350d9faaffadcd4b7 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 8 Sep 2020 10:07:34 +0200 Subject: [PATCH 025/173] add common list function for module overview --- htdocs/admin/system/modules.php | 344 +++++++++++++++++++++++++++----- 1 file changed, 293 insertions(+), 51 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 1e5de3b9a46..bba227f9acc 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -25,32 +25,64 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -// Load translation files required by the page -$langs->loadLangs(array("install", "other", "admin")); - if (!$user->admin) accessforbidden(); +// Load translation files required by the page +$langs->loadLangs(array("install", "other", "admin")); + +$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; + +$search_name = GETPOST("search_name", 'alpha'); +$search_id = GETPOST("search_id", 'alpha'); +$search_version = GETPOST("search_version", 'alpha'); +$search_permission = GETPOST("search_permission", 'alpha'); + +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); + +if (!$sortfield) $sortfield = "id"; +if (!$sortorder) $sortorder = "asc"; + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('moduleoverview')); +$form = new Form($db); +$object = new stdClass(); + +// Definition of fields for lists +$arrayfields = array( + 'name'=>array('label'=>$langs->trans("Modules"), 'checked'=>1, 'position'=>10), + 'version'=>array('label'=>$langs->trans("Version"), 'checked'=>1, 'position'=>20), + 'id'=>array('label'=>$langs->trans("IdModule"), 'checked'=>1, 'position'=>30), + 'permission'=>array('label'=>$langs->trans("IdPermissions"), 'checked'=>1, 'position'=>40) +); + +$arrayfields = dol_sort_array($arrayfields, 'position'); /* - * View + * Actions */ -llxHeader(); +$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'); -print load_fiche_titre($langs->trans("AvailableModules"), '', 'title_setup'); +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +} -print ''.$langs->trans("ToActivateModule").'
'; -print "
\n"; +// Load list of modules +$moduleList = array(); $modules = array(); -$modules_names = array(); $modules_files = array(); $modules_fullpath = array(); $modulesdir = dolGetModulesDirs(); +$rights_ids = array(); -// Load list of modules -$i = 0; foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); @@ -69,7 +101,9 @@ foreach ($modulesdir as $dir) { // File duplicate print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")
"; - } else { + } + else + { // File to load $res = include_once $dir.$file; if (class_exists($modName)) @@ -78,15 +112,16 @@ foreach ($modulesdir as $dir) $objMod = new $modName($db); $modules[$objMod->numero] = $objMod; - $modules_names[$objMod->numero] = $objMod->name; $modules_files[$objMod->numero] = $file; $modules_fullpath[$file] = $dir.$file; - $picto[$objMod->numero] = (isset($objMod->picto) && $objMod->picto) ? $objMod->picto : 'generic'; - } catch (Exception $e) + } + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } - } else { + } + else + { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } @@ -97,60 +132,267 @@ foreach ($modulesdir as $dir) } } -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -$var = false; -$sortorder = $modules_names; -ksort($sortorder); -$rights_ids = array(); -foreach ($sortorder as $numero=>$name) +// create pre-filtered list for modules +foreach ($modules as $key=>$module) { - $idperms = ""; - // Module - print '"; - // Version - print ''; - // Id - print ''; - // Permissions - if ($modules[$numero]->rights) + else { - foreach ($modules[$numero]->rights as $rights) + $newModule->picto = img_object($alt, 'generic', 'width="14px"'); + } + + $permission = array(); + if ($module->rights) + { + foreach ($module->rights as $rights) { - $idperms .= ($idperms ? ", " : "").$rights[0]; + if (empty($rights[0])) + { + continue; + } + + $permission[] = $rights[0]; + array_push($rights_ids, $rights[0]); } } - print ''; - print "\n"; + + $newModule->permission = $permission; + + // pre-filter list + if($search_name && !stristr($newModule->name, $search_name)) continue; + if($search_version && !stristr($newModule->version, $search_version)) continue; + if($search_id && !stristr($newModule->id, $search_id)) continue; + + if($search_permission) + { + $found = false; + + foreach($newModule->permission as $permission) + { + if(stristr($permission, $search_permission)) + { + $found = true; + break; + } + } + + if(!$found) continue; + } + + $moduleList[] = $newModule; } + + + +/* + * View + */ + +llxHeader(); + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans("AvailableModules"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $massactionbutton, -1, '', 'title_setup', 0, '', '', 0, 1, 1); + +print ''.$langs->trans("ToActivateModule").''; +print '
'; +print '
'; + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print '
'; +print '
'.$langs->trans("Modules").''.$langs->trans("Version").''.$langs->trans("IdModule").''.$langs->trans("IdPermissions").'
'; - $alt = $name.' - '.$modules_files[$numero]; - if (!empty($picto[$numero])) + $newModule = new stdClass(); + + $newModule->name = $module->getName(); + $newModule->version = $module->getVersion(); + $newModule->id = $key; + + $alt = $module->name.' - '.$modules_files[$key]; + + if (!empty($module->picto)) { - if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1); - else print img_object($alt, $picto[$numero], 'width="14px"'); - } else { - print img_object($alt, $picto[$numero], 'width="14px"'); + if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1); + else $newModule->picto = img_object($alt, $module->picto, 'width="14px"'); } - print ' '.$modules[$numero]->getName(); - print "'.$modules[$numero]->getVersion().''.$numero.''.($idperms ? $idperms : " ").'
'; + +// Lines with input filters +print ''; + +if($arrayfields['name']['checked']) +{ + print ''; +} +if($arrayfields['version']['checked']) +{ + print ''; +} +if($arrayfields['id']['checked']) +{ + print ''; +} +if($arrayfields['permission']['checked']) +{ + print ''; +} + +print ''; + +print ''; + +print ''; + +if($arrayfields['name']['checked']) +{ + print_liste_field_titre($arrayfields['name']['label'], $_SERVER["PHP_SELF"], "name", "", "", "", $sortfield, $sortorder); +} +if($arrayfields['version']['checked']) +{ + print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder); +} +if($arrayfields['id']['checked']) +{ + print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder); +} +if($arrayfields['permission']['checked']) +{ + print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder); +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print ''; + +// sort list +if($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); +if($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); +if($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); +if($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); +if($sortfield == "id" && $sortorder == "asc") usort($moduleList, "sortIdAsc"); +if($sortfield == "id" && $sortorder == "desc") usort($moduleList, "sortIdDesc"); +if($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "sortPermissionIdsAsc"); +if($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "sortPermissionIdsDesc"); + +foreach ($moduleList as $module) +{ + print ''; + + if($arrayfields['name']['checked']) + { + print '"; + } + + if($arrayfields['version']['checked']) + { + print ''; + } + + if($arrayfields['id']['checked']) + { + print ''; + } + + if($arrayfields['permission']['checked']) + { + $idperms = ''; + foreach ($module->permission as $permission) + { + $idperms .= ($idperms ? ", " : "").$permission; + + $translationKey = "Permission".$permission; + if(empty($langs->tab_translate[$translationKey])) + { + $tooltip = 'Missing translation (key '.$translation.' not found in admin.lang)'; + $idperms .= ' Warning'; + } + } + + print ''; + } + + print ''; + print ''; +} + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; + print $module->picto; + print ' '.$module->name; + print "'.$module->version.''.$module->id.''.($idperms ? $idperms : " ").'
'; print '
'; +print ''; print '
'; + sort($rights_ids); $old = ''; + foreach ($rights_ids as $right_id) { - if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."
"; + if ($old == $right_id) + { + print "Warning duplicate id on permission : ".$right_id."
"; + } + $old = $right_id; } // End of page llxFooter(); $db->close(); + + +/* + * user-defined sort functions + */ + +function sortIdAsc(stdClass $a, stdClass $b) +{ + return $a->id > $b->id ? -1 : 1; +} + +function sortIdDesc(stdClass $a, stdClass $b) +{ + return $b->id > $a->id ? -1 : 1; +} + +function sortPermissionIdsAsc(stdClass $a, stdClass $b) +{ + if (empty($a->permission) && empty($b->permission)) return sortIdAsc($a, $b); + + if (empty($a->permission)) return 1; + if (empty($b->permission)) return -1; + + return $a->permission[0] > $b->permission[0] ? -1 : 1; +} + +function sortPermissionIdsDesc(stdClass $a, stdClass $b) +{ + if (empty($a->permission) && empty($b->permission)) return sortIdDesc($a, $b); + + if (empty($a->permission)) return -1; + if (empty($b->permission)) return 1; + + return $a->permission[0] > $b->permission[0] ? 1 : -1; +} From 387dcd2fa2946ed3ecca5913165c8113f7290578 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 8 Sep 2020 10:10:45 +0200 Subject: [PATCH 026/173] FIX error on update invoice line --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 20f705a8ed9..b6ce513e8c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5160,7 +5160,7 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql .= " description='".$this->db->escape($this->desc)."'"; - $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; + $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", remise_percent=".price2num($this->remise_percent).""; From 2569c792e768365d60db59826b69bcf8eb125084 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Sep 2020 08:13:56 +0000 Subject: [PATCH 027/173] Fixing style errors. --- htdocs/admin/system/modules.php | 81 +++++++++++++++++---------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index bba227f9acc..7181b35f858 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -32,7 +32,7 @@ if (!$user->admin) $langs->loadLangs(array("install", "other", "admin")); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; $search_name = GETPOST("search_name", 'alpha'); $search_id = GETPOST("search_id", 'alpha'); @@ -102,8 +102,7 @@ foreach ($modulesdir as $dir) // File duplicate print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")
"; } - else - { + else { // File to load $res = include_once $dir.$file; if (class_exists($modName)) @@ -120,8 +119,7 @@ foreach ($modulesdir as $dir) dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } - else - { + else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } @@ -140,16 +138,15 @@ foreach ($modules as $key=>$module) $newModule->name = $module->getName(); $newModule->version = $module->getVersion(); $newModule->id = $key; - + $alt = $module->name.' - '.$modules_files[$key]; - + if (!empty($module->picto)) { if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1); else $newModule->picto = img_object($alt, $module->picto, 'width="14px"'); } - else - { + else { $newModule->picto = img_object($alt, 'generic', 'width="14px"'); } @@ -172,24 +169,24 @@ foreach ($modules as $key=>$module) $newModule->permission = $permission; // pre-filter list - if($search_name && !stristr($newModule->name, $search_name)) continue; - if($search_version && !stristr($newModule->version, $search_version)) continue; - if($search_id && !stristr($newModule->id, $search_id)) continue; + if ($search_name && !stristr($newModule->name, $search_name)) continue; + if ($search_version && !stristr($newModule->version, $search_version)) continue; + if ($search_id && !stristr($newModule->id, $search_id)) continue; - if($search_permission) + if ($search_permission) { $found = false; - foreach($newModule->permission as $permission) + foreach ($newModule->permission as $permission) { - if(stristr($permission, $search_permission)) + if (stristr($permission, $search_permission)) { $found = true; break; } } - if(!$found) continue; + if (!$found) continue; } $moduleList[] = $newModule; @@ -227,25 +224,25 @@ print ''; // Lines with input filters print ''; -if($arrayfields['name']['checked']) +if ($arrayfields['name']['checked']) { print ''; } -if($arrayfields['version']['checked']) +if ($arrayfields['version']['checked']) { print ''; } -if($arrayfields['id']['checked']) +if ($arrayfields['id']['checked']) { print ''; } -if($arrayfields['permission']['checked']) +if ($arrayfields['permission']['checked']) { print ''; print ''; -if($arrayfields['name']['checked']) +if ($arrayfields['name']['checked']) { print_liste_field_titre($arrayfields['name']['label'], $_SERVER["PHP_SELF"], "name", "", "", "", $sortfield, $sortorder); } -if($arrayfields['version']['checked']) +if ($arrayfields['version']['checked']) { print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder); } -if($arrayfields['id']['checked']) +if ($arrayfields['id']['checked']) { print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder); } -if($arrayfields['permission']['checked']) +if ($arrayfields['permission']['checked']) { print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder); } @@ -287,46 +284,50 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); -if($sortfield == "id" && $sortorder == "asc") usort($moduleList, "sortIdAsc"); -if($sortfield == "id" && $sortorder == "desc") usort($moduleList, "sortIdDesc"); -if($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "sortPermissionIdsAsc"); -if($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "sortPermissionIdsDesc"); +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { + return strcasecmp($a->name, $b->name); }); +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { + return strcasecmp($b->name, $a->name); }); +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { + return strcasecmp($a->version, $b->version); }); +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { + return strcasecmp($b->version, $a->version); }); +if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "sortIdAsc"); +if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "sortIdDesc"); +if ($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "sortPermissionIdsAsc"); +if ($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "sortPermissionIdsDesc"); foreach ($moduleList as $module) { print ''; - if($arrayfields['name']['checked']) + if ($arrayfields['name']['checked']) { print '"; } - - if($arrayfields['version']['checked']) + + if ($arrayfields['version']['checked']) { print ''; } - if($arrayfields['id']['checked']) + if ($arrayfields['id']['checked']) { print ''; } - if($arrayfields['permission']['checked']) + if ($arrayfields['permission']['checked']) { $idperms = ''; foreach ($module->permission as $permission) { $idperms .= ($idperms ? ", " : "").$permission; - + $translationKey = "Permission".$permission; - if(empty($langs->tab_translate[$translationKey])) + if (empty($langs->tab_translate[$translationKey])) { $tooltip = 'Missing translation (key '.$translation.' not found in admin.lang)'; $idperms .= ' Warning'; @@ -374,7 +375,7 @@ function sortIdAsc(stdClass $a, stdClass $b) function sortIdDesc(stdClass $a, stdClass $b) { - return $b->id > $a->id ? -1 : 1; + return $b->id > $a->id ? -1 : 1; } function sortPermissionIdsAsc(stdClass $a, stdClass $b) From bd96e0fe421c5db7cc27383ecda20c1a4a79c245 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 8 Sep 2020 11:15:33 +0200 Subject: [PATCH 028/173] finished helper method and usage of it --- htdocs/comm/index.php | 51 ++++++++++++++--------------- htdocs/core/lib/functions.lib.php | 54 +++++++++++++++++++------------ 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 56e5071a250..511fb606a4e 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -168,7 +169,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["ProposalsDraft"], 2, $num, "comm/propal/list.php","search_status=0"); + StartSimpleTableHeader("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -250,7 +251,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["SupplierProposalsDraft"], 2, $num, "supplier_proposal/list.php","search_status=0"); + StartSimpleTableHeader("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -329,7 +330,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftOrders"], 2, $num, "commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftOrders", "commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -413,7 +414,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $total = 0; $num = $db->num_rows($resql); - StartSimpleTableHeader(["DraftSuppliersOrders"], 2, $num, "fourn/commande/list.php","search_status=0"); + StartSimpleTableHeader("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); if ($num > 0) { @@ -503,16 +504,19 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $num = $db->num_rows($resql); $i = 0; - print '
'; - print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -261,19 +258,19 @@ print '
'; print $module->picto; print ' '.$module->name; print "'.$module->version.''.$module->id.'
'; - print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastCustomersOrProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + else + { + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); + } + if ($num) { while ($i < $num) @@ -570,12 +574,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $num = $db->num_rows($result); $i = 0; - print '
'; - print '
'; - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects", $max); - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects", $max); - else print $langs->trans("BoxTitleLastModifiedCustomers", $max); - print ''.$langs->trans("FullList").'
'; - print ''; - print ''; - print ''; - print ''; + StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + if ($num) { while ($i < $num && $i < $max) @@ -650,12 +650,11 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD if ($resql) { $num = $db->num_rows($resql); - + if ($num > 0) { - print '
'; - print '
'.$langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)).''.$langs->trans("FullList").'
'; - print ''; + StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); + $i = 0; $staticcontrat = new Contrat($db); @@ -715,7 +714,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["ProposalsOpened"], 4, $num, "comm/propal/list.php","search_status=1"); + StartSimpleTableHeader("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -817,7 +816,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - StartSimpleTableHeader(["OrdersOpened"], 4, $num, "commande/list.php","search_status=1"); + StartSimpleTableHeader("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7feb9aa8655..2bc5d8eea53 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8675,58 +8675,70 @@ function currentToken() * Start a table with headers and a optinal clickable number * (don't forget to close the table with a HTML TABLE and a HTML DIV element) * - * @param string|array $headers The header(s) of the table (headers inside a array are automatic translated) - * @param integer $emptyRows (optional) The count of empty rows after the first header (use this instead of empty headers) - * @param integer $number (optional) The number that is shown right after the first header - * @param string $internalLink (optional) The link to a internal dolibarr page, when click on the number (without the first "/") - * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @param string $header The first left header of the table (automatic translated) + * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") + * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") + * @param integer $emptyRows (optional) The count of empty rows after the first header + * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" * @return void */ -function StartSimpleTableHeader($headers, $emptyRows = 0, $number = -1, $internalLink = "", $arguments = "") +function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) { global $langs; print '
'; print '
'.$langs->trans("LastContracts", 5).'
'; print ''; - + print $emptyRows < 1 ? ''; - if(!is_array($headers) || count($headers) < 2) + if ($number < 0 && !empty($link)) { - print ''; - return; - } + print ''; } From 413bb10913385262755795efae418e8041844330 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Sep 2020 09:22:02 +0000 Subject: [PATCH 029/173] Fixing style errors. --- htdocs/comm/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 511fb606a4e..e28f0c397e7 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -512,8 +512,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); } - else - { + else { StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); } @@ -650,7 +649,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD if ($resql) { $num = $db->num_rows($resql); - + if ($num > 0) { StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); From a15de8467c07208eca8c479949e7d5ab3fcb0bc7 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Tue, 8 Sep 2020 11:25:21 +0200 Subject: [PATCH 030/173] fix wrong placed close table tag --- htdocs/expedition/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 2a4e92d28d6..eafb787c245 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -234,6 +234,7 @@ if ($resql) print '
'; print '
' : ''; - print is_array($headers) ? $langs->trans($headers[0]) : $headers; + print $langs->trans($header); - if($number > -1) + if ($number > -1) { // extra space between the first header and the number print ' '; } - if(!empty($internalLink)) + if (!empty($link)) { - print ''; + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } } - if($number > -1) + if ($number > -1) { print ''.$number.''; } - if(!empty($internalLink)) + if (!empty($link)) { print ''; } print '
'; - foreach(array_slice($headers, 1) as $header) - { - print ''; - print print $langs->trans($header); + if (!empty($arguments)) + { + print ''; + } + else + { + print ''; + } + + print $langs->trans("FullList"); + print ''; print '
'; + print ''; print ''; } - print "
'.$langs->trans("OrdersToProcess").' '; print ''; @@ -279,10 +280,12 @@ if ($resql) print '

"; } else { print ''.$langs->trans("None").''; } + + print "
"; + } else dol_print_error($db); From d6206b49df011669788e5373d4ceac6e5c56b7eb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Sep 2020 09:26:39 +0000 Subject: [PATCH 031/173] Fixing style errors. --- htdocs/expedition/index.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index eafb787c245..e2742f078bb 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -279,13 +279,11 @@ if ($resql) print ''; print ''; } - } else { print ''.$langs->trans("None").''; } print "
"; - } else dol_print_error($db); From 86ed4dfa2be91b5f61e3bf05664996aa44d581d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Sep 2020 11:51:36 +0200 Subject: [PATCH 032/173] Debug hidden option MAIN_USE_EXPENSE_IK --- ChangeLog | 2 + htdocs/admin/expensereport_ik.php | 43 ++++++++------- htdocs/admin/expensereport_rules.php | 18 +++--- htdocs/core/class/coreobject.class.php | 4 +- htdocs/core/class/html.form.class.php | 7 ++- htdocs/core/lib/date.lib.php | 17 ------ htdocs/core/lib/expensereport.lib.php | 16 +++--- htdocs/expensereport/card.php | 55 +++++++++++-------- .../install/mysql/migration/12.0.0-13.0.0.sql | 2 + .../mysql/tables/llx_expensereport_ik.sql | 2 +- htdocs/langs/en_US/admin.lang | 1 - htdocs/langs/en_US/trips.lang | 2 +- test/phpunit/DateLibTest.php | 23 -------- 13 files changed, 86 insertions(+), 106 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa82859a5b8..9653e4577cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ Following changes may create regressions for some external modules, but were nec * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id * The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in your email templates. +* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom + days of holiday. ***** ChangeLog for 12.0.2 compared to 12.0.1 ***** FIX: computation of the bottom margin of returns NaN because body is not loaded yet diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index ebdc1f7ed59..840cf4d2681 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -35,13 +35,11 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); if (!$user->admin) accessforbidden(); -//Init error -$error = false; -$message = false; +$error = 0; $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); -$offset = GETPOST('offset', 'int'); +$ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); @@ -59,10 +57,13 @@ if ($action == 'updateik') $expIk->setValues($_POST); $result = $expIk->create($user); - if ($result > 0) setEventMessages('SetupSaved', null, 'mesgs'); - - header('Location: '.$_SERVER['PHP_SELF']); - exit; + if ($result > 0) { + setEventMessages('SetupSaved', null, 'mesgs'); + header('Location: '.$_SERVER['PHP_SELF']); + exit; + } else { + setEventMessages($expIk->error, $expIk->errors, 'errors'); + } } elseif ($action == 'delete') // TODO add confirm { $expIk = new ExpenseReportIk($db); @@ -81,6 +82,7 @@ if ($action == 'updateik') $rangesbycateg = ExpenseReportIk::getAllRanges(); + /* * View */ @@ -90,12 +92,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); -echo $langs->trans('ExpenseReportIkDesc'); +echo ''.$langs->trans('ExpenseReportIkDesc').''; +print '

'; echo '
'; @@ -136,21 +139,23 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; // Label - echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; + echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; // Offset - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; - else echo $range->ik->offset; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + else { + echo $range->ik->ikoffset; + } echo ''; // Coef - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); echo ''; // Total for one - echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->offset + 5 * $range->ik->coef)).''; + echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).''; // Action echo ''; @@ -161,8 +166,8 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; } else { - echo ''.img_edit().''; - if (!empty($range->ik->id)) echo ''.img_delete().''; + echo ''.img_edit().''; + if (!empty($range->ik->id)) echo ''.img_delete().''; // TODO add delete link } } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 337311b85e7..28d5b3341b1 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -138,6 +138,7 @@ $rules = ExpenseReportRule::getAllRule(); $tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User')); $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense')); + /* * View */ @@ -147,12 +148,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); -echo $langs->trans('ExpenseReportRulesDesc'); +echo ''.$langs->trans('ExpenseReportRulesDesc').''; +print '

'; if ($action != 'edit') { @@ -164,7 +166,7 @@ if ($action != 'edit') echo ''; echo ''.$langs->trans('ExpenseReportApplyTo').''; - echo ''.$langs->trans('ExpenseReportDomain').''; + echo ''.$langs->trans('Type').''; echo ''.$langs->trans('ExpenseReportLimitOn').''; echo ''.$langs->trans('ExpenseReportDateStart').''; echo ''.$langs->trans('ExpenseReportDateEnd').''; @@ -184,7 +186,7 @@ if ($action != 'edit') 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 ''.$conf->currency.''; + echo ' '.$conf->currency.''; echo ''.$form->selectyesno('restrictive', 0, 1).''; echo ''; echo ''; @@ -207,7 +209,7 @@ echo ''; echo ''; echo ''; -echo ''; +echo ''; echo ''; echo ''; echo ''; @@ -300,11 +302,11 @@ foreach ($rules as $rule) echo ''; - echo ''; } - if ($object->fk_statut == 6) + if ($object->fk_statut == $object::STATUS_CLOSED) { /* TODO this fields are not yet filled print ''; @@ -2029,8 +2029,8 @@ if ($action == 'create') //print ''; print ''; if (!empty($conf->projet->enabled)) print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; print ''; @@ -2080,6 +2080,13 @@ if ($action == 'create') } print ''; } + + // Type of fee + print ''; + // IK if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { @@ -2087,11 +2094,7 @@ if ($action == 'create') print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); print ''; } - // Type of fee - print ''; + // Comment print ''; // VAT rate @@ -2285,6 +2288,11 @@ if ($action == 'create') print ''; } + // Select type + print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } - // Select type - print ''; - // Add comments print ''; print ''; print ''; - if (!empty($conf->projet->enabled)) print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; + if (!empty($conf->projet->enabled)) { + print ''; + } print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } print ''; print ''; print ''; @@ -2440,19 +2447,19 @@ if ($action == 'create') print ''; } - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) - { - print ''; - } - // Select type print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) + { + print ''; + } + // Add comments print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) @@ -2449,7 +2449,7 @@ if ($action == 'create') // Select type print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e2ea2b377a4..90f063e8ae0 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2774,12 +2774,14 @@ function select_type_fees_id($selected = '', $htmlname = 'type', $showempty = 0, global $db, $langs, $user; $langs->load("trips"); - print ''; if ($showempty) { - print ''; + $out .= ''; print ''; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; } else { print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } print ''; @@ -310,12 +310,12 @@ print ''; print ''; if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; } else { print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } print ''; @@ -387,7 +387,7 @@ foreach ($list_binding as $key) } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0)); - } else { + } else { print ''; } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index b7027282281..7790271f842 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -140,48 +140,48 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg = ''; + $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; - if (!empty($mesCasesCochees)) { - $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; - $msg .= '
'; - $cpt = 0; - $ok = 0; - $ko = 0; + //print '
' . $langs->trans("Processing") . '...
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; + $cpt = 0; + $ok = 0; + $ko = 0; - foreach ($mesCasesCochees as $maLigneCochee) { - $maLigneCourante = explode("_", $maLigneCochee); - $monId = $maLigneCourante[0]; - $monCompte = GETPOST('codeventil'.$monId); + foreach ($mesCasesCochees as $maLigneCochee) { + $maLigneCourante = explode("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monCompte = GETPOST('codeventil'.$monId); - if ($monCompte <= 0) - { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; - $ko++; - } else { - $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sql .= " SET fk_code_ventilation = ".$monCompte; - $sql .= " WHERE rowid = ".$monId; + if ($monCompte <= 0) + { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $ko++; + } else { + $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; - $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); - dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); - if ($db->query($sql)) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; - $ok++; - } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; - $ko++; - } - } + dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $ok++; + } else { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $ko++; + } + } - $cpt++; - } - $msg .= '
'; - $msg .= '
'.$langs->trans("EndProcessing").'
'; - } + $cpt++; + } + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; + } } @@ -199,8 +199,8 @@ if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -236,28 +236,28 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("l.rowid", $search_lineid, 1); + $sql .= natural_search("l.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { - $sql .= natural_search("f.ref", $search_invoice); + $sql .= natural_search("f.ref", $search_invoice); } if (strlen(trim($search_ref))) { - $sql .= natural_search("p.ref", $search_ref); + $sql .= natural_search("p.ref", $search_ref); } if (strlen(trim($search_label))) { - $sql .= natural_search("p.label", $search_label); + $sql .= natural_search("p.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= natural_search("l.description", $search_desc); + $sql .= natural_search("l.description", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= natural_search("l.total_ht", $search_amount, 1); + $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { @@ -295,13 +295,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -336,9 +336,9 @@ if ($result) { if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); $arrayofmassactions = array( - 'ventil'=>$langs->trans("Ventilate") - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + 'ventil'=>$langs->trans("Ventilate") + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -376,8 +376,8 @@ if ($result) { print ''; print ''; @@ -425,7 +425,7 @@ if ($result) { $isSellerInEEC = isInEEC($mysoc); - $accountingaccount_codetotid_cache = array(); + $accountingaccount_codetotid_cache = array(); while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); @@ -464,29 +464,29 @@ if ($result) { $code_sell_p_notset = ''; $objp->aarowid_suggest = ''; // Will be set later - $isBuyerInEEC = isInEEC($objp); + $isBuyerInEEC = isInEEC($objp); - // Search suggested default account for product/service - $suggestedaccountingaccountbydefaultfor = ''; - if ($objp->type_l == 1) { - if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = ''; - } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT + // Search suggested default account for product/service + $suggestedaccountingaccountbydefaultfor = ''; + if ($objp->type_l == 1) { + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'export'; - } - } + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { // Foreign sale + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } } elseif ($objp->type_l == 0) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); @@ -512,28 +512,28 @@ if ($result) { // Search suggested account for product/service (similar code exists in page index.php to make automatic binding) $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = ''; - } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT $objp->code_sell_p = $objp->code_sell; $objp->aarowid_suggest = $objp->aarowid; $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? - $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? + $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_p = $objp->code_sell_intra; - $objp->aarowid_suggest = $objp->aarowid_intra; - $suggestedaccountingaccountfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_p = $objp->code_sell_export; - $objp->aarowid_suggest = $objp->aarowid_export; - $suggestedaccountingaccountfor = 'export'; - } - } + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } if (!empty($objp->code_sell_p)) { // Value was defined previously @@ -585,32 +585,32 @@ if ($result) { print ''; // Country - print ''; + print ''; print ''; // Found accounts print ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 6135a213115..4fdc29b2c0f 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -264,7 +264,7 @@ if ($result) { print ''; print ''; print ''; - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; } print ''; // Date validation - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; } diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 0a5bef0c57e..76d13b99805 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -303,7 +303,7 @@ if ($result) { print ''; print ''; print ''; - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; } print ''; // Date validation - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print ''; } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 53c987e0189..9e0b64160e1 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -144,48 +144,48 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg = ''; + $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; - if (!empty($mesCasesCochees)) { - $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; - $msg .= '
'; - $cpt = 0; - $ok = 0; - $ko = 0; + //print '
' . $langs->trans("Processing") . '...
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; + $cpt = 0; + $ok = 0; + $ko = 0; - foreach ($mesCasesCochees as $maLigneCochee) { - $maLigneCourante = explode("_", $maLigneCochee); - $monId = $maLigneCourante[0]; - $monCompte = GETPOST('codeventil'.$monId); + foreach ($mesCasesCochees as $maLigneCochee) { + $maLigneCourante = explode("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monCompte = GETPOST('codeventil'.$monId); - if ($monCompte <= 0) - { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; - $ko++; - } else { - $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " SET fk_code_ventilation = ".$monCompte; - $sql .= " WHERE rowid = ".$monId; + if ($monCompte <= 0) + { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $ko++; + } else { + $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; - $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); - if ($db->query($sql)) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; - $ok++; - } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; - $ko++; - } - } + dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $ok++; + } else { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $ko++; + } + } - $cpt++; - } - $msg .= '
'; - $msg .= '
'.$langs->trans("EndProcessing").'
'; - } + $cpt++; + } + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; + } } @@ -203,8 +203,8 @@ if (empty($chartaccountcode)) { print $langs->trans("ErrorChartOfAccountSystemNotSelected"); // End of page - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); exit; } @@ -240,28 +240,28 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_lineid) { - $sql .= natural_search("l.rowid", $search_lineid, 1); + $sql .= natural_search("l.rowid", $search_lineid, 1); } if (strlen(trim($search_invoice))) { - $sql .= natural_search("f.ref", $search_invoice); + $sql .= natural_search("f.ref", $search_invoice); } if (strlen(trim($search_label))) { $sql .= natural_search("f.libelle", $search_label); } if (strlen(trim($search_ref))) { - $sql .= natural_search("p.ref", $search_ref); + $sql .= natural_search("p.ref", $search_ref); } if (strlen(trim($search_desc))) { - $sql .= natural_search("l.description", $search_desc); + $sql .= natural_search("l.description", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= natural_search("l.total_ht", $search_amount, 1); + $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { @@ -299,13 +299,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -337,9 +337,9 @@ if ($result) { if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); $arrayofmassactions = array( - 'ventil'=>$langs->trans("Ventilate") - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + 'ventil'=>$langs->trans("Ventilate") + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -572,12 +572,12 @@ if ($result) { print ''; // Country - print ''; + print ''; - // VAT Num + // VAT Num print ''; // Found accounts diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 9b66b8e5c7f..b43daca20d9 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -51,147 +51,147 @@ $type = 'bankaccount'; // Order display of bank account if ($action == 'setbankorder') { - if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } // Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { - if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif ($action == 'unsetreportlastnumreleve') { - if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } // Colorize movements if ($action == 'setbankcolorizemovement') { - if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif ($action == 'unsetbankcolorizemovement') { - if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if ($actionsave) { - $db->begin(); + $db->begin(); - $i = 1; $errorsaved = 0; - $error = 0; + $i = 1; $errorsaved = 0; + $error = 0; - // Save colors - while ($i <= 2) - { - $color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'); - if ($color == '-1') $color = ''; + // Save colors + while ($i <= 2) + { + $color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'); + if ($color == '-1') $color = ''; - $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - $i++; - } + $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + $i++; + } - if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - if ($modele == 'sepamandate') { - $object = new CompanyBankAccount($db); - } else { - $object = new Account($db); - } - $object->initAsSpecimen(); + if ($modele == 'sepamandate') { + $object = new CompanyBankAccount($db); + } else { + $object = new Account($db); + } + $object->initAsSpecimen(); - // Search template files - $file = ''; - $classname = ''; - $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) { - require_once $file; + if ($filefound) { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($object, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, null, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($object, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model if ($action == 'set') { - $ret = addDocumentModel($value, $type, $label, $scandir); + $ret = addDocumentModel($value, $type, $label, $scandir); } elseif ($action == 'del') { - $ret = delDocumentModel($value, $type); - if ($ret > 0) { - if ($conf->global->BANKADDON_PDF == "$value") - dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); - } + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + if ($conf->global->BANKADDON_PDF == "$value") + dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); + } } // Set default model elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { - // The constant that was read before the new set - // We therefore requires a variable to have a coherent view - $conf->global->BANKADDON_PDF = $value; - } + if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->BANKADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 94a3d698c2a..3044aa3ab6f 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -670,12 +670,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone print ''; - // Collect now - if (count($object->actions) > 0) { + // Collect now + if (count($object->actions) > 0) { print ''; - } else { - print ''; - } + } else { + print ''; + } print ''; } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index b0514dfc975..04c1b79a5bc 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -40,8 +40,8 @@ $dirsmartphone = array(); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); foreach ($dirmenus as $dirmenu) { - $dirstandard[] = $dirmenu.'standard'; - $dirsmartphone[] = $dirmenu.'smartphone'; + $dirstandard[] = $dirmenu.'standard'; + $dirsmartphone[] = $dirmenu.'smartphone'; } $action = GETPOST('action', 'aZ09'); @@ -66,192 +66,192 @@ if (GETPOST("menu_handler")) $menu_handler = GETPOST("menu_handler"); if ($action == 'update') { - if (!$cancel) - { - $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha'))) - { - $tmp = explode('&', GETPOST('menuIdParent', 'alpha')); - foreach ($tmp as $s) - { - if (preg_match('/fk_mainmenu=/', $s)) - { - $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); - } - if (preg_match('/fk_leftmenu=/', $s)) - { - $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); - } - } - } + if (!$cancel) + { + $leftmenu = ''; $mainmenu = ''; + if (GETPOST('menuIdParent', 'alpha') && !is_numeric(GETPOST('menuIdParent', 'alpha'))) + { + $tmp = explode('&', GETPOST('menuIdParent', 'alpha')); + foreach ($tmp as $s) + { + if (preg_match('/fk_mainmenu=/', $s)) + { + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); + } + if (preg_match('/fk_leftmenu=/', $s)) + { + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); + } + } + } - $menu = new Menubase($db); - $result = $menu->fetch(GETPOST('menuId', 'int')); - if ($result > 0) - { - $menu->title = GETPOST('titre', 'alpha'); - $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); - $menu->url = GETPOST('url', 'alpha'); - $menu->langs = GETPOST('langs', 'alpha'); - $menu->position = GETPOST('position', 'int'); - $menu->enabled = GETPOST('enabled', 'alpha'); - $menu->perms = GETPOST('perms', 'alpha'); - $menu->target = GETPOST('target', 'alpha'); - $menu->user = GETPOST('user', 'alpha'); - $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); - if (is_numeric(GETPOST('menuIdParent', 'alpha'))) - { - $menu->fk_menu = GETPOST('menuIdParent', 'alpha'); - } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; - else $menu->fk_menu = -1; - $menu->fk_mainmenu = $mainmenu; - $menu->fk_leftmenu = $leftmenu; - } + $menu = new Menubase($db); + $result = $menu->fetch(GETPOST('menuId', 'int')); + if ($result > 0) + { + $menu->title = GETPOST('titre', 'alpha'); + $menu->leftmenu = GETPOST('leftmenu', 'aZ09'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); + if (is_numeric(GETPOST('menuIdParent', 'alpha'))) + { + $menu->fk_menu = GETPOST('menuIdParent', 'alpha'); + } else { + if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; + else $menu->fk_menu = -1; + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; + } - $result = $menu->update($user); - if ($result > 0) - { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - } else { - setEventMessages($menu->error, $menu->errors, 'errors'); - } - } else { - setEventMessages($menu->error, $menu->errors, 'errors'); - } - $action = "edit"; + $result = $menu->update($user); + if ($result > 0) + { + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + } else { + setEventMessages($menu->error, $menu->errors, 'errors'); + } + } else { + setEventMessages($menu->error, $menu->errors, 'errors'); + } + $action = "edit"; - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); - exit; - } else { - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); - exit; - } + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); + exit; + } else { + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); + exit; + } } if ($action == 'add') { - if ($cancel) - { - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); - exit; - } + if ($cancel) + { + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); + exit; + } - $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3))) - { - $tmp = explode('&', GETPOST('menuId', 'alpha', 3)); - foreach ($tmp as $s) - { - if (preg_match('/fk_mainmenu=/', $s)) - { + $leftmenu = ''; $mainmenu = ''; + if (GETPOST('menuId', 'alpha', 3) && !is_numeric(GETPOST('menuId', 'alpha', 3))) + { + $tmp = explode('&', GETPOST('menuId', 'alpha', 3)); + foreach ($tmp as $s) + { + if (preg_match('/fk_mainmenu=/', $s)) + { $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); - } - if (preg_match('/fk_leftmenu=/', $s)) - { - $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); - } - } - } + } + if (preg_match('/fk_leftmenu=/', $s)) + { + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); + } + } + } - $langs->load("errors"); + $langs->load("errors"); - $error = 0; - if (!$error && !$_POST['menu_handler']) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); - $action = 'create'; - $error++; - } - if (!$error && !$_POST['type']) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); - $action = 'create'; - $error++; - } - if (!$error && !$_POST['url']) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); - $action = 'create'; - $error++; - } - if (!$error && !$_POST['titre']) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); - $action = 'create'; - $error++; - } - if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') - { - setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); - $action = 'create'; - $error++; - } - if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') - { - setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); - $action = 'create'; - $error++; - } + $error = 0; + if (!$error && !$_POST['menu_handler']) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors'); + $action = 'create'; + $error++; + } + if (!$error && !$_POST['type']) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); + $action = 'create'; + $error++; + } + if (!$error && !$_POST['url']) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); + $action = 'create'; + $error++; + } + if (!$error && !$_POST['titre']) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); + $action = 'create'; + $error++; + } + if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') + { + setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); + $action = 'create'; + $error++; + } + if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') + { + setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); + $action = 'create'; + $error++; + } - if (!$error) - { - $menu = new Menubase($db); - $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); - $menu->type = GETPOST('type', 'alpha'); - $menu->title = GETPOST('titre', 'alpha'); - $menu->url = GETPOST('url', 'alpha'); - $menu->langs = GETPOST('langs', 'alpha'); - $menu->position = GETPOST('position', 'int'); - $menu->enabled = GETPOST('enabled', 'alpha'); - $menu->perms = GETPOST('perms', 'alpha'); - $menu->target = GETPOST('target', 'alpha'); - $menu->user = GETPOST('user', 'alpha'); - $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); - if (is_numeric(GETPOST('menuId', 'alpha', 3))) - { - $menu->fk_menu = GETPOST('menuId', 'alpha', 3); - } else { - if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; - else $menu->fk_menu = -1; - $menu->fk_mainmenu = $mainmenu; - $menu->fk_leftmenu = $leftmenu; - } + if (!$error) + { + $menu = new Menubase($db); + $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); + $menu->type = GETPOST('type', 'alpha'); + $menu->title = GETPOST('titre', 'alpha'); + $menu->url = GETPOST('url', 'alpha'); + $menu->langs = GETPOST('langs', 'alpha'); + $menu->position = GETPOST('position', 'int'); + $menu->enabled = GETPOST('enabled', 'alpha'); + $menu->perms = GETPOST('perms', 'alpha'); + $menu->target = GETPOST('target', 'alpha'); + $menu->user = GETPOST('user', 'alpha'); + $menu->mainmenu = GETPOST('propertymainmenu', 'alpha'); + if (is_numeric(GETPOST('menuId', 'alpha', 3))) + { + $menu->fk_menu = GETPOST('menuId', 'alpha', 3); + } else { + if (GETPOST('type', 'alpha') == 'top') $menu->fk_menu = 0; + else $menu->fk_menu = -1; + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; + } - $result = $menu->create($user); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09')); - exit; - } else { - $action = 'create'; - setEventMessages($menu->error, $menu->errors, 'errors'); - } - } + $result = $menu->create($user); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler', 'aZ09')); + exit; + } else { + $action = 'create'; + setEventMessages($menu->error, $menu->errors, 'errors'); + } + } } // delete if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') { - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); - $result = $db->query($sql); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); + $result = $db->query($sql); - if ($result == 0) - { - $this->db->commit(); + if ($result == 0) + { + $this->db->commit(); - llxHeader(); - setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); - llxFooter(); - exit; - } else { - $this->db->rollback(); + llxHeader(); + setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs'); + llxFooter(); + exit; + } else { + $this->db->rollback(); - $reload = 0; - $_GET["action"] = ''; - } + $reload = 0; + $_GET["action"] = ''; + } } @@ -268,7 +268,7 @@ llxHeader('', $langs->trans("Menu")); if ($action == 'create') { - print ''; - print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup'); + print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup'); - print ''; - print ''; + print ''; + print ''; - dol_fiche_head(); + dol_fiche_head(); - print '
'.$langs->trans('ExpenseReportApplyTo').''.$langs->trans('ExpenseReportDomain').''.$langs->trans('Type').''.$langs->trans('ExpenseReportLimitOn').''.$langs->trans('ExpenseReportDateStart').''.$langs->trans('ExpenseReportDateEnd').''; + echo ''; if ($object->id != $rule->id) { - echo ''.img_edit().' '; - echo ''.img_delete().''; + echo ''.img_edit().' '; + echo ''.img_delete().''; } else { echo ' '; echo ''.$langs->trans('Cancel').''; diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index caaeb706c32..42691f14307 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -269,10 +269,10 @@ class CoreObject extends CommonObject /** * Function to create object in database * - * @param User $user user object + * @param User $user User object * @return int < 0 if KO, > 0 if OK */ - public function create(User &$user) + public function create(User $user) { if ($this->id > 0) return $this->update($user); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c6ebb7511bb..80752a2090a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7606,9 +7606,10 @@ class Form * @param string $target htmlname of target select to bind event * @param int $default_selected default category to select if fk_c_type_fees change = EX_KME * @param array $params param to give + * @param int $info_admin Show the tooltip help picto to setup list * @return string */ - public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) + public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array(), $info_admin = 1) { global $db, $conf, $langs, $user; @@ -7629,7 +7630,9 @@ class Form $out .= ''; } $out .= ''; - if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ajax_combobox('select_'.$htmlname); + + if (!empty($htmlname) && $user->admin && $info_admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if (!empty($target)) { diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 1c7ff2cf20e..30fd6d29a1d 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -615,23 +615,6 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $mois = date("m", $timestampStart); $annee = date("Y", $timestampStart); - // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... - // Do not use this anymore, use instead the dictionary of public holidays. - if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) - { - $arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); - foreach ($arrayofdaystring as $daystring) - { - $tmp = explode('-', $daystring); - if ($tmp[2]) - { - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true; - } else { - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true; - } - } - } - $country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid'); // Loop on public holiday defined into hrm_public_holiday diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php index 4c54ca09e31..c4e68356349 100644 --- a/htdocs/core/lib/expensereport.lib.php +++ b/htdocs/core/lib/expensereport.lib.php @@ -133,14 +133,6 @@ function expensereport_admin_prepare_head() $head[$h][2] = 'expensereport'; $h++; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) - { - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; - $head[$h][1] = $langs->trans("ExpenseReportsIk"); - $head[$h][2] = 'expenseik'; - $h++; - } - if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) { $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; @@ -149,6 +141,14 @@ function expensereport_admin_prepare_head() $h++; } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) + { + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; + $head[$h][1] = $langs->trans("ExpenseReportsIk"); + $head[$h][2] = 'expenseik'; + $h++; + } + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d4f09f793bc..59584562dff 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2017 Ferran Marcet @@ -1835,7 +1835,7 @@ if ($action == 'create') print '
'.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; + $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); + print $labeltype; + print ''; - $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); - print $labeltype; - print ''.dol_nl2br($line->comments).''; + select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); + print ''; @@ -2293,11 +2301,6 @@ if ($action == 'create') print ''; - select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); - print ''; print ''; @@ -2344,7 +2347,7 @@ if ($action == 'create') } } - // Add a line + // Add a new line if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) @@ -2408,9 +2411,13 @@ if ($action == 'create') print '
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('CarCategory').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; - $params = array('fk_expense' => $object->id); - print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); - print ''; select_type_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1); print ''; + $params = array('fk_expense' => $object->id); + print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0); + print ''; print ''; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index a3c0b78510c..defe5736aa8 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -318,3 +318,5 @@ ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_t ALTER TABLE llx_c_ticket_category ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL; ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL; +ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; + diff --git a/htdocs/install/mysql/tables/llx_expensereport_ik.sql b/htdocs/install/mysql/tables/llx_expensereport_ik.sql index 3e767a8c396..ddc7fa4d3c7 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_ik.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_ik.sql @@ -25,6 +25,6 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL, fk_range integer DEFAULT 0 NOT NULL, coef double DEFAULT 0 NOT NULL, - ikoffset double DEFAULT 0 NOT NULL, + ikoffset double DEFAULT 0 NOT NULL, active integer DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 15627a7e88b..0a91a481ac3 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1794,7 +1794,6 @@ TypePaymentDesc=0:Customer payment type, 1:Vendor payment type, 2:Both customers IncludePath=Include path (defined into variable %s) ExpenseReportsSetup=Setup of module Expense Reports TemplatePDFExpenseReports=Document templates to generate expense report document -ExpenseReportsIkSetup=Setup of module Expense Reports - Milles index ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules ExpenseReportNumberingModules=Expense reports numbering module NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only. diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 654f14d6bf7..d0fc0126f2c 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -110,7 +110,7 @@ ExpenseReportPayment=Expense report payment ExpenseReportsToApprove=Expense reports to approve ExpenseReportsToPay=Expense reports to pay ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ? -ExpenseReportsIk=Expense report milles index +ExpenseReportsIk=Configuration of mileage charges ExpenseReportsRules=Expense report rules ExpenseReportIkDesc=You can modify the calculation of kilometers expense by category and range who they are previously defined. d is the distance in kilometers ExpenseReportRulesDesc=You can create or update any rules of calculation. This part will be used when user will create a new expense report diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 062bdb6dd11..2d5598f49b3 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -242,29 +242,6 @@ class DateLibTest extends PHPUnit\Framework\TestCase $result=num_public_holiday($date1, $date2, 'XX', 1); print __METHOD__." result=".$result."\n"; $this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) - - - - // Add more holiday with constant HOLIDAY_MORE_PUBLIC_HOLIDAYS - $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS='12-13,2019-12-14'; - - $date1=dol_mktime(0, 0, 0, 12, 13, 2018); - $date2=dol_mktime(0, 0, 0, 12, 13, 2018); - $result=num_public_holiday($date1, $date2, 'YY', 1); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2018-12-13'); // 0 opened day, 1 closed days (even if country unknown) - - $date1=dol_mktime(0, 0, 0, 12, 14, 2018); - $date2=dol_mktime(0, 0, 0, 12, 14, 2018); - $result=num_public_holiday($date1, $date2, 'YY', 1); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(0, $result, 'NumPublicHoliday for YY the 2018-12-14'); // 1 opened day, 0 closed days (even if country unknown) - - $date1=dol_mktime(0, 0, 0, 12, 14, 2019); - $date2=dol_mktime(0, 0, 0, 12, 14, 2019); - $result=num_public_holiday($date1, $date2, 'YY', 1); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2019-12-14'); // 0 opened day, 1 closed days (even if country unknown) } /** From 54c0f673c1f510b20b20b3a772b3bf20cd986221 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Sep 2020 12:00:14 +0200 Subject: [PATCH 033/173] Debug hidden option MAIN_USE_EXPENSE_IK --- htdocs/core/class/html.form.class.php | 2 +- htdocs/expensereport/card.php | 4 +-- .../class/expensereport.class.php | 25 +++++++++++-------- htdocs/langs/en_US/trips.lang | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 80752a2090a..9e6b247d178 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7622,7 +7622,7 @@ class Form $resql = $db->query($sql); if ($resql) { - $out = ''; if ($useempty) $out .= ''; while ($obj = $db->fetch_object($resql)) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 59584562dff..192cfcdc570 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2290,7 +2290,7 @@ if ($action == 'create') // Select type print ''; - select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); + print select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); print ''; - select_type_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1); + print select_type_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1); print '
'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print '
'.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print '
'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } + print ''; + } print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; - $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; - print $labelcountry; - print ''; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; + print $labelcountry; + print ''.$objp->tva_intra.''; - $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; - $shelp = ''; - if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); - $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : ''.$langs->trans("NotDefined").''); - print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); - if ($objp->product_id > 0) + $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $shelp = ''; + if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); + $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : ''.$langs->trans("NotDefined").''); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + if ($objp->product_id > 0) { - print '
'; - $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; - $shelp = ''; - if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); - elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber"); - elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); - $s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p)); - print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + print '
'; + $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $shelp = ''; + if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); + elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber"); + elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); + $s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p)); + print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '
'; @@ -287,7 +287,7 @@ if ($result) { print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -341,7 +341,7 @@ if ($result) { print ''.$expensereportstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->date_valid), 'day').''; @@ -327,7 +327,7 @@ if ($result) { print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre("DateOfLine", $_SERVER["PHP_SELF"], "erd.date, erd.rowid", "", $param, '', $sortfield, $sortorder, 'center '); @@ -381,7 +381,7 @@ if ($result) { print ''.$expensereport_static->getNomUrl(1).''.dol_print_date($db->jdate($objp->date_valid), 'day').''.$thirdpartystatic->getNomUrl(1, 'supplier').''; - $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; - print $labelcountry; - print ''; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; + print $labelcountry; + print ''.$objp->tva_intra.'
'; + print '
'; - // Id - $parent_rowid = GETPOST('menuId', 'int'); - if (GETPOST('menuId', 'int')) - { - $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); - $res = $db->query($sql); - if ($res) - { - while ($menu = $db->fetch_array($res)) - { - $parent_rowid = $menu['rowid']; - $parent_mainmenu = $menu['mainmenu']; - $parent_leftmenu = $menu['leftmenu']; - $parent_langs = $menu['langs']; - $parent_level = $menu['level']; - } - } - } + // Id + $parent_rowid = GETPOST('menuId', 'int'); + if (GETPOST('menuId', 'int')) + { + $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); + $res = $db->query($sql); + if ($res) + { + while ($menu = $db->fetch_array($res)) + { + $parent_rowid = $menu['rowid']; + $parent_mainmenu = $menu['mainmenu']; + $parent_leftmenu = $menu['leftmenu']; + $parent_langs = $menu['langs']; + $parent_level = $menu['level']; + } + } + } - // Handler - print ''; - print ''; - print ''; + // Handler + print ''; + print ''; + print ''; - // User - print ''; - print ''; - print ''; + // User + print ''; + print ''; + print ''; - // Type - print ''; + // Type + print ''; - // Mainmenu code - print ''; + // Mainmenu code + print ''; print ''; - print ''; + print ''; - // MenuId Parent - print ''; - if ($parent_rowid) - { - print ''; - } else { - print ''; - } - print ''; + // MenuId Parent + print ''; + if ($parent_rowid) + { + print ''; + } else { + print ''; + } + print ''; - // Title - print ''; + // Title + print ''; - // URL - print ''; + // URL + print ''; - // Langs - print ''; + // Langs + print ''; - // Position - print ''; + // Position + print ''; - // Target - print ''; + // Target + print ''; - // Enabled - print ''; + // Enabled + print ''; - // Perms - print ''; + // Perms + print ''; - print '
'.$langs->trans('MenuHandler').''; - $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); - print ''.$langs->trans('DetailMenuHandler').'
'.$langs->trans('MenuHandler').''; + $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/', $menu_handler) ? '' : '_menu'), 'menu_handler', array_merge($dirstandard, $dirsmartphone)); + print ''.$langs->trans('DetailMenuHandler').'
'.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
'.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
'.$langs->trans('Type').''; - if ($parent_rowid) - { - print $langs->trans('Left'); - print ''; - } else { - print ''; - } - print ''.$langs->trans('DetailType').'
'.$langs->trans('Type').''; + if ($parent_rowid) + { + print $langs->trans('Left'); + print ''; + } else { + print ''; + } + print ''.$langs->trans('DetailType').'
'.$langs->trans('MainMenuCode').'
'.$langs->trans('MainMenuCode').''; - print $langs->trans("Example").': mytopmenukey'; - print '
'; + print $langs->trans("Example").': mytopmenukey'; + print '
'.$langs->trans('MenuIdParent').''.$parent_rowid.''.$langs->trans('DetailMenuIdParent'); - print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; - print '
'.$langs->trans('MenuIdParent').''.$parent_rowid.''.$langs->trans('DetailMenuIdParent'); + print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; + print '
'.$langs->trans('Title').''.$langs->trans('DetailTitre').'
'.$langs->trans('Title').''.$langs->trans('DetailTitre').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
'.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
'.$langs->trans('Rights').''.$langs->trans('DetailRight').'
'.$langs->trans('Rights').''.$langs->trans('DetailRight').'
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - print '
'; + print '
'; print ''; - print '     '; - print ''; + print '     '; + print ''; print '
'; - print ''; + print ''; } elseif ($action == 'edit') { - print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup'); - print '
'; + print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup'); + print '
'; - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - dol_fiche_head(); + dol_fiche_head(); - print ''; + print '
'; - $menu = new Menubase($db); - $result = $menu->fetch(GETPOST('menuId', 'int')); - //var_dump($menu); + $menu = new Menubase($db); + $result = $menu->fetch(GETPOST('menuId', 'int')); + //var_dump($menu); - // Id - print ''; + // Id + print ''; - // Module - print ''; + // Module + print ''; - // Handler - if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus'); - else $handler = $menu->menu_handler; - print ''; + // Handler + if ($menu->menu_handler == 'all') $handler = $langs->trans('AllMenus'); + else $handler = $menu->menu_handler; + print ''; - // User - print ''; + // User + print ''; - // Type - print ''; + // Type + print ''; - // Mainmenu code - if ($menu->type == 'top') - { - print ''; - /*if ($parent_rowid) + // Mainmenu code + if ($menu->type == 'top') + { + print ''; + /*if ($parent_rowid) { print ''; } else {*/ - print ''; - //} - print ''; - } + print ''; + //} + print ''; + } - // MenuId Parent - print ''; - $valtouse = $menu->fk_menu; - if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu; - if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; - print ''; - print ''; + // MenuId Parent + print ''; + $valtouse = $menu->fk_menu; + if ($menu->fk_mainmenu) $valtouse = 'fk_mainmenu='.$menu->fk_mainmenu; + if ($menu->fk_leftmenu) $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; + print ''; + print ''; - // Niveau - //print ''; + // Niveau + //print ''; - // Title - print ''; + // Title + print ''; - // Url - print ''; + // Url + print ''; - // Langs - print ''; + // Langs + print ''; - // Position - print ''; + // Position + print ''; - // Target - print ''; + // Target + print ''; - // Enabled - print ''; + // Enabled + print ''; - // Perms - print ''; + // Perms + print ''; - print '
'.$langs->trans('Id').''.$menu->id.''.$langs->trans('DetailId').'
'.$langs->trans('Id').''.$menu->id.''.$langs->trans('DetailId').'
'.$langs->trans('MenuModule').''.$menu->module.''.$langs->trans('DetailMenuModule').'
'.$langs->trans('MenuModule').''.$menu->module.''.$langs->trans('DetailMenuModule').'
'.$langs->trans('MenuHandler').''.$handler.''.$langs->trans('DetailMenuHandler').'
'.$langs->trans('MenuHandler').''.$handler.''.$langs->trans('DetailMenuHandler').'
'.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
'.$langs->trans('MenuForUsers').''.$langs->trans('DetailUser').'
'.$langs->trans('Type').''.$langs->trans(ucfirst($menu->type)).''.$langs->trans('DetailType').'
'.$langs->trans('Type').''.$langs->trans(ucfirst($menu->type)).''.$langs->trans('DetailType').'
'.$langs->trans('MainMenuCode').'
'.$langs->trans('MainMenuCode').''.$parent_rowid.'mainmenu).'">'; - print $langs->trans("Example").': mytopmenukey'; - print '
mainmenu).'">'; + print $langs->trans("Example").': mytopmenukey'; + print '
'.$langs->trans('MenuIdParent'); - print ''.$langs->trans('DetailMenuIdParent'); - print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; - print '
'.$langs->trans('MenuIdParent'); + print ''.$langs->trans('DetailMenuIdParent'); + print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; + print '
'.$langs->trans('Level').''.$menu->level.''.$langs->trans('DetailLevel').'
'.$langs->trans('Level').''.$menu->level.''.$langs->trans('DetailLevel').'
'.$langs->trans('Title').''.$langs->trans('DetailTitre').'
'.$langs->trans('Title').''.$langs->trans('DetailTitre').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('URL').''.$langs->trans('DetailUrl').'
'.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
'.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Position').''.$langs->trans('DetailPosition').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Target').''.$langs->trans('DetailTarget').'
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled'); - if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; - print '
'.$langs->trans('Enabled').''.$langs->trans('DetailEnabled'); + if (!empty($menu->enabled)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->enabled, 1)).')'; + print '
'.$langs->trans('Rights').''.$langs->trans('DetailRight'); - if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; - print '
'.$langs->trans('Rights').''.$langs->trans('DetailRight'); + if (!empty($menu->perms)) print ' ('.$langs->trans("ConditionIsCurrently").': '.yn(dol_eval($menu->perms, 1)).')'; + print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); - // Bouton - print '
'; + // Bouton + print '
'; print ''; - print '     '; - print ''; + print '     '; + print ''; print '
'; - print ''; + print ''; - print '
'; + print '
'; } // End of page diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5514172182e..908044433e7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -498,7 +498,7 @@ class ActionComm extends CommonObject $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; $sql .= " '".$this->db->escape($this->note_private)."', "; - $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned + $sql .= ((isset($this->contact_id) && $this->contact_id > 0) ? $this->contact_id : "null").", "; // deprecated, use ->socpeopleassigned $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; $sql .= ($userownerid > 0 ? $userownerid : "null").", "; $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; @@ -632,173 +632,173 @@ class ActionComm extends CommonObject //$this->fetch_userassigned(); $this->fetchResources(); - $this->id = 0; + $this->id = 0; - // Create clone + // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($fuser); - if ($result < 0) $error++; + if ($result < 0) $error++; - if (!$error) - { - // Hook of thirdparty module - if (is_object($hookmanager)) - { - $parameters = array('objFrom'=>$objFrom); - $action = ''; - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; - } + if (!$error) + { + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } - // Call trigger - $result = $this->call_trigger('ACTION_CLONE', $fuser); - if ($result < 0) { $error++; } - // End call triggers - } + // Call trigger + $result = $this->call_trigger('ACTION_CLONE', $fuser); + if ($result < 0) { $error++; } + // End call triggers + } - unset($this->context['createfromclone']); + unset($this->context['createfromclone']); - // End - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } + // End + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object from database - * - * @param int $id Id of action to get - * @param string $ref Ref of action to get - * @param string $ref_ext Ref ext to get + /** + * Load object from database + * + * @param int $id Id of action to get + * @param string $ref Ref of action to get + * @param string $ref_ext Ref ext to get * @param string $email_msgid Email msgid - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') - { - global $langs; + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $ref = '', $ref_ext = '', $email_msgid = '') + { + global $langs; - $sql = "SELECT a.id,"; - $sql .= " a.id as ref,"; - $sql .= " a.entity,"; - $sql .= " a.ref_ext,"; - $sql .= " a.datep,"; - $sql .= " a.datep2,"; - $sql .= " a.durationp,"; // deprecated - $sql .= " a.datec,"; - $sql .= " a.tms as datem,"; - $sql .= " a.code, a.label, a.note,"; - $sql .= " a.fk_soc,"; - $sql .= " a.fk_project,"; - $sql .= " a.fk_user_author, a.fk_user_mod,"; - $sql .= " a.fk_user_action, a.fk_user_done,"; - $sql .= " a.fk_contact, a.percent as percentage,"; - $sql .= " a.fk_element as elementid, a.elementtype,"; - $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; - $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; - $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; - $sql .= " s.nom as socname,"; - $sql .= " u.firstname, u.lastname as lastname"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql .= " WHERE "; - if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id - elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; - elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; - else $sql .= " a.id = ".((int) $id); + $sql = "SELECT a.id,"; + $sql .= " a.id as ref,"; + $sql .= " a.entity,"; + $sql .= " a.ref_ext,"; + $sql .= " a.datep,"; + $sql .= " a.datep2,"; + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec,"; + $sql .= " a.tms as datem,"; + $sql .= " a.code, a.label, a.note,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_project,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element as elementid, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.transparency,"; + $sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; + $sql .= " s.nom as socname,"; + $sql .= " u.firstname, u.lastname as lastname"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql .= " WHERE "; + if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id + elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; + elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; + else $sql .= " a.id = ".((int) $id); - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->id; + $this->id = $obj->id; $this->entity = $obj->entity; - $this->ref = $obj->ref; - $this->ref_ext = $obj->ref_ext; + $this->ref = $obj->ref; + $this->ref_ext = $obj->ref_ext; - // Properties of parent table llx_c_actioncomm - $this->type_id = $obj->type_id; - $this->type_code = $obj->type_code; - $this->type_color = $obj->type_color; - $this->type_picto = $obj->type_picto; - $transcode = $langs->trans("Action".$obj->type_code); - $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); - $transcode = $langs->trans("Action".$obj->type_code.'Short'); - $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); + // Properties of parent table llx_c_actioncomm + $this->type_id = $obj->type_id; + $this->type_code = $obj->type_code; + $this->type_color = $obj->type_color; + $this->type_picto = $obj->type_picto; + $transcode = $langs->trans("Action".$obj->type_code); + $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); + $transcode = $langs->trans("Action".$obj->type_code.'Short'); + $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); $this->code = $obj->code; - $this->label = $obj->label; - $this->datep = $this->db->jdate($obj->datep); - $this->datef = $this->db->jdate($obj->datep2); + $this->label = $obj->label; + $this->datep = $this->db->jdate($obj->datep); + $this->datef = $this->db->jdate($obj->datep2); - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); - $this->note = $obj->note; // deprecated - $this->note_private = $obj->note; - $this->percentage = $obj->percentage; + $this->note = $obj->note; // deprecated + $this->note_private = $obj->note; + $this->percentage = $obj->percentage; - $this->authorid = $obj->fk_user_author; - $this->usermodid = $obj->fk_user_mod; + $this->authorid = $obj->fk_user_author; + $this->usermodid = $obj->fk_user_mod; - if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated - if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated + if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning + $this->usermod->id = $obj->fk_user_mod; // deprecated - $this->userownerid = $obj->fk_user_action; - $this->userdoneid = $obj->fk_user_done; - $this->priority = $obj->priority; - $this->fulldayevent = $obj->fulldayevent; - $this->location = $obj->location; - $this->transparency = $obj->transparency; + $this->userownerid = $obj->fk_user_action; + $this->userdoneid = $obj->fk_user_done; + $this->priority = $obj->priority; + $this->fulldayevent = $obj->fulldayevent; + $this->location = $obj->location; + $this->transparency = $obj->transparency; - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contact_id = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_projet method working + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->contact_id = $obj->fk_contact; // To have fetch_contact method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working - //$this->societe->id = $obj->fk_soc; // deprecated - //$this->contact->id = $obj->fk_contact; // deprecated + //$this->societe->id = $obj->fk_soc; // deprecated + //$this->contact->id = $obj->fk_contact; // deprecated - $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; - $this->elementtype = $obj->elementtype; + $this->fk_element = $obj->elementid; + $this->elementid = $obj->elementid; + $this->elementtype = $obj->elementtype; - $this->fetchResources(); - } - $this->db->free($resql); - } else { - $this->error = $this->db->lasterror(); - return -1; - } + $this->fetchResources(); + } + $this->db->free($resql); + } else { + $this->error = $this->db->lasterror(); + return -1; + } - return $num; - } + return $num; + } - /** - * Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event - * - * @return int <0 if KO, >0 if OK - */ - public function fetchResources() - { - $this->userassigned = array(); - $this->socpeopleassigned = array(); + /** + * Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event + * + * @return int <0 if KO, >0 if OK + */ + public function fetchResources() + { + $this->userassigned = array(); + $this->socpeopleassigned = array(); - $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; + $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; $sql .= ' WHERE fk_actioncomm = '.$this->id; $sql .= " AND element_type IN ('user', 'socpeople')"; @@ -1937,168 +1937,168 @@ class ActionComm extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - /** - * Is the action delayed? - * - * @return bool - */ - public function hasDelay() - { - global $conf; + /** + * Is the action delayed? + * + * @return bool + */ + public function hasDelay() + { + global $conf; - $now = dol_now(); + $now = dol_now(); - return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay)); - } + return $this->datep && ($this->datep < ($now - $conf->agenda->warning_delay)); + } - /** - * Send reminders by emails - * CAN BE A CRON TASK - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function sendEmailsReminder() - { - global $conf, $langs, $user; + /** + * Send reminders by emails + * CAN BE A CRON TASK + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function sendEmailsReminder() + { + global $conf, $langs, $user; - $error = 0; - $this->output = ''; + $error = 0; + $this->output = ''; $this->error = ''; $nbMailSend = 0; $errorsMsg = array(); - if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. + if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. { $langs->load("agenda"); $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; } if (empty($conf->global->AGENDA_REMINDER_EMAIL)) - { - $langs->load("agenda"); - $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); - return 0; - } + { + $langs->load("agenda"); + $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); + return 0; + } - $now = dol_now(); + $now = dol_now(); - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $this->db->begin(); + $this->db->begin(); - //Select all action comm reminder - $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + //Select all action comm reminder + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; $sql .= " WHERE typeremind = 'email' AND status = 0"; $sql .= " AND dateremind <= '".$this->db->idate(dol_now())."'"; $sql .= $this->db->order("dateremind", "ASC"); - $resql = $this->db->query($sql); + $resql = $this->db->query($sql); - if ($resql) { - $formmail = new FormMail($this->db); - $actionCommReminder = new ActionCommReminder($this->db); + if ($resql) { + $formmail = new FormMail($this->db); + $actionCommReminder = new ActionCommReminder($this->db); while ($obj = $this->db->fetch_object($resql)){ - $res = $actionCommReminder->fetch($obj->id); - if ($res < 0) { - $error++; - $errorsMsg[] = "Failed to load invoice ActionComm Reminder"; - } + $res = $actionCommReminder->fetch($obj->id); + if ($res < 0) { + $error++; + $errorsMsg[] = "Failed to load invoice ActionComm Reminder"; + } - if (!$error) - { - //Select email template - $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); + if (!$error) + { + //Select email template + $arraymessage = $formmail->getEMailTemplate($this->db, 'actioncomm_send', $user, $langs, (!empty($actionCommReminder->fk_email_template)) ? $actionCommReminder->fk_email_template : -1, 1); - // Load event - $res = $this->fetch($actionCommReminder->fk_actioncomm); - if ($res > 0) - { - // PREPARE EMAIL + // Load event + $res = $this->fetch($actionCommReminder->fk_actioncomm); + if ($res > 0) + { + // PREPARE EMAIL - // Make substitution in email content - $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($langs, 0, '', $this); - complete_substitutions_array($substitutionarray, $langs, $this); + complete_substitutions_array($substitutionarray, $langs, $this); - // Content - $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); + // Content + $sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray); - //Topic - $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); + //Topic + $sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder')); - // Recipient - $recipient = new User($this->db); - $res = $recipient->fetch($actionCommReminder->fk_user); - if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; - else { - $errorsMsg[] = "Failed to load recipient"; - $error++; - } + // Recipient + $recipient = new User($this->db); + $res = $recipient->fetch($actionCommReminder->fk_user); + if ($res > 0 && !empty($recipient->email)) $to = $recipient->email; + else { + $errorsMsg[] = "Failed to load recipient"; + $error++; + } - // Sender - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - if (empty($from)) { - $errorsMsg[] = "Failed to load recipient"; - $error++; - } + // Sender + $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + if (empty($from)) { + $errorsMsg[] = "Failed to load recipient"; + $error++; + } - // Errors Recipient - $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + // Errors Recipient + $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; - // Mail Creation - $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', ''); - // Sending Mail - if ($cMailFile->sendfile()) - { - $actionCommReminder->status = $actionCommReminder::STATUS_DONE; - $res = $actionCommReminder->update($user); - if ($res < 0) - { - $errorsMsg[] = "Failed to update status of ActionComm Reminder"; - $error++; - break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. - } else { - $nbMailSend++; - } - } else { - $errorsMsg[] = $cMailFile->error.' : '.$to; - $error++; - } - } else { - $error++; - } - } - } - } else { - $error++; - } + // Sending Mail + if ($cMailFile->sendfile()) + { + $actionCommReminder->status = $actionCommReminder::STATUS_DONE; + $res = $actionCommReminder->update($user); + if ($res < 0) + { + $errorsMsg[] = "Failed to update status of ActionComm Reminder"; + $error++; + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + } else { + $nbMailSend++; + } + } else { + $errorsMsg[] = $cMailFile->error.' : '.$to; + $error++; + } + } else { + $error++; + } + } + } + } else { + $error++; + } - if (!$error) - { - // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + if (!$error) + { + // Delete also very old past events (we do not keep more than 1 month record in past) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; $sql .= " WHERE dateremind < '".$this->db->idate($now - (3600 * 24 * 32))."'"; - $resql = $this->db->query($sql); + $resql = $this->db->query($sql); - if (!$resql) { - $errorsMsg[] = 'Failed to delete old reminders'; - //$error++; // If this fails, we must not rollback other SQL requests already done. Never mind. - } - } + if (!$resql) { + $errorsMsg[] = 'Failed to delete old reminders'; + //$error++; // If this fails, we must not rollback other SQL requests already done. Never mind. + } + } - if (!$error) { - $this->output = 'Nb of emails sent : '.$nbMailSend; - $this->db->commit(); - return 0; - } - else { - $this->db->rollback(); - $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; - return $error; - } - } + if (!$error) { + $this->output = 'Nb of emails sent : '.$nbMailSend; + $this->db->commit(); + return 0; + } + else { + $this->db->rollback(); + $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; + return $error; + } + } /** * Udpate the percent value of a event with the given id diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 64c24c9c8e8..0c6ca3c1acc 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -150,7 +150,7 @@ if (GETPOST("viewlist", 'alpha') || $action == 'show_list') $param .= '&'.$key.'='.urlencode($val); } } - if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; + if (!preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list'; //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); exit; @@ -636,518 +636,518 @@ dol_syslog("comm/action/index.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) - $i = 0; - while ($i < $num && $i < $MAXONSAMEPAGE) - { - $obj = $db->fetch_object($resql); + $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) + $i = 0; + while ($i < $num && $i < $MAXONSAMEPAGE) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - // Create a new object action - $event = new ActionComm($db); + // Create a new object action + $event = new ActionComm($db); - $event->id = $obj->id; - $event->ref = $event->id; + $event->id = $obj->id; + $event->ref = $event->id; - $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin - $event->datef = $db->jdate($obj->datep2); + $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin + $event->datef = $db->jdate($obj->datep2); //var_dump($obj->datep); - //var_dump($event->datep); + //var_dump($event->datep); - $event->type_code = $obj->type_code; - $event->type_label = $obj->type_label; - $event->type_color = $obj->type_color; + $event->type_code = $obj->type_code; + $event->type_label = $obj->type_label; + $event->type_color = $obj->type_color; - $event->libelle = $obj->label; // deprecated - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->libelle = $obj->label; // deprecated + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->fetch_userassigned(); // This load $event->userassigned + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->thirdparty_id = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->thirdparty_id = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; - else $event->date_end_in_calendar = $event->datep; - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + $event->date_start_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + } else { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; - } + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } // Complete $eventarray with birthdates if ($showbirthday) { - // Add events in array - $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; - $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; - if ($action == 'show_day') - { - $sql .= ' AND MONTH(birthday) = '.$month; - $sql .= ' AND DAY(birthday) = '.$day; - } else { - $sql .= ' AND MONTH(birthday) = '.$month; - } - $sql .= ' ORDER BY birthday'; + // Add events in array + $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; + $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; + if ($action == 'show_day') + { + $sql .= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND DAY(birthday) = '.$day; + } else { + $sql .= ' AND MONTH(birthday) = '.$month; + } + $sql .= ' ORDER BY birthday'; - dol_syslog("comm/action/index.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $event = new ActionComm($db); + dol_syslog("comm/action/index.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $event = new ActionComm($db); - $event->id = $obj->rowid; // We put contact id in action id for birthdays events - $event->ref = $event->id; + $event->id = $obj->rowid; // We put contact id in action id for birthdays events + $event->ref = $event->id; - $datebirth = dol_stringtotime($obj->birthday, 1); - //print 'ee'.$obj->birthday.'-'.$datebirth; - $datearray = dol_getdate($datebirth, true); - $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output - $event->datef = $event->datep; - $event->type_code = 'BIRTHDAY'; - $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); - $event->percentage = 100; - $event->fulldayevent = 1; + $datebirth = dol_stringtotime($obj->birthday, 1); + //print 'ee'.$obj->birthday.'-'.$datebirth; + $datearray = dol_getdate($datebirth, true); + $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output + $event->datef = $event->datep; + $event->type_code = 'BIRTHDAY'; + $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->percentage = 100; + $event->fulldayevent = 1; - $event->date_start_in_calendar = $event->datep; - $event->date_end_in_calendar = $event->datef; - $event->ponctuel = 0; + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + $event->ponctuel = 0; - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - $loop = true; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); - $i++; - } - } else { - dol_print_error($db); - } + $loop = true; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); + $i++; + } + } else { + dol_print_error($db); + } } if ($conf->global->AGENDA_SHOW_HOLIDAYS) { - $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"; - $sql .= " WHERE u.rowid = x.fk_user"; - $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) - $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + $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"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) - if ($action == 'show_day') - { - // Request only leaves for the current selected day - $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; - } elseif ($action == 'show_week') - { - // TODO: Add filter to reduce database request - } elseif ($action == 'show_month') - { - // TODO: Add filter to reduce database request - } + if ($action == 'show_day') + { + // Request only leaves for the current selected day + $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; + } elseif ($action == 'show_week') + { + // TODO: Add filter to reduce database request + } elseif ($action == 'show_month') + { + // TODO: Add filter to reduce database request + } - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $dateStartArray = dol_getdate(dol_stringtotime($obj->date_start, 1), true); - $dateEndArray = dol_getdate(dol_stringtotime($obj->date_end, 1), true); + $dateStartArray = dol_getdate(dol_stringtotime($obj->date_start, 1), true); + $dateEndArray = dol_getdate(dol_stringtotime($obj->date_end, 1), true); - $event = new ActionComm($db); + $event = new ActionComm($db); - // Need the id of the leave object for link to it - $event->id = $obj->rowid; - $event->ref = $event->id; + // Need the id of the leave object for link to it + $event->id = $obj->rowid; + $event->ref = $event->id; - $event->type_code = 'HOLIDAY'; - $event->datep = dol_mktime(0, 0, 0, $dateStartArray['mon'], $dateStartArray['mday'], $dateStartArray['year'], true); - $event->datef = dol_mktime(0, 0, 0, $dateEndArray['mon'], $dateEndArray['mday'], $dateEndArray['year'], true); - $event->date_start_in_calendar = $event->datep; - $event->date_end_in_calendar = $event->datef; + $event->type_code = 'HOLIDAY'; + $event->datep = dol_mktime(0, 0, 0, $dateStartArray['mon'], $dateStartArray['mday'], $dateStartArray['year'], true); + $event->datef = dol_mktime(0, 0, 0, $dateEndArray['mon'], $dateEndArray['mday'], $dateEndArray['year'], true); + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; - if ($obj->status == 3) - { - // Show no symbol for leave with state "leave approved" - $event->percentage = -1; - } elseif ($obj->status == 2) - { - // Show TO-DO symbol for leave with state "leave wait for approval" - $event->percentage = 0; - } + if ($obj->status == 3) + { + // Show no symbol for leave with state "leave approved" + $event->percentage = -1; + } elseif ($obj->status == 2) + { + // Show TO-DO symbol for leave with state "leave wait for approval" + $event->percentage = 0; + } - if ($obj->halfday == 1) - { - $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } elseif ($obj->halfday == -1) - { - $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; - } else { - $event->label = $obj->lastname; - } + if ($obj->halfday == 1) + { + $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; + } elseif ($obj->halfday == -1) + { + $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; + } else { + $event->label = $obj->lastname; + } - $annee = date('Y', $event->date_start_in_calendar); - $mois = date('m', $event->date_start_in_calendar); - $jour = date('d', $event->date_start_in_calendar); - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + $annee = date('Y', $event->date_start_in_calendar); + $mois = date('m', $event->date_start_in_calendar); + $jour = date('d', $event->date_start_in_calendar); + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - $eventarray[$daykey][] = $event; + do { + $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; - } while ($daykey <= $event->date_end_in_calendar); + $daykey += 60 * 60 * 24; + } while ($daykey <= $event->date_end_in_calendar); - $i++; - } - } + $i++; + } + } } // Complete $eventarray with external import Ical if (count($listofextcals)) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; - foreach ($listofextcals as $extcal) - { - $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics - $namecal = $extcal['name']; - $offsettz = $extcal['offsettz']; - $colorcal = $extcal['color']; - $buggedfile = $extcal['buggedfile']; - //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; - $ical = new ICal(); - $ical->parse($url); + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; + foreach ($listofextcals as $extcal) + { + $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics + $namecal = $extcal['name']; + $offsettz = $extcal['offsettz']; + $colorcal = $extcal['color']; + $buggedfile = $extcal['buggedfile']; + //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; + $ical = new ICal(); + $ical->parse($url); - // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... - //var_dump($ical->cal); exit; - $icalevents = array(); - if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] - if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... + //var_dump($ical->cal); exit; + $icalevents = array(); + if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] - if (count($icalevents) > 0) - { - // Duplicate all repeatable events into new entries - $moreicalevents = array(); - foreach ($icalevents as $icalevent) - { - if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event - { - //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); - if ($icalevent['DTSTART;VALUE=DATE']) //fullday event - { - $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) - { - $datecurstart = $icalevent['DTSTART']['unixtime']; - $datecurend = $icalevent['DTEND']['unixtime']; - if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) - { - //var_dump($ical->cal); - $tmpcurstart = $datecurstart; - $tmpcurend = $datecurend; - $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; - $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; - //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); - // Edit datecurstart and datecurend - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; - } - // datecurstart and datecurend are now GMT date - //var_dump($datecurstart); var_dump($datecurend); exit; - } else { - // Not a recongized record - dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); - continue; - } - //print 'xx'.$datecurstart;exit; + if (count($icalevents) > 0) + { + // Duplicate all repeatable events into new entries + $moreicalevents = array(); + foreach ($icalevents as $icalevent) + { + if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event + { + //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); + if ($icalevent['DTSTART;VALUE=DATE']) //fullday event + { + $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) + { + $datecurstart = $icalevent['DTSTART']['unixtime']; + $datecurend = $icalevent['DTEND']['unixtime']; + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) + { + //var_dump($ical->cal); + $tmpcurstart = $datecurstart; + $tmpcurend = $datecurend; + $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; + $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; + //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); + // Edit datecurstart and datecurend + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } + // datecurstart and datecurend are now GMT date + //var_dump($datecurstart); var_dump($datecurend); exit; + } else { + // Not a recongized record + dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); + continue; + } + //print 'xx'.$datecurstart;exit; - $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); - $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); - $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; - if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show - if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show + $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); + $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); + $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show + if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show - $numofevent = 0; - while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) - { - if ($datecurend >= $firstdaytoshow) // We add event - { - $newevent = $icalevent; - unset($newevent['RRULE']); - if ($icalevent['DTSTART;VALUE=DATE']) - { - $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); - $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); - } else { - $newevent['DTSTART'] = $datecurstart; - $newevent['DTEND'] = $datecurend; - } - $moreicalevents[] = $newevent; - } - // Jump on next occurence - $numofevent++; - $savdatecurstart = $datecurstart; - if ($icalevent['RRULE']['FREQ'] == 'DAILY') - { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); - } - if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') - { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); - } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') - { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); - } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') - { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); - } - // Test to avoid infinite loop ($datecurstart must increase) - if ($savdatecurstart >= $datecurstart) - { - dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); - $datecurstart += 3600 * 24 * 7; - $datecurend += 3600 * 24 * 7; - } - } - } - } - $icalevents = array_merge($icalevents, $moreicalevents); + $numofevent = 0; + while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) + { + if ($datecurend >= $firstdaytoshow) // We add event + { + $newevent = $icalevent; + unset($newevent['RRULE']); + if ($icalevent['DTSTART;VALUE=DATE']) + { + $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); + $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); + } else { + $newevent['DTSTART'] = $datecurstart; + $newevent['DTEND'] = $datecurend; + } + $moreicalevents[] = $newevent; + } + // Jump on next occurence + $numofevent++; + $savdatecurstart = $datecurstart; + if ($icalevent['RRULE']['FREQ'] == 'DAILY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); + } + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); + } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); + } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); + } + // Test to avoid infinite loop ($datecurstart must increase) + if ($savdatecurstart >= $datecurstart) + { + dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); + $datecurstart += 3600 * 24 * 7; + $datecurend += 3600 * 24 * 7; + } + } + } + } + $icalevents = array_merge($icalevents, $moreicalevents); - // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray - foreach ($icalevents as $icalevent) - { - //var_dump($icalevent); + // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray + foreach ($icalevents as $icalevent) + { + //var_dump($icalevent); - //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; - if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; + if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. - // Create a new object action - $event = new ActionComm($db); - $addevent = false; - if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event - { - // For full day events, date are also GMT but they wont but converted using tz during output - $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - //print 'x'.$datestart.'-'.$dateend;exit; - //print dol_print_date($dateend,'dayhour','gmt'); - $event->fulldayevent = 1; - $addevent = true; - } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) - { - $datestart = $icalevent['DTSTART']; - $dateend = $icalevent['DTEND']; + // Create a new object action + $event = new ActionComm($db); + $addevent = false; + if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event + { + // For full day events, date are also GMT but they wont but converted using tz during output + $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + //print 'x'.$datestart.'-'.$dateend;exit; + //print dol_print_date($dateend,'dayhour','gmt'); + $event->fulldayevent = 1; + $addevent = true; + } elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) + { + $datestart = $icalevent['DTSTART']; + $dateend = $icalevent['DTEND']; - $datestart += +($offsettz * 3600); - $dateend += +($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); - $addevent = true; - //var_dump($offsettz); - //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); - } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) - { - $datestart = $icalevent['DTSTART']['unixtime']; - $dateend = $icalevent['DTEND']['unixtime']; + $addevent = true; + //var_dump($offsettz); + //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); + } elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) + { + $datestart = $icalevent['DTSTART']['unixtime']; + $dateend = $icalevent['DTEND']['unixtime']; - $datestart += +($offsettz * 3600); - $dateend += +($offsettz * 3600); + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); - // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' - if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 - { - // TODO - } - // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) - if ($buggedfile === 'uselocalandtzdaylight') // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer - { - $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); - $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); - $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); - $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); + // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' + if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 + { + // TODO + } + // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) + if ($buggedfile === 'uselocalandtzdaylight') // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer + { + $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); + $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); + $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); + $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); $tmps = -1 * $localtzs->getOffset($localdts); $tmpe = -1 * $localtze->getOffset($localdte); $datestart += $tmps; $dateend += $tmpe; //var_dump($datestart); - } - $addevent = true; - } + } + $addevent = true; + } - if ($addevent) - { - $event->id = $icalevent['UID']; - $event->ref = $event->id; + if ($addevent) + { + $event->id = $icalevent['UID']; + $event->ref = $event->id; - $userId = $userstatic->findUserIdByEmail($namecal); - if (!empty($userId) && $userId > 0) - { - $event->userassigned[$userId] = $userId; - $event->percentage = -1; - } - else { - $event->type_code = "ICALEVENT"; - } + $userId = $userstatic->findUserIdByEmail($namecal); + if (!empty($userId) && $userId > 0) + { + $event->userassigned[$userId] = $userId; + $event->percentage = -1; + } + else { + $event->type_code = "ICALEVENT"; + } - $event->icalname = $namecal; - $event->icalcolor = $colorcal; - $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. - $event->datep = $datestart + $usertime; - $event->datef = $dateend + $usertime; + $event->icalname = $namecal; + $event->icalcolor = $colorcal; + $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep = $datestart + $usertime; + $event->datef = $dateend + $usertime; - if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; - elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); - else $event->label = $langs->trans("ExtSiteNoLabel"); + if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; + elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); + else $event->label = $langs->trans("ExtSiteNoLabel"); - // Priority (see https://www.kanzaki.com/docs/ical/priority.html) - // LOW = 0 to 4 - // MEDIUM = 5 - // HIGH = 6 to 9 - if ($icalevent['PRIORITY']) $event->priority = $icalevent['PRIORITY']; + // Priority (see https://www.kanzaki.com/docs/ical/priority.html) + // LOW = 0 to 4 + // MEDIUM = 5 + // HIGH = 6 to 9 + if ($icalevent['PRIORITY']) $event->priority = $icalevent['PRIORITY']; - // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) - if ($icalevent['TRANSP']) - { - if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free - if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy + // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) + if ($icalevent['TRANSP']) + { + if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free + if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy - // TODO: MS outlook states - // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free - // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:OPAQUE => Work another place - // X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE + TRANSP:OPAQUE => With reservations - // X-MICROSOFT-CDO-BUSYSTATUS:BUSY + TRANSP:OPAQUE => Busy - // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site - } + // TODO: MS outlook states + // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free + // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:OPAQUE => Work another place + // X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE + TRANSP:OPAQUE => With reservations + // X-MICROSOFT-CDO-BUSYSTATUS:BUSY + TRANSP:OPAQUE => Busy + // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site + } - if ($icalevent['LOCATION']) $event->location = $icalevent['LOCATION']; + if ($icalevent['LOCATION']) $event->location = $icalevent['LOCATION']; - $event->date_start_in_calendar = $event->datep; + $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; - else $event->date_end_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - //print 'x'.$datestart.'-'.$dateend;exit; - } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + //print 'x'.$datestart.'-'.$dateend;exit; + } - // Add event into $eventarray if date range are ok. - if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) - { - //print 'x'.$datestart.'-'.$dateend;exit; - //print 'x'.$datestart.'-'.$dateend;exit; - //print 'x'.$datestart.'-'.$dateend;exit; - // This record is out of visible range - } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + // Add event into $eventarray if date range are ok. + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) + { + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + // This record is out of visible range + } else { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - // daykey must be date that represent day box in calendar so must be a user time - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); - do { - //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; - $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; - } while ($loop); - } - } - } - } - } + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + // daykey must be date that represent day box in calendar so must be a user time + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); + do { + //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; + } while ($loop); + } + } + } + } + } } @@ -1192,48 +1192,48 @@ print $s; if (empty($action) || $action == 'show_month') // View by month { - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam = preg_replace('/action=show_month&?/i', '', $newparam); - $newparam = preg_replace('/action=show_week&?/i', '', $newparam); - $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam .= '&viewcal=1'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewcal=1'; - print '
'; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
'; + print '
'; + print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
'; - print '
'; - print ''; - print ' '; + print '
'; + print '
'; + print ' '; // Column title of weeks numbers echo ' '; - $i = 0; - while ($i < 7) - { - print ' '."\n"; - $i++; - } - echo ' '."\n"; + $i = 0; + while ($i < 7) + { + print ' '."\n"; + $i++; + } + echo ' '."\n"; - $todayarray = dol_getdate($now, 'fast'); - $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); + $todayarray = dol_getdate($now, 'fast'); + $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); - // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) - //var_dump($eventarray); - for ($iter_week = 0; $iter_week < 6; $iter_week++) { - echo " \n"; + // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) + //var_dump($eventarray); + for ($iter_week = 0; $iter_week < 6; $iter_week++) { + echo " \n"; // Get date of the current day, format 'yyyy-mm-dd' if ($tmpday <= 0) // If number of the current day is in previous month { @@ -1252,130 +1252,130 @@ if (empty($action) || $action == 'show_month') // View by month // Show the week number, and define column width echo ' '; - for ($iter_day = 0; $iter_day < 7; $iter_day++) { - if ($tmpday <= 0) { - /* Show days before the beginning of the current month (previous month) */ - $style = 'cal_other_month cal_past'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo ' \n"; - } elseif ($tmpday <= $max_day_in_month) { - /* Show days of the current month */ - $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); - $style = 'cal_current_month'; - if ($iter_day == 6) $style .= ' cal_current_month_right'; - $today = 0; - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; - if ($today) $style = 'cal_today'; - if ($curtime < $todaytms) $style .= ' cal_past'; + for ($iter_day = 0; $iter_day < 7; $iter_day++) { + if ($tmpday <= 0) { + /* Show days before the beginning of the current month (previous month) */ + $style = 'cal_other_month cal_past'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + echo ' \n"; + } elseif ($tmpday <= $max_day_in_month) { + /* Show days of the current month */ + $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_current_month_right'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($today) $style = 'cal_today'; + if ($curtime < $todaytms) $style .= ' cal_past'; //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); - echo ' \n"; - } else { - /* Show days after the current month (next month) */ - $style = 'cal_other_month'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo ' \n"; - } - $tmpday++; - } - echo " \n"; - } - print "
#'; - $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); - if (!empty($conf->dol_optimize_smallscreen)) - { - $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); - print $langs->trans($labelshort[$numdayinweek]); - } else print $langs->trans("Day".$numdayinweek); - print '
'; + $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); + if (!empty($conf->dol_optimize_smallscreen)) + { + $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); + print $langs->trans($labelshort[$numdayinweek]); + } else print $langs->trans("Day".$numdayinweek); + print '
'.$numweek0.''; - show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo " '; + show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo " '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo " '; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo "
\n"; + echo ' '; + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo " \n"; + } else { + /* Show days after the current month (next month) */ + $style = 'cal_other_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + echo ' '; + show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo "\n"; + } + $tmpday++; + } + echo " \n"; + } + print "\n"; print '
'; print ''; print ''; print ''; } elseif ($action == 'show_week') { - // View by week - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam = preg_replace('/action=show_month&?/i', '', $newparam); - $newparam = preg_replace('/action=show_week&?/i', '', $newparam); - $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam .= '&viewweek=1'; + // View by week + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewweek=1'; - print '
'; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
'; + print '
'; + print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
'; - print '
'; - print ''; - print ' '; - $i = 0; - while ($i < 7) { - echo ' \n"; - $i++; - } - echo " \n"; + print '
'; + print '
'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; + print ' '; + $i = 0; + while ($i < 7) { + echo ' \n"; + $i++; + } + echo " \n"; - echo " \n"; + echo " \n"; - for ($iter_day = 0; $iter_day < 7; $iter_day++) { - // Show days of the current week + for ($iter_day = 0; $iter_day < 7; $iter_day++) { + // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, true); $tmpday = $tmparray['mday']; $tmpmonth = $tmparray['mon']; $tmpyear = $tmparray['year']; - $style = 'cal_current_month'; - if ($iter_day == 6) $style .= ' cal_other_month_right'; - $today = 0; - $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; - if ($today) $style = 'cal_today'; + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today'; - echo ' \n"; - } - echo " \n"; + echo ' \n"; + } + echo " \n"; - print "
'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; - show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); - echo "
'; + show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); + echo "
\n"; + print "\n"; print '
'; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; } else // View by day { - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/action=show_month&?/i', '', $newparam); - $newparam = preg_replace('/action=show_week&?/i', '', $newparam); - $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); - $newparam .= '&viewday=1'; - // Code to show just one day - $style = 'cal_current_month cal_current_month_oneday'; - $today = 0; - $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; - //if ($today) $style='cal_today'; + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); + $newparam .= '&viewday=1'; + // Code to show just one day + $style = 'cal_current_month cal_current_month_oneday'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + //if ($today) $style='cal_today'; - $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); - $arraytimestamp = dol_getdate($timestamp); + $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); + $arraytimestamp = dol_getdate($timestamp); - print '
'; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
'; + print '
'; + print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
'; - print '
'; - echo ''; + print '
'; + echo '
'; - echo ' '; - echo ' \n"; - echo " \n"; + echo ' '; + echo ' \n"; + echo " \n"; - /* + /* echo '
'; echo '
'; echo '
'; @@ -1460,401 +1460,401 @@ $db->close(); */ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) { - global $user, $conf, $langs; - global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form - global $theme_datacolor; - global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; + global $user, $conf, $langs; + global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form + global $theme_datacolor; + global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; - $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - print "\n"; + print "\n"; - // Line with title of day - $curtime = dol_mktime(0, 0, 0, $month, $day, $year); - print '
'."\n"; + // Line with title of day + $curtime = dol_mktime(0, 0, 0, $month, $day, $year); + print '
'."\n"; - if ($nonew <= 0) - { - print '
'; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) - { - $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + if ($nonew <= 0) + { + print '
'; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - print ''; - print img_picto($langs->trans("NewAction"), 'edit_add.png'); - print ''; - } - print '
'."\n"; - } + //$param='month='.$monthshown.'&year='.$year; + $hourminsec = '100000'; + print ''; + print img_picto($langs->trans("NewAction"), 'edit_add.png'); + print ''; + } + print '
'."\n"; + } - if ($nonew < 0) - { - print '
'; - return; - } + if ($nonew < 0) + { + print '
'; + return; + } - // Line with td contains all div of each events - print '
'; - print '
'; + // Line with td contains all div of each events + print '
'; + print '
'; - //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); - $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); - $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 + $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... //var_dump($colorindexused); - foreach ($eventarray as $daykey => $notused) - { - $annee = date('Y', $daykey); - $mois = date('m', $daykey); - $jour = date('d', $daykey); - if ($day == $jour && $month == $mois && $year == $annee) - { - foreach ($eventarray[$daykey] as $index => $event) - { - if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) - { - $keysofuserassigned = array_keys($event->userassigned); - $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); + foreach ($eventarray as $daykey => $notused) + { + $annee = date('Y', $daykey); + $mois = date('m', $daykey); + $jour = date('d', $daykey); + if ($day == $jour && $month == $mois && $year == $annee) + { + foreach ($eventarray[$daykey] as $index => $event) + { + if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) + { + $keysofuserassigned = array_keys($event->userassigned); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); - // Define $color (Hex string like '0088FF') and $cssclass of event - $color = -1; $cssclass = ''; $colorindex = -1; - if (in_array($user->id, $keysofuserassigned)) - { - $cssclass = 'family_mytasks'; + // Define $color (Hex string like '0088FF') and $cssclass of event + $color = -1; $cssclass = ''; $colorindex = -1; + if (in_array($user->id, $keysofuserassigned)) + { + $cssclass = 'family_mytasks'; - if (empty($cacheusers[$event->userownerid])) - { - $newuser = new User($db); - $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid] = $newuser; - } - //var_dump($cacheusers[$event->userownerid]->color); + if (empty($cacheusers[$event->userownerid])) + { + $newuser = new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid] = $newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file - { - $numical++; - if (!empty($event->icalname)) { - if (!isset($numicals[dol_string_nospecial($event->icalname)])) { - $numicals[dol_string_nospecial($event->icalname)] = 0; - } - $numicals[dol_string_nospecial($event->icalname)]++; - } + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; + } elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file + { + $numical++; + if (!empty($event->icalname)) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { + $numicals[dol_string_nospecial($event->icalname)] = 0; + } + $numicals[dol_string_nospecial($event->icalname)]++; + } - $color = ($event->icalcolor ? $event->icalcolor : -1); - $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - } elseif ($event->type_code == 'BIRTHDAY') - { - $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } else { - $numother++; - $color = ($event->icalcolor ? $event->icalcolor : -1); - $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); + } elseif ($event->type_code == 'BIRTHDAY') + { + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } else { + $numother++; + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - if (empty($cacheusers[$event->userownerid])) - { - $newuser = new User($db); - $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid] = $newuser; - } - //var_dump($cacheusers[$event->userownerid]->color); + if (empty($cacheusers[$event->userownerid])) + { + $newuser = new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid] = $newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; - } + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; + } - if ($color < 0) // Color was not set on user card. Set color according to color index. - { - // Define color index if not yet defined - $idusertouse = ($event->userownerid ? $event->userownerid : 0); - if (isset($colorindexused[$idusertouse])) - { - $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user - } else { - $colorindex = $nextindextouse; - $colorindexused[$idusertouse] = $colorindex; - if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color - } - //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
'; - // Define color - $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } - $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd; + if ($color < 0) // Color was not set on user card. Set color according to color index. + { + // Define color index if not yet defined + $idusertouse = ($event->userownerid ? $event->userownerid : 0); + if (isset($colorindexused[$idusertouse])) + { + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user + } else { + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color + } + //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
'; + // Define color + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } + $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd; - // Defined style to disable drag and drop feature - if ($event->type_code == 'AC_OTH_AUTO') - { - $cssclass .= " unmovable"; - } elseif ($event->type_code == 'ICALEVENT') - { - $cssclass .= " unmovable"; - } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { - $tmpyearend = date('Y', $event->date_end_in_calendar); - $tmpmonthend = date('m', $event->date_end_in_calendar); - $tmpdayend = date('d', $event->date_end_in_calendar); - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - { - $cssclass .= " unmovable"; - } - } else { - if ($user->rights->agenda->allactions->create || - (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) - { - $cssclass .= " movable cursormove"; - } else { - $cssclass .= " unmovable"; - } - } + // Defined style to disable drag and drop feature + if ($event->type_code == 'AC_OTH_AUTO') + { + $cssclass .= " unmovable"; + } elseif ($event->type_code == 'ICALEVENT') + { + $cssclass .= " unmovable"; + } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { + $tmpyearend = date('Y', $event->date_end_in_calendar); + $tmpmonthend = date('m', $event->date_end_in_calendar); + $tmpdayend = date('d', $event->date_end_in_calendar); + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + { + $cssclass .= " unmovable"; + } + } else { + if ($user->rights->agenda->allactions->create || + (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + $cssclass .= " movable cursormove"; + } else { + $cssclass .= " unmovable"; + } + } - $h = ''; $nowrapontd = 1; - if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } - if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } + $h = ''; $nowrapontd = 1; + if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } + if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } - // Show rect of event - print "\n"; - print ''."\n"; - print '
'; + // Show rect of event + print "\n"; + print ''."\n"; + print '
'; - //var_dump($event->userassigned); - //var_dump($event->transparency); - print '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; - print ''; - print ''; + // Status - Percent + $withstatus = 0; + if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') + { + $withstatus = 1; + if ($event->percentage >= 0) $withstatus = 2; + } + print '
'; + //var_dump($event->userassigned); + //var_dump($event->transparency); + print ''; + print ''; + print ''; - // Status - Percent - $withstatus = 0; - if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') - { - $withstatus = 1; - if ($event->percentage >= 0) $withstatus = 2; - } - print '
'; - $daterange = ''; + $daterange = ''; - if ($event->type_code == 'BIRTHDAY') // It's a birthday - { - print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); - } elseif ($event->type_code == 'HOLIDAY') - { - print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user'); - } elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') - { - // Picto - if (empty($event->fulldayevent)) - { - //print $event->getNomUrl(2).' '; - } + if ($event->type_code == 'BIRTHDAY') // It's a birthday + { + print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); + } elseif ($event->type_code == 'HOLIDAY') + { + print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user'); + } elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') + { + // Picto + if (empty($event->fulldayevent)) + { + //print $event->getNomUrl(2).' '; + } - // Date - if (empty($event->fulldayevent)) - { - // Show hours (start ... end) - $tmpyearstart = date('Y', $event->date_start_in_calendar); - $tmpmonthstart = date('m', $event->date_start_in_calendar); - $tmpdaystart = date('d', $event->date_start_in_calendar); - $tmpyearend = date('Y', $event->date_end_in_calendar); - $tmpmonthend = date('m', $event->date_end_in_calendar); - $tmpdayend = date('d', $event->date_end_in_calendar); - // Hour start - if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) - { - $daterange .= dol_print_date($event->date_start_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) - $daterange .= '-'; - //else - //print '...'; - } - } - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) - { - $daterange .= '...'; - } - } - // Hour end - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - $daterange .= dol_print_date($event->date_end_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user - } - } else { - if ($showinfo) - { - print $langs->trans("EventOnFullDay")."
\n"; - } - } + // Date + if (empty($event->fulldayevent)) + { + // Show hours (start ... end) + $tmpyearstart = date('Y', $event->date_start_in_calendar); + $tmpmonthstart = date('m', $event->date_start_in_calendar); + $tmpdaystart = date('d', $event->date_start_in_calendar); + $tmpyearend = date('Y', $event->date_end_in_calendar); + $tmpmonthend = date('m', $event->date_end_in_calendar); + $tmpdayend = date('d', $event->date_end_in_calendar); + // Hour start + if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) + { + $daterange .= dol_print_date($event->date_start_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) + $daterange .= '-'; + //else + //print '...'; + } + } + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) + { + $daterange .= '...'; + } + } + // Hour end + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + $daterange .= dol_print_date($event->date_end_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + } + } else { + if ($showinfo) + { + print $langs->trans("EventOnFullDay")."
\n"; + } + } - // Show title - $titletoshow = $daterange; - $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle); + // Show title + $titletoshow = $daterange; + $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle); - if ($event->type_code != 'ICALEVENT') { - $savlabel = $event->label ? $event->label : $event->libelle; - $event->label = $titletoshow; - $event->libelle = $titletoshow; - // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user. - $titletoshow = $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0); - $event->label = $savlabel; - $event->libelle = $savlabel; - } + if ($event->type_code != 'ICALEVENT') { + $savlabel = $event->label ? $event->label : $event->libelle; + $event->label = $titletoshow; + $event->libelle = $titletoshow; + // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user. + $titletoshow = $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0); + $event->label = $savlabel; + $event->libelle = $savlabel; + } - // Loop on each assigned user - $listofusertoshow = ''; - $posuserassigned = 0; - foreach ($event->userassigned as $tmpid => $tmpdata) - { - if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
'; - $posuserassigned++; - if (empty($cacheusers[$tmpid])) - { - $newuser = new User($db); - $newuser->fetch($tmpid); - $cacheusers[$tmpid] = $newuser; - } + // Loop on each assigned user + $listofusertoshow = ''; + $posuserassigned = 0; + foreach ($event->userassigned as $tmpid => $tmpdata) + { + if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
'; + $posuserassigned++; + if (empty($cacheusers[$tmpid])) + { + $newuser = new User($db); + $newuser->fetch($tmpid); + $cacheusers[$tmpid] = $newuser; + } - $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); - } + $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + } - print $titletoshow; - print $listofusertoshow; + print $titletoshow; + print $listofusertoshow; - if ($event->type_code == 'ICALEVENT') print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; + if ($event->type_code == 'ICALEVENT') print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; - $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); - $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); + $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); + $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); - // If action related to company / contact - $linerelatedto = ''; - if ($thirdparty_id > 0) - { - if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) - { - $thirdparty = new Societe($db); - $thirdparty->fetch($thirdparty_id); - $cachethirdparties[$thirdparty_id] = $thirdparty; - } else $thirdparty = $cachethirdparties[$thirdparty_id]; - if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); - } - if (!empty($contact_id) && $contact_id > 0) - { - if (!is_object($cachecontacts[$contact_id])) - { - $contact = new Contact($db); - $contact->fetch($contact_id); - $cachecontacts[$contact_id] = $contact; - } else $contact = $cachecontacts[$contact_id]; - if ($linerelatedto) $linerelatedto .= ' '; - if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); - } - if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ($linerelatedto) $linerelatedto .= '
'; - $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); - } - if ($linerelatedto) print '
'.$linerelatedto; - } + // If action related to company / contact + $linerelatedto = ''; + if ($thirdparty_id > 0) + { + if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) + { + $thirdparty = new Societe($db); + $thirdparty->fetch($thirdparty_id); + $cachethirdparties[$thirdparty_id] = $thirdparty; + } else $thirdparty = $cachethirdparties[$thirdparty_id]; + if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); + } + if (!empty($contact_id) && $contact_id > 0) + { + if (!is_object($cachecontacts[$contact_id])) + { + $contact = new Contact($db); + $contact->fetch($contact_id); + $cachecontacts[$contact_id] = $contact; + } else $contact = $cachecontacts[$contact_id]; + if ($linerelatedto) $linerelatedto .= ' '; + if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); + } + if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if ($linerelatedto) $linerelatedto .= '
'; + $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); + } + if ($linerelatedto) print '
'.$linerelatedto; + } - // Show location - if ($showinfo) - { - if ($event->location) - { - print '
'; - print $langs->trans("Location").': '.$event->location; - } - } + // Show location + if ($showinfo) + { + if ($event->location) + { + print '
'; + print $langs->trans("Location").': '.$event->location; + } + } - print '
'; - if ($withstatus) print $event->getLibStatut(3, 1); - else print ' '; - print '
'; - print ''."\n"; - $i++; - } else { - print ''.img_picto("all", "1downarrow_selected.png").' ...'; - print ' +'.(count($eventarray[$daykey]) - $maxprint); - print ''; - break; - //$ok=false; // To avoid to show twice the link - } - } + print '
'; + if ($withstatus) print $event->getLibStatut(3, 1); + else print ' '; + print '
'; + print '
'."\n"; + $i++; + } else { + print ''.img_picto("all", "1downarrow_selected.png").' ...'; + print ' +'.(count($eventarray[$daykey]) - $maxprint); + print ''; + break; + //$ok=false; // To avoid to show twice the link + } + } - break; - } - } - if (!$i) print ' '; + break; + } + } + if (!$i) print ' '; - if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) - { - print '
'.img_picto("all", "1downarrow_selected.png").' +'.$langs->trans("More").'...
'; - //print ' +'.(count($eventarray[$daykey])-$maxprint); - print ''."\n"; - } + print ''."\n"; + } - print '
'; // td tr + print ''; // td tr - print ''; // table - print "\n"; + print ''; // table + print "\n"; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index db59fd5f942..7bce96633fc 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1291,21 +1291,21 @@ if ($resql) foreach ($toselect as $checked) { if ($tmpproposal->fetch($checked)) { if ($tmpproposal->statut == 0) { - if ($tmpproposal->valid($user)){ - setEventMessage($tmpproposal->ref . " " . $langs->trans('PassedInOpenStatus'), 'mesgs'); + if ($tmpproposal->valid($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); $error++; } } else { - setEventMessage($tmpproposal->ref . " " . $langs->trans('IsNotADraft'), 'errors'); + setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors'); $error++; } } dol_print_error($db); $error++; } - if ($error){ + if ($error) { $db->rollback(); } else { $db->commit(); @@ -1323,13 +1323,13 @@ if ($resql) if ($tmpproposal->statut == 1) { $tmpproposal->statut = 2; if ($tmpproposal->update($user)) { - setEventMessage($tmpproposal->ref . " " . $langs->trans('Signed'), 'mesgs'); + setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); } else { dol_print_error($db); $error++; } } else { - setEventMessage($tmpproposal->ref . " " . $langs->trans('CantBeSign'), 'errors'); + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); $error++; } } else { @@ -1337,7 +1337,7 @@ if ($resql) $error++; } } - if ($error){ + if ($error) { $db->rollback(); } else { $db->commit(); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index e4d432b234a..75f9457b45f 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -29,229 +29,229 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; class Orders extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid', - 'date' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid', + 'date' + ); - /** - * @var Commande $commande {@type Commande} - */ - public $commande; + /** + * @var Commande $commande {@type Commande} + */ + public $commande; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->commande = new Commande($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->commande = new Commande($this->db); + } - /** - * Get properties of an order object by id - * - * Return an array with order informations - * - * @param int $id ID of order - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + /** + * Get properties of an order object by id * - * @throws RestException - */ - public function get($id, $contact_list = 1) - { - return $this->_fetch($id, '', '', $contact_list); - } + * Return an array with order informations + * + * @param int $id ID of order + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id, $contact_list = 1) + { + return $this->_fetch($id, '', '', $contact_list); + } - /** - * Get properties of an order object by ref - * - * Return an array with order informations - * - * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref/{ref} - * - * @throws RestException - */ - public function getByRef($ref, $contact_list = 1) - { - return $this->_fetch('', $ref, '', $contact_list); - } + /** + * Get properties of an order object by ref + * + * Return an array with order informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', $contact_list); + } - /** - * Get properties of an order object by ref_ext - * - * Return an array with order informations - * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref_ext/{ref_ext} - * - * @throws RestException - */ - public function getByRefExt($ref_ext, $contact_list = 1) - { - return $this->_fetch('', '', $ref_ext, $contact_list); - } + /** + * Get properties of an order object by ref_ext + * + * Return an array with order informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, $contact_list); + } - /** - * Get properties of an order object - * - * Return an array with order informations - * - * @param int $id ID of order + /** + * Get properties of an order object + * + * Return an array with order informations + * + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @throws RestException - */ - private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) - { - if (!DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) + { + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } - $result = $this->commande->fetch($id, $ref, $ref_ext); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id, $ref, $ref_ext); + if (!$result) { + throw new RestException(404, 'Order not found'); + } - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); - $this->commande->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->commande); - } + // Add external contacts ids + $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); + $this->commande->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->commande); + } - /** - * List orders - * - * Get a list of orders - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of order objects - * - * @throws RestException 404 Not found - * @throws RestException 503 Error - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') - { - global $db, $conf; + /** + * List orders + * + * Get a list of orders + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException 404 Not found + * @throws RestException 503 Error + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= " FROM ".MAIN_DB_PREFIX."commande as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."commande as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $db->plimit($limit + 1, $offset); - } + $sql .= $db->plimit($limit + 1, $offset); + } - dol_syslog("API Rest request"); - $result = $db->query($sql); + dol_syslog("API Rest request"); + $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i = 0; - while ($i < $min) - { - $obj = $db->fetch_object($result); - $commande_static = new Commande($db); - if ($commande_static->fetch($obj->rowid)) { - // Add external contacts ids - $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); - $obj_ret[] = $this->_cleanObjectDatas($commande_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No order found'); - } + if ($result) + { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $commande_static = new Commande($db); + if ($commande_static->fetch($obj->rowid)) { + // Add external contacts ids + $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); + $obj_ret[] = $this->_cleanObjectDatas($commande_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No order found'); + } return $obj_ret; - } + } - /** - * Create a sale order - * - * Exemple: { "socid": 2, "date": 1595196000, "type": 0, "lines": [{ "fk_product": 2, "qty": 1 }] } - * - * @param array $request_data Request data - * @return int ID of order - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + /** + * Create a sale order + * + * Exemple: { "socid": 2, "date": 1595196000, "type": 0, "lines": [{ "fk_product": 2, "qty": 1 }] } + * + * @param array $request_data Request data + * @return int ID of order + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); - } - // Check mandatory fields - $result = $this->_validate($request_data); + } + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->commande->$field = $value; - } - /*if (isset($request_data["lines"])) { + foreach ($request_data as $field => $value) { + $this->commande->$field = $value; + } + /*if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { array_push($lines, (object) $line); @@ -259,241 +259,241 @@ class Orders extends DolibarrApi $this->commande->lines = $lines; }*/ - if ($this->commande->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating order", array_merge(array($this->commande->error), $this->commande->errors)); - } + if ($this->commande->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating order", array_merge(array($this->commande->error), $this->commande->errors)); + } - return $this->commande->id; - } + return $this->commande->id; + } - /** - * Get lines of an order - * - * @param int $id Id of order - * - * @url GET {id}/lines - * - * @return int - */ - public function getLines($id) - { - if (!DolibarrApiAccess::$user->rights->commande->lire) { + /** + * Get lines of an order + * + * @param int $id Id of order + * + * @url GET {id}/lines + * + * @return int + */ + public function getLines($id) + { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->commande->getLinesArray(); - $result = array(); - foreach ($this->commande->lines as $line) { - array_push($result, $this->_cleanObjectDatas($line)); - } - return $result; - } + } + $this->commande->getLinesArray(); + $result = array(); + foreach ($this->commande->lines as $line) { + array_push($result, $this->_cleanObjectDatas($line)); + } + return $result; + } - /** - * Add a line to given order - * - * @param int $id Id of order to update - * @param array $request_data OrderLine data - * - * @url POST {id}/lines - * - * @return int - */ - public function postLine($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + /** + * Add a line to given order + * + * @param int $id Id of order to update + * @param array $request_data OrderLine data + * + * @url POST {id}/lines + * + * @return int + */ + public function postLine($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + } $request_data = (object) $request_data; - $updateRes = $this->commande->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, - 'HT', - 0, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->rang, - $request_data->special_code, - $request_data->fk_parent_line, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->array_options, - $request_data->fk_unit, - $request_data->origin, - $request_data->origin_id, - $request_data->multicurrency_subprice, - $request_data->ref_ext - ); + $updateRes = $this->commande->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $request_data->fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $request_data->origin, + $request_data->origin_id, + $request_data->multicurrency_subprice, + $request_data->ref_ext + ); - if ($updateRes > 0) { - return $updateRes; - } else { - throw new RestException(400, $this->commande->error); - } - } + if ($updateRes > 0) { + return $updateRes; + } else { + throw new RestException(400, $this->commande->error); + } + } - /** - * Update a line to given order - * - * @param int $id Id of order to update - * @param int $lineid Id of line to update - * @param array $request_data OrderLine data - * - * @url PUT {id}/lines/{lineid} - * - * @return array|bool - */ - public function putLine($id, $lineid, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + /** + * Update a line to given order + * + * @param int $id Id of order to update + * @param int $lineid Id of line to update + * @param array $request_data OrderLine data + * + * @url PUT {id}/lines/{lineid} + * + * @return array|bool + */ + public function putLine($id, $lineid, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + } $request_data = (object) $request_data; - $updateRes = $this->commande->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->date_start, - $request_data->date_end, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->fk_unit, - $request_data->multicurrency_subprice, + $updateRes = $this->commande->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, 0, - $request_data->ref_ext - ); + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit, + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + } - /** - * Delete a line to given order - * - * - * @param int $id Id of order to update - * @param int $lineid Id of line to delete - * - * @url DELETE {id}/lines/{lineid} - * - * @return int - * - * @throws RestException 401 - * @throws RestException 404 - */ - public function deleteLine($id, $lineid) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + /** + * Delete a line to given order + * + * + * @param int $id Id of order to update + * @param int $lineid Id of line to delete + * + * @url DELETE {id}/lines/{lineid} + * + * @return int + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function deleteLine($id, $lineid) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } else { - throw new RestException(405, $this->commande->error); - } - } + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } else { + throw new RestException(405, $this->commande->error); + } + } - /** - * Get contacts of given order - * - * Return an array with contact informations - * - * @param int $id ID of order + /** + * Get contacts of given order + * + * Return an array with contact informations + * + * @param int $id ID of order * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) - * - * @url GET {id}/contacts - * - * @return array data without useless information - * - * @throws RestException - */ - public function getContacts($id, $type = '') - { - if (! DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } + * + * @url GET {id}/contacts + * + * @return array data without useless information + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (! DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } - $result = $this->commande->fetch($id); - if ( ! $result ) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Order not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); + $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); - return $this->_cleanObjectDatas($contacts); - } + return $this->_cleanObjectDatas($contacts); + } - /** + /** * Add a contact type of given order * * @param int $id Id of order to update @@ -504,43 +504,43 @@ class Orders extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 + * @throws RestException 401 + * @throws RestException 404 */ - public function postContact($id, $contactid, $type) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + public function postContact($id, $contactid, $type) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->add_contact($contactid, $type, 'external'); + $result = $this->commande->add_contact($contactid, $type, 'external'); - if ($result < 0) { - throw new RestException(500, 'Error when added the contact'); - } + if ($result < 0) { + throw new RestException(500, 'Error when added the contact'); + } - if ($result == 0) { - throw new RestException(304, 'contact already added'); - } + if ($result == 0) { + throw new RestException(304, 'contact already added'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contact linked to the order' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the order' + ) + ); + } - /** + /** * Unlink a contact type of given order * * @param int $id Id of order to update @@ -550,143 +550,143 @@ class Orders extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ - public function deleteContact($id, $rowid) - { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + public function deleteContact($id, $rowid) + { + if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (! $result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (! $result) { + throw new RestException(404, 'Order not found'); + } if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->delete_linked_contact($rowid); + $result = $this->commande->delete_linked_contact($rowid); - if (!$result) { - throw new RestException(500, 'Error when deleted the contact'); - } + if (!$result) { + throw new RestException(500, 'Error when deleted the contact'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contact unlinked from order' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact unlinked from order' + ) + ); + } - /** - * Update order general fields (won't touch lines of order) - * - * @param int $id Id of order to update - * @param array $request_data Datas - * - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + /** + * Update order general fields (won't touch lines of order) + * + * @param int $id Id of order to update + * @param array $request_data Datas + * + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->commande->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->commande->$field = $value; + } // Update availability if (!empty($this->commande->availability_id)) { - if ($this->commande->availability($this->commande->availability_id) < 0) + if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - if ($this->commande->update(DolibarrApiAccess::$user) > 0) - { - return $this->get($id); - } else { - throw new RestException(500, $this->commande->error); - } - } + if ($this->commande->update(DolibarrApiAccess::$user) > 0) + { + return $this->get($id); + } else { + throw new RestException(500, $this->commande->error); + } + } - /** - * Delete order - * - * @param int $id Order ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->commande->supprimer) { + /** + * Delete order + * + * @param int $id Order ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->commande->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when deleting order : '.$this->commande->error); - } + if (!$this->commande->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting order : '.$this->commande->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Order deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order deleted' + ) + ); + } - /** - * Validate an order - * + /** + * Validate an order + * * If you get a bad value for param notrigger check, provide this in body - * { - * "idwarehouse": 0, - * "notrigger": 0 - * } - * - * @param int $id Order ID - * @param int $idwarehouse Warehouse ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * - * @url POST {id}/validate - * + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - * - * @return array - */ - public function validate($id, $idwarehouse = 0, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + * + * @return array + */ + public function validate($id, $idwarehouse = 0, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); @@ -694,288 +694,288 @@ class Orders extends DolibarrApi $result = $this->commande->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { - throw new RestException(500, 'Error when validating Order: '.$this->commande->error); + throw new RestException(500, 'Error when validating Order: '.$this->commande->error); + } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->commande->fetchObjectLinked(); + $this->commande->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->commande); - } + return $this->_cleanObjectDatas($this->commande); + } - /** - * Tag the order as validated (opened) - * - * Function used when order is reopend after being closed. - * - * @param int $id Id of the order - * - * @url POST {id}/reopen - * - * @return int - * - * @throws RestException 304 - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function reopen($id) - { + /** + * Tag the order as validated (opened) + * + * Function used when order is reopend after being closed. + * + * @param int $id Id of the order + * + * @url POST {id}/reopen + * + * @return int + * + * @throws RestException 304 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function reopen($id) + { - if (!DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Order ID is mandatory'); - } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + if (!DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Order ID is mandatory'); + } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } - $result = $this->commande->set_reopen(DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(405, $this->commande->error); - } elseif ($result == 0) { - throw new RestException(304); - } + $result = $this->commande->set_reopen(DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(405, $this->commande->error); + } elseif ($result == 0) { + throw new RestException(304); + } - return $result; - } + return $result; + } - /** - * Classify the order as invoiced. Could be also called setbilled - * - * @param int $id Id of the order - * - * @url POST {id}/setinvoiced - * - * @return int - * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function setinvoiced($id) - { + /** + * Classify the order as invoiced. Could be also called setbilled + * + * @param int $id Id of the order + * + * @url POST {id}/setinvoiced + * + * @return int + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function setinvoiced($id) + { - if (!DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Order ID is mandatory'); - } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + if (!DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Order ID is mandatory'); + } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } - $result = $this->commande->classifyBilled(DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(400, $this->commande->error); - } - - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $this->commande->fetchObjectLinked(); - - return $this->_cleanObjectDatas($this->commande); - } - - /** - * Close an order (Classify it as "Delivered") - * - * @param int $id Order ID - * @param int $notrigger Disabled triggers - * - * @url POST {id}/close - * - * @return int - */ - public function close($id, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->commande->cloture(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already closed'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Order: '.$this->commande->error); - } - - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $this->commande->fetchObjectLinked(); - - return $this->_cleanObjectDatas($this->commande); - } - - /** - * Set an order to draft - * - * @param int $id Order ID - * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) - * - * @url POST {id}/settodraft - * - * @return array - */ - public function settodraft($id, $idwarehouse = -1) - { - if (!DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } - $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } - - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->commande->setDraft(DolibarrApiAccess::$user, $idwarehouse); - if ($result == 0) { - throw new RestException(304, 'Nothing done. May be object is already closed'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Order: '.$this->commande->error); - } + $result = $this->commande->classifyBilled(DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(400, $this->commande->error); + } $result = $this->commande->fetch($id); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + if (!$result) { + throw new RestException(404, 'Order not found'); + } - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->commande->fetchObjectLinked(); + $this->commande->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->commande); - } + return $this->_cleanObjectDatas($this->commande); + } + + /** + * Close an order (Classify it as "Delivered") + * + * @param int $id Order ID + * @param int $notrigger Disabled triggers + * + * @url POST {id}/close + * + * @return int + */ + public function close($id, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->commande->cloture(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already closed'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Order: '.$this->commande->error); + } + + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->commande->fetchObjectLinked(); + + return $this->_cleanObjectDatas($this->commande); + } + + /** + * Set an order to draft + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) + * + * @url POST {id}/settodraft + * + * @return array + */ + public function settodraft($id, $idwarehouse = -1) + { + if (!DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->commande->setDraft(DolibarrApiAccess::$user, $idwarehouse); + if ($result == 0) { + throw new RestException(304, 'Nothing done. May be object is already closed'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Order: '.$this->commande->error); + } + + $result = $this->commande->fetch($id); + if (!$result) { + throw new RestException(404, 'Order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->commande->fetchObjectLinked(); + + return $this->_cleanObjectDatas($this->commande); + } - /** - * Create an order using an existing proposal. - * - * - * @param int $proposalid Id of the proposal - * - * @url POST /createfromproposal/{proposalid} - * - * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function createOrderFromProposal($proposalid) - { + /** + * Create an order using an existing proposal. + * + * + * @param int $proposalid Id of the proposal + * + * @url POST /createfromproposal/{proposalid} + * + * @return int + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function createOrderFromProposal($proposalid) + { - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if (!DolibarrApiAccess::$user->rights->propal->lire) { - throw new RestException(401); - } - if (!DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } - if (empty($proposalid)) { - throw new RestException(400, 'Proposal ID is mandatory'); - } + if (!DolibarrApiAccess::$user->rights->propal->lire) { + throw new RestException(401); + } + if (!DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + if (empty($proposalid)) { + throw new RestException(400, 'Proposal ID is mandatory'); + } - $propal = new Propal($this->db); - $result = $propal->fetch($proposalid); - if (!$result) { - throw new RestException(404, 'Proposal not found'); - } + $propal = new Propal($this->db); + $result = $propal->fetch($proposalid); + if (!$result) { + throw new RestException(404, 'Proposal not found'); + } - $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(405, $this->commande->error); - } - $this->commande->fetchObjectLinked(); + $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(405, $this->commande->error); + } + $this->commande->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->commande); - } + return $this->_cleanObjectDatas($this->commande); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - private function _validate($data) - { - $commande = array(); - foreach (Orders::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, $field." field missing"); - $commande[$field] = $data[$field]; - } - return $commande; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $commande = array(); + foreach (Orders::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, $field." field missing"); + $commande[$field] = $data[$field]; + } + return $commande; + } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 73dd2cee9fb..7119e85b473 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -99,13 +99,13 @@ class Commande extends CommonOrder */ public $ref_client; - /** + /** * @var string Internal ref for order * @deprecated */ public $ref_int; - /** + /** * @var int Contact ID */ public $contactid; @@ -121,15 +121,15 @@ class Commande extends CommonOrder */ public $billed; - /** - * @var int Draft Status of the order - */ - public $brouillon; - public $cond_reglement_code; + /** + * @var int Draft Status of the order + */ + public $brouillon; + public $cond_reglement_code; /** - * @var int bank account ID - */ + * @var int bank account ID + */ public $fk_account; /** @@ -168,12 +168,12 @@ class Commande extends CommonOrder public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; /** - * @var int Date of order + * @var int Date of order */ public $date; /** - * @var int Date of order + * @var int Date of order * @deprecated * @see $date */ @@ -182,8 +182,8 @@ class Commande extends CommonOrder public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) /** - * @var int ID - */ + * @var int ID + */ public $fk_remise_except; public $remise_percent; @@ -197,13 +197,13 @@ class Commande extends CommonOrder public $linked_objects = array(); /** - * @var int User author ID - */ + * @var int User author ID + */ public $user_author_id; - /** - * @var int User validator ID - */ + /** + * @var int User validator ID + */ public $user_valid; /** @@ -213,8 +213,8 @@ class Commande extends CommonOrder // Multicurrency /** - * @var int Currency ID - */ + * @var int Currency ID + */ public $fk_multicurrency; public $multicurrency_code; @@ -223,9 +223,9 @@ class Commande extends CommonOrder public $multicurrency_total_tva; public $multicurrency_total_ttc; - /** - * @var Commande clone of order object - */ + /** + * @var Commande clone of order object + */ public $oldcopy; //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) @@ -394,11 +394,11 @@ class Commande extends CommonOrder $mybool |= @include_once $dir.$file; } - if ($mybool === false) - { - dol_print_error('', "Failed to include file ".$file); - return ''; - } + if ($mybool === false) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); @@ -568,7 +568,7 @@ class Commande extends CommonOrder { $this->ref = $num; $this->statut = self::STATUS_VALIDATED; - $this->brouillon = 0; + $this->brouillon = 0; } if (!$error) @@ -589,9 +589,9 @@ class Commande extends CommonOrder * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @return int <0 if KO, >0 if OK */ - public function setDraft($user, $idwarehouse = -1) - { - //phpcs:enable + public function setDraft($user, $idwarehouse = -1) + { + //phpcs:enable global $conf, $langs; $error = 0; @@ -619,12 +619,12 @@ class Commande extends CommonOrder if ($this->db->query($sql)) { - if (!$error) - { - $this->oldcopy = clone $this; - } + if (!$error) + { + $this->oldcopy = clone $this; + } - // If stock is decremented on validate order, we must reincrement it + // If stock is decremented on validate order, we must reincrement it if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { $result = 0; @@ -665,7 +665,7 @@ class Commande extends CommonOrder $this->db->rollback(); return -1; } - } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -678,7 +678,7 @@ class Commande extends CommonOrder */ public function set_reopen($user) { - // phpcs:enable + // phpcs:enable $error = 0; if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED) @@ -958,7 +958,7 @@ class Commande extends CommonOrder $sql .= ", ".(int) $this->fk_incoterms; $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ", ".setEntity($this); - $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); + $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); $sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; @@ -1009,7 +1009,7 @@ class Commande extends CommonOrder $line->ref_ext = ''; } - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -1033,10 +1033,10 @@ class Commande extends CommonOrder $line->label, $line->array_options, $line->fk_unit, - $origintype, - $originid, + $origintype, + $originid, 0, - $line->ref_ext + $line->ref_ext ); if ($result < 0) { @@ -1357,8 +1357,8 @@ class Commande extends CommonOrder if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) { - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; } $this->origin = $object->element; @@ -1502,7 +1502,7 @@ class Commande extends CommonOrder return -1; } - $this->db->begin(); + $this->db->begin(); $product_type = $type; if (!empty($fk_product)) @@ -1681,7 +1681,7 @@ class Commande extends CommonOrder */ public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { - // phpcs:enable + // phpcs:enable global $conf, $mysoc; if (!$qty) $qty = 1; @@ -1780,7 +1780,7 @@ class Commande extends CommonOrder $sql .= ', c.fk_incoterms, c.location_incoterms'; $sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; $sql .= ", c.module_source, c.pos_source"; - $sql .= ", i.libelle as label_incoterms"; + $sql .= ", i.libelle as label_incoterms"; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql .= ', ca.code as availability_code, ca.label as availability_label'; @@ -1917,7 +1917,7 @@ class Commande extends CommonOrder */ public function insert_discount($idremise) { - // phpcs:enable + // phpcs:enable global $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1992,7 +1992,7 @@ class Commande extends CommonOrder public function fetch_lines($only_product = 0, $loadalsotranslation = 0) { global $langs, $conf; - // phpcs:enable + // phpcs:enable $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,'; @@ -2086,13 +2086,13 @@ class Commande extends CommonOrder $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } - $this->lines[$i] = $line; + $this->lines[$i] = $line; $i++; } @@ -2224,7 +2224,7 @@ class Commande extends CommonOrder */ public function nb_expedition() { - // phpcs:enable + // phpcs:enable $sql = 'SELECT count(*)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; @@ -2251,7 +2251,7 @@ class Commande extends CommonOrder */ public function stock_array($filtre_statut = self::STATUS_CANCELED) { - // phpcs:enable + // phpcs:enable $this->stocks = array(); // Tableau des id de produit de la commande @@ -2359,7 +2359,7 @@ class Commande extends CommonOrder */ public function set_remise($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if ($user->rights->commande->creer) @@ -2425,7 +2425,7 @@ class Commande extends CommonOrder */ public function set_remise_absolue($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if ($user->rights->commande->creer) @@ -2491,7 +2491,7 @@ class Commande extends CommonOrder */ public function set_date($user, $date, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if ($user->rights->commande->creer) { $error = 0; @@ -2553,7 +2553,7 @@ class Commande extends CommonOrder */ public function set_date_livraison($user, $date_livraison, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if ($user->rights->commande->creer) { $error = 0; @@ -2620,7 +2620,7 @@ class Commande extends CommonOrder */ public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { - // phpcs:enable + // phpcs:enable global $user; $ga = array(); @@ -2750,7 +2750,7 @@ class Commande extends CommonOrder */ public function demand_reason($demand_reason_id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); @@ -2819,7 +2819,7 @@ class Commande extends CommonOrder */ public function set_ref_client($user, $ref_client, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if ($user->rights->commande->creer) { $error = 0; @@ -3321,9 +3321,9 @@ class Commande extends CommonOrder if (!$error) { // Delete extrafields of order details - $main = MAIN_DB_PREFIX.'commandedet'; - $ef = $main."_extrafields"; - $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; + $main = MAIN_DB_PREFIX.'commandedet'; + $ef = $main."_extrafields"; + $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".$this->id.")"; if (!$this->db->query($sql)) { $error++; @@ -3432,7 +3432,7 @@ class Commande extends CommonOrder */ public function load_board($user) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $clause = " WHERE"; @@ -3521,45 +3521,45 @@ class Commande extends CommonOrder */ public function LibStatut($status, $billed, $mode, $donotshowbilled = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; $billedtext = ''; if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : ''); if ($status == self::STATUS_CANCELED) { - $labelStatus = $langs->trans('StatusOrderCanceled'); - $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); - $statusType = 'status9'; + $labelStatus = $langs->trans('StatusOrderCanceled'); + $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); + $statusType = 'status9'; } elseif ($status == self::STATUS_DRAFT) { - $labelStatus = $langs->trans('StatusOrderDraft'); - $labelStatusShort = $langs->trans('StatusOrderDraftShort'); - $statusType = 'status0'; + $labelStatus = $langs->trans('StatusOrderDraft'); + $labelStatusShort = $langs->trans('StatusOrderDraftShort'); + $statusType = 'status0'; } elseif ($status == self::STATUS_VALIDATED) { - $labelStatus = $langs->trans('StatusOrderValidated').$billedtext; - $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; - $statusType = 'status1'; + $labelStatus = $langs->trans('StatusOrderValidated').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; + $statusType = 'status1'; } elseif ($status == self::STATUS_SHIPMENTONPROCESS) { - $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; - $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; - $statusType = 'status4'; + $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; + $statusType = 'status4'; } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { - $labelStatus = $langs->trans('StatusOrderToBill'); - $labelStatusShort = $langs->trans('StatusOrderToBillShort'); - $statusType = 'status4'; + $labelStatus = $langs->trans('StatusOrderToBill'); + $labelStatusShort = $langs->trans('StatusOrderToBillShort'); + $statusType = 'status4'; } elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { - $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; - $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; - $statusType = 'status6'; + $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; + $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; + $statusType = 'status6'; } elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { - $labelStatus = $langs->trans('StatusOrderDelivered'); - $labelStatusShort = $langs->trans('StatusOrderDelivered'); - $statusType = 'status6'; + $labelStatus = $langs->trans('StatusOrderDelivered'); + $labelStatusShort = $langs->trans('StatusOrderDelivered'); + $statusType = 'status6'; } else { - $labelStatus = $langs->trans('Unknown'); - $labelStatusShort = ''; - $statusType = ''; - $mode = 0; + $labelStatus = $langs->trans('Unknown'); + $labelStatusShort = ''; + $statusType = ''; + $mode = 0; } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); @@ -3825,7 +3825,7 @@ class Commande extends CommonOrder */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -4024,10 +4024,10 @@ class OrderLine extends CommonOrderLine * * @param DoliDB $db handler d'acces base de donnee */ - public function __construct($db) - { - $this->db = $db; - } + public function __construct($db) + { + $this->db = $db; + } /** * Load line order @@ -4125,32 +4125,32 @@ class OrderLine extends CommonOrderLine $error = 0; - // check if order line is not in a shipment line before deleting - $sqlCheckShipmentLine = "SELECT"; - $sqlCheckShipmentLine .= " ed.rowid"; - $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; - $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid; + // check if order line is not in a shipment line before deleting + $sqlCheckShipmentLine = "SELECT"; + $sqlCheckShipmentLine .= " ed.rowid"; + $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; + $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid; - $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); - if (!$resqlCheckShipmentLine) { - $error++; - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - } else { - $langs->load('errors'); - $num = $this->db->num_rows($resqlCheckShipmentLine); - if ($num > 0) { - $error++; - $objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine); - $this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid; - $this->errors[] = $this->error; - } - $this->db->free($resqlCheckShipmentLine); - } - if ($error) { - dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR); - return -1; - } + $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); + if (!$resqlCheckShipmentLine) { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } else { + $langs->load('errors'); + $num = $this->db->num_rows($resqlCheckShipmentLine); + if ($num > 0) { + $error++; + $objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine); + $this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid; + $this->errors[] = $this->error; + } + $this->db->free($resqlCheckShipmentLine); + } + if ($error) { + dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR); + return -1; + } $this->db->begin(); @@ -4482,7 +4482,7 @@ class OrderLine extends CommonOrderLine */ public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Clean parameters diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 20f705a8ed9..9db3c8fcd96 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -100,13 +100,13 @@ class Facture extends CommonInvoice public $author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_valid; public $date; // Date invoice @@ -153,8 +153,8 @@ class Facture extends CommonInvoice public $mode_reglement_code; // Code in llx_c_paiement /** - * @var int ID Field to store bank id to use when payment mode is withdraw - */ + * @var int ID Field to store bank id to use when payment mode is withdraw + */ public $fk_bank; /** @@ -175,8 +175,8 @@ class Facture extends CommonInvoice // Multicurrency /** - * @var int ID - */ + * @var int ID + */ public $fk_multicurrency; public $multicurrency_code; @@ -323,30 +323,30 @@ class Facture extends CommonInvoice ); // END MODULEBUILDER PROPERTIES - /** - * Standard invoice - */ - const TYPE_STANDARD = 0; + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; - /** - * Replacement invoice - */ - const TYPE_REPLACEMENT = 1; + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; - /** - * Credit note invoice - */ - const TYPE_CREDIT_NOTE = 2; + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; - /** - * Deposit invoice - */ - const TYPE_DEPOSIT = 3; + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; - /** - * Proforma invoice (should not be used. a proforma is an order) - */ - const TYPE_PROFORMA = 4; + /** + * Proforma invoice (should not be used. a proforma is an order) + */ + const TYPE_PROFORMA = 4; /** * Situation invoice @@ -407,7 +407,7 @@ class Facture extends CommonInvoice * @param int $forceduedate If set, do not recalculate due date from payment condition but force it with value * @return int <0 if KO, >0 if OK */ - public function create(User $user, $notrigger = 0, $forceduedate = 0) + public function create(User $user, $notrigger = 0, $forceduedate = 0) { global $langs, $conf, $mysoc, $hookmanager; $error = 0; @@ -461,7 +461,7 @@ class Facture extends CommonInvoice // Create invoice from a template invoice if ($this->fac_rec > 0) { - $this->fk_fac_rec_source = $this->fac_rec; + $this->fk_fac_rec_source = $this->fac_rec; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; $_facrec = new FactureRec($this->db); @@ -503,9 +503,9 @@ class Facture extends CommonInvoice $this->ref_client = trim($this->ref_client); $this->note_public = trim($this->note_public); $this->note_private = trim($this->note_private); - $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); + $this->note_private = dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref)); - $this->array_options = $_facrec->array_options; + $this->array_options = $_facrec->array_options; //if (! $this->remise) $this->remise = 0; if (!$this->mode_reglement_id) $this->mode_reglement_id = 0; @@ -520,12 +520,12 @@ class Facture extends CommonInvoice // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice if ($_facrec->frequency > 0) { - dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); - if (empty($_facrec->date_when)) $_facrec->date_when = $now; - $next_date = $_facrec->getNextDate(); // Calculate next date - $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); - //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. - $result = $_facrec->setNextDate($next_date, 1); + dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); + if (empty($_facrec->date_when)) $_facrec->date_when = $now; + $next_date = $_facrec->getNextDate(); // Calculate next date + $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); + //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. + $result = $_facrec->setNextDate($next_date, 1); } // Define lang of customer @@ -536,8 +536,8 @@ class Facture extends CommonInvoice if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang = $this->default_lang; // for thirdparty if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); } // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) @@ -567,16 +567,16 @@ class Facture extends CommonInvoice } // Define due date if not already defined - if (empty($forceduedate)) { - $duedate = $this->calculate_date_lim_reglement(); - /*if ($duedate < 0) { Regression, a date can be negative if before 1970. + if (empty($forceduedate)) { + $duedate = $this->calculate_date_lim_reglement(); + /*if ($duedate < 0) { Regression, a date can be negative if before 1970. dol_syslog(__METHOD__ . ' Error in calculate_date_lim_reglement. We got ' . $duedate, LOG_ERR); return -1; }*/ - $this->date_lim_reglement = $duedate; - } else { - $this->date_lim_reglement = $forceduedate; - } + $this->date_lim_reglement = $duedate; + } else { + $this->date_lim_reglement = $forceduedate; + } // Insert into database $socid = $this->socid; @@ -595,17 +595,17 @@ class Facture extends CommonInvoice $sql .= ", note_private"; $sql .= ", note_public"; $sql .= ", ref_client, ref_int"; - $sql .= ", fk_account"; + $sql .= ", fk_account"; $sql .= ", module_source, pos_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; $sql .= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql .= ", situation_cycle_ref, situation_counter, situation_final"; $sql .= ", fk_incoterms, location_incoterms"; - $sql .= ", fk_multicurrency"; - $sql .= ", multicurrency_code"; - $sql .= ", multicurrency_tx"; - $sql .= ", retained_warranty"; - $sql .= ", retained_warranty_date_limit"; - $sql .= ", retained_warranty_fk_cond_reglement"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ", retained_warranty"; + $sql .= ", retained_warranty_date_limit"; + $sql .= ", retained_warranty_fk_cond_reglement"; $sql .= ")"; $sql .= " VALUES ("; $sql .= "'(PROV)'"; @@ -636,7 +636,7 @@ class Facture extends CommonInvoice $sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null"); $sql .= ", ".($this->situation_final ? $this->situation_final : 0); $sql .= ", ".(int) $this->fk_incoterms; - $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql .= ", ".(double) $this->multicurrency_tx; @@ -667,27 +667,27 @@ class Facture extends CommonInvoice { foreach ($this->linked_objects as $origin => $tmp_origin_id) { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } } } @@ -698,20 +698,20 @@ class Facture extends CommonInvoice $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - if (is_object($value)) $originidforcontact = $value->id; - else $originidforcontact = $value; - break; // We take first one - } - } + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0); + if (count($exp->linkedObjectsIds['commande']) > 0) + { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) + { + $originforcontact = 'commande'; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; + break; // We take first one + } + } } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; @@ -720,11 +720,11 @@ class Facture extends CommonInvoice $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } + while ($objcontact = $this->db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } } else dol_print_error($resqlcontact); } @@ -764,12 +764,12 @@ class Facture extends CommonInvoice $newinvoiceline->fk_parent_line = $fk_parent_line; if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { - $discount = new DiscountAbsolute($this->db); - $discount->fetch($newinvoiceline->fk_remise_except); + $discount = new DiscountAbsolute($this->db); + $discount->fetch($newinvoiceline->fk_remise_except); - $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); - $newinvoiceline->fk_remise_except = $discountId; - } + $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); + $newinvoiceline->fk_remise_except = $discountId; + } $result = $newinvoiceline->insert(); @@ -793,13 +793,13 @@ class Facture extends CommonInvoice foreach ($this->lines as $i => $val) { - $line = $this->lines[$i]; + $line = $this->lines[$i]; - // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array - //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (!is_object($line)) $line = (object) $line; + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. + if (!is_object($line)) $line = (object) $line; - if ($result >= 0) + if ($result >= 0) { // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { @@ -823,7 +823,7 @@ class Facture extends CommonInvoice $line->ref_ext = ''; } - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -842,8 +842,8 @@ class Facture extends CommonInvoice $line->product_type, $line->rang, $line->special_code, - $origintype, - $originid, + $origintype, + $originid, $fk_parent_line, $line->fk_fournprice, $line->pa_ht, @@ -902,26 +902,26 @@ class Facture extends CommonInvoice $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; // If buyprice not defined from template invoice, we try to guess the best value if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $producttmp = new ProductFournisseur($this->db); - $producttmp->fetch($_facrec->lines[$i]->fk_product); + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $producttmp = new ProductFournisseur($this->db); + $producttmp->fetch($_facrec->lines[$i]->fk_product); - // If margin module defined on costprice, we try the costprice - // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price - // else we get the best supplier price - if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; - elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) $buyprice = $producttmp->pmp; - else { - if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) - { - if ($producttmp->product_fourn_price_id > 0) - { - $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent / 100) + $producttmp->fourn_remise, 'MU'); - } - } - } - } + // If margin module defined on costprice, we try the costprice + // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price + // else we get the best supplier price + if ($conf->global->MARGIN_TYPE == 'costprice' && !empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (!empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && !empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + else { + if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) + { + if ($producttmp->product_fourn_price_id > 0) + { + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent / 100) + $producttmp->fourn_remise, 'MU'); + } + } + } + } $result_insert = $this->addline( $_facrec->lines[$i]->desc, @@ -945,7 +945,7 @@ class Facture extends CommonInvoice '', 0, 0, - $fk_product_fournisseur_price, + $fk_product_fournisseur_price, $buyprice, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options) ?null:$_facrec->lines[$i]->array_options, @@ -974,17 +974,17 @@ class Facture extends CommonInvoice // Actions on extra fields if (!$error) { - $result = $this->insertExtraFields(); - if ($result < 0) $error++; + $result = $this->insertExtraFields(); + if ($result < 0) $error++; } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('BILL_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('BILL_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } if (!$error) { @@ -1019,7 +1019,7 @@ class Facture extends CommonInvoice * @param int $invertdetail Reverse sign of amounts for lines * @return int <0 if KO, >0 if OK */ - public function createFromCurrent(User $user, $invertdetail = 0) + public function createFromCurrent(User $user, $invertdetail = 0) { global $conf; @@ -1030,13 +1030,13 @@ class Facture extends CommonInvoice // fetch optionals attributes and labels $this->fetch_optionals(); - if (!empty($this->array_options)) { - $facture->array_options = $this->array_options; - } + if (!empty($this->array_options)) { + $facture->array_options = $this->array_options; + } - foreach ($this->lines as &$line) { - $line->fetch_optionals(); //fetch extrafields - } + foreach ($this->lines as &$line) { + $line->fetch_optionals(); //fetch extrafields + } $facture->fk_facture_source = $this->fk_facture_source; $facture->type = $this->type; @@ -1062,9 +1062,9 @@ class Facture extends CommonInvoice $facture->situation_cycle_ref = $this->situation_cycle_ref; $facture->situation_final = $this->situation_final; - $facture->retained_warranty = $this->retained_warranty; - $facture->retained_warranty_fk_cond_reglement = $this->retained_warranty_fk_cond_reglement; - $facture->retained_warranty_date_limit = $this->retained_warranty_date_limit; + $facture->retained_warranty = $this->retained_warranty; + $facture->retained_warranty_fk_cond_reglement = $this->retained_warranty_fk_cond_reglement; + $facture->retained_warranty_date_limit = $this->retained_warranty_date_limit; // Loop on each line of new invoice @@ -1112,7 +1112,7 @@ class Facture extends CommonInvoice /** * Load an object from its id and create a new one in database * - * @param User $user User that clone + * @param User $user User that clone * @param int $fromid Id of object to clone * @return int New id of clone */ @@ -1135,11 +1135,11 @@ class Facture extends CommonInvoice if ($objsoc->fetch($this->socid) > 0) { - $object->socid = $objsoc->id; - $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $object->fk_project = ''; - $object->fk_delivery_address = ''; + $object->socid = $objsoc->id; + $object->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $object->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $object->fk_project = ''; + $object->fk_delivery_address = ''; } // TODO Change product price if multi-prices @@ -1168,14 +1168,14 @@ class Facture extends CommonInvoice // Loop on each line of new invoice foreach ($object->lines as $i => $line) { - if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts + if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { - unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise + unset($object->lines[$i]); + unset($object->products[$i]); // Tant que products encore utilise } // Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month) // If it's a service with start and end dates - if (!empty($line->date_start) && !empty($line->date_end) ) { + if (!empty($line->date_start) && !empty($line->date_end)) { // Get the dates $start = dol_getdate($line->date_start); $end = dol_getdate($line->date_end); @@ -1207,13 +1207,13 @@ class Facture extends CommonInvoice if ($result < 0) $error++; else { // copy internal contacts - if ($object->copy_linked_contact($this, 'internal') < 0) + if ($object->copy_linked_contact($this, 'internal') < 0) $error++; // copy external contacts if same company elseif ($this->socid == $object->socid) { - if ($object->copy_linked_contact($this, 'external') < 0) + if ($object->copy_linked_contact($this, 'external') < 0) $error++; } } @@ -1250,7 +1250,7 @@ class Facture extends CommonInvoice * @param User $user Object user * @return int <0 if KO, 0 if nothing done, 1 if OK */ - public function createFromOrder($object, User $user) + public function createFromOrder($object, User $user) { global $conf, $hookmanager; @@ -1303,7 +1303,7 @@ class Facture extends CommonInvoice $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; - // get extrafields from original line + // get extrafields from original line $object->lines[$i]->fetch_optionals(); foreach ($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; @@ -1325,17 +1325,17 @@ class Facture extends CommonInvoice if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) { - $this->note_private = $object->note_private; - $this->note_public = $object->note_public; + $this->note_private = $object->note_private; + $this->note_public = $object->note_public; } - $this->module_source = $object->module_source; + $this->module_source = $object->module_source; $this->pos_source = $object->pos_source; $this->origin = $object->element; $this->origin_id = $object->id; - // get extrafields from original line + // get extrafields from original line $object->fetch_optionals(); foreach ($object->array_options as $options_key => $value) $this->array_options[$options_key] = $value; @@ -1374,13 +1374,13 @@ class Facture extends CommonInvoice * @param int $max Maxlength of ref * @param int $short 1=Return just URL * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $addlinktonotes 1=Add link to notes - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param string $target Target of link ('', '_self', '_blank', '_parent', '_backoffice', ...) + * @param int $notooltip 1=Disable tooltip + * @param int $addlinktonotes 1=Add link to notes + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $target Target of link ('', '_self', '_blank', '_parent', '_backoffice', ...) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '') + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '') { global $langs, $conf, $user, $mysoc; @@ -1391,8 +1391,8 @@ class Facture extends CommonInvoice if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id; else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id; - if (!$user->rights->facture->lire) - $option = 'nolink'; + if (!$user->rights->facture->lire) + $option = 'nolink'; if ($option !== 'nolink') { @@ -1408,56 +1408,56 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice - $label = ''; + $label = ''; - if ($user->rights->facture->lire) { - $label = ''.$langs->trans("Invoice").''; - if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; - if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; - if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; - if (!empty($this->ref)) - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->ref_client)) - $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - if (!empty($this->date)) - $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); - if (!empty($this->total_ht)) - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) - $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' - $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) - $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($moretitle) $label .= ' - '.$moretitle; - if (isset($this->statut) && isset($this->alreadypaid)) { - $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5, $this->alreadypaid); - } - } + if ($user->rights->facture->lire) { + $label = ''.$langs->trans("Invoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; + if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; + if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->ref_client)) + $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + if (!empty($this->date)) + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); + if (!empty($this->total_ht)) + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) + $label .= '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000' + $label .= '
'.$langs->transcountry('AmountLT1', $mysoc->country_code).': '.price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_localtax2) && $this->total_localtax2 != 0) + $label .= '
'.$langs->transcountry('AmountLT2', $mysoc->country_code).': '.price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if ($moretitle) $label .= ' - '.$moretitle; + if (isset($this->statut) && isset($this->alreadypaid)) { + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5, $this->alreadypaid); + } + } $linkclose = ($target ? ' target="'.$target.'"' : ''); if (empty($notooltip) && $user->rights->facture->lire) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("Invoice"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("Invoice"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart = ''; + $linkstart = ''; $linkend = ''; - if ($option == 'nolink') { - $linkstart = ''; - $linkend = ''; - } + if ($option == 'nolink') { + $linkstart = ''; + $linkend = ''; + } $result .= $linkstart; if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); @@ -1466,19 +1466,19 @@ class Facture extends CommonInvoice if ($addlinktonotes) { - $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) - { - //$notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); - $notetoshow = $langs->trans("ViewPrivateNote").':
'.$txttoshow; - $result .= ' '; - $result .= ''; - $result .= img_picto('', 'note'); - $result .= ''; - //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); - //$result.=''; - $result .= ''; - } + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); + if ($txttoshow) + { + //$notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $notetoshow = $langs->trans("ViewPrivateNote").':
'.$txttoshow; + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result .= ''; + } } return $result; @@ -1516,10 +1516,10 @@ class Facture extends CommonInvoice $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; - $sql .= ', f.fk_incoterms, f.location_incoterms'; - $sql .= ', f.module_source, f.pos_source'; - $sql .= ", i.libelle as label_incoterms"; - $sql .= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; + $sql .= ', f.fk_incoterms, f.location_incoterms'; + $sql .= ', f.module_source, f.pos_source'; + $sql .= ", i.libelle as label_incoterms"; + $sql .= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement"; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; @@ -1651,7 +1651,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load all detailed lines into this->lines * @@ -1663,7 +1663,7 @@ class Facture extends CommonInvoice public function fetch_lines($only_product = 0, $loadalsotranslation = 0) { global $langs, $conf; - // phpcs:enable + // phpcs:enable $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; @@ -1708,7 +1708,7 @@ class Facture extends CommonInvoice $line->subprice = $objp->subprice; $line->ref_ext = $objp->ref_ext; // line external ref - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -1751,14 +1751,14 @@ class Facture extends CommonInvoice $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fetch_optionals(); + $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } $this->lines[$i] = $line; @@ -1778,7 +1778,7 @@ class Facture extends CommonInvoice * * @return void */ - public function fetchPreviousNextSituationInvoice() + public function fetchPreviousNextSituationInvoice() { global $conf; @@ -1800,13 +1800,13 @@ class Facture extends CommonInvoice $invoice = new Facture($this->db); if ($invoice->fetch($objp->rowid) > 0) { - if ($objp->situation_counter < $this->situation_counter - || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes - ) + if ($objp->situation_counter < $this->situation_counter + || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes + ) { - $this->tab_previous_situation_invoice[] = $invoice; + $this->tab_previous_situation_invoice[] = $invoice; } else { - $this->tab_next_situation_invoice[] = $invoice; + $this->tab_next_situation_invoice[] = $invoice; } } } @@ -1820,7 +1820,7 @@ class Facture extends CommonInvoice * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1930,16 +1930,16 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) * * @param int $idremise Id of absolute discount * @return int >0 if OK, <0 if KO */ - public function insert_discount($idremise) + public function insert_discount($idremise) { - // phpcs:enable + // phpcs:enable global $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1975,12 +1975,12 @@ class Facture extends CommonInvoice // Get buy/cost price of invoice that is source of discount if ($remise->fk_facture_source > 0) { - $srcinvoice = new Facture($this->db); - $srcinvoice->fetch($remise->fk_facture_source); - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject - $formmargin = new FormMargin($this->db); - $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); - $facligne->pa_ht = $arraytmp['pa_total']; + $srcinvoice = new Facture($this->db); + $srcinvoice->fetch($remise->fk_facture_source); + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject + $formmargin = new FormMargin($this->db); + $arraytmp = $formmargin->getMarginInfosArray($srcinvoice, false); + $facligne->pa_ht = $arraytmp['pa_total']; } $facligne->total_ht = -$remise->amount_ht; @@ -2025,7 +2025,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -2033,10 +2033,10 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_ref_client($ref_client, $notrigger = 0) + public function set_ref_client($ref_client, $notrigger = 0) { - // phpcs:enable - global $user; + // phpcs:enable + global $user; $error = 0; @@ -2094,7 +2094,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, 0=Refused, >0 if OK */ - public function delete($user, $notrigger = 0, $idwarehouse = -1) + public function delete($user, $notrigger = 0, $idwarehouse = -1) { global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2114,10 +2114,10 @@ class Facture extends CommonInvoice if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BILL_DELETE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('BILL_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } // Removed extrafields @@ -2189,7 +2189,7 @@ class Facture extends CommonInvoice } } - // Invoice line extrafileds + // Invoice line extrafileds $main = MAIN_DB_PREFIX.'facturedet'; $ef = $main."_extrafields"; $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; @@ -2255,7 +2255,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1 * or partialy (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 @@ -2265,9 +2265,9 @@ class Facture extends CommonInvoice * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) * @return int <0 if KO, >0 if OK */ - public function set_paid($user, $close_code = '', $close_note = '') + public function set_paid($user, $close_code = '', $close_note = '') { - // phpcs:enable + // phpcs:enable $error = 0; if ($this->paye != 1) @@ -2290,10 +2290,10 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_PAYED', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('BILL_PAYED', $user); + if ($result < 0) $error++; + // End call triggers } else { $error++; $this->error = $this->db->lasterror(); @@ -2313,7 +2313,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED * Fonction utilisee quand un paiement prelevement est refuse, @@ -2322,9 +2322,9 @@ class Facture extends CommonInvoice * @param User $user Object user that change status * @return int <0 if KO, >0 if OK */ - public function set_unpaid($user) + public function set_unpaid($user) { - // phpcs:enable + // phpcs:enable $error = 0; $this->db->begin(); @@ -2339,10 +2339,10 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_UNPAYED', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('BILL_UNPAYED', $user); + if ($result < 0) $error++; + // End call triggers } else { $error++; $this->error = $this->db->error(); @@ -2360,7 +2360,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because @@ -2371,9 +2371,9 @@ class Facture extends CommonInvoice * @param string $close_note Comment * @return int <0 if KO, >0 if OK */ - public function set_canceled($user, $close_code = '', $close_note = '') + public function set_canceled($user, $close_code = '', $close_note = '') { - // phpcs:enable + // phpcs:enable dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); @@ -2397,14 +2397,14 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_CANCEL', $user); - if ($result < 0) - { + // Call trigger + $result = $this->call_trigger('BILL_CANCEL', $user); + if ($result < 0) + { $this->db->rollback(); return -1; } - // End call triggers + // End call triggers $this->db->commit(); return 1; @@ -2430,9 +2430,9 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $batch_rule 0=do not decrement batch, else batch rule to use * 1=take in batches ordered by sellby and eatby dates - * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK + * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK */ - public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0) + public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2463,12 +2463,12 @@ class Facture extends CommonInvoice } if (count($this->lines) <= 0) { - $langs->load("errors"); + $langs->load("errors"); $this->error = $langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); return -1; } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { $this->error = 'Permission denied'; dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR); @@ -2680,10 +2680,10 @@ class Facture extends CommonInvoice // Trigger calls if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BILL_VALIDATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('BILL_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) @@ -2711,16 +2711,16 @@ class Facture extends CommonInvoice if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -2744,20 +2744,20 @@ class Facture extends CommonInvoice $this->date_validation = $now; $i = 0; - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $final = true; - $nboflines = count($this->lines); - while (($i < $nboflines) && $final) { - $final = ($this->lines[$i]->situation_percent == 100); - $i++; - } + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $final = true; + $nboflines = count($this->lines); + while (($i < $nboflines) && $final) { + $final = ($this->lines[$i]->situation_percent == 100); + $i++; + } - if (empty($final)) $this->situation_final = 0; - else $this->situation_final = 1; + if (empty($final)) $this->situation_final = 0; + else $this->situation_final = 1; - $this->setFinal($user); - } + $this->setFinal($user); + } } } else { $error++; @@ -2779,7 +2779,7 @@ class Facture extends CommonInvoice * @param Translate $langs Translate object * @return bool false if KO, true if OK */ - public function updatePriceNextInvoice(&$langs) + public function updatePriceNextInvoice(&$langs) { foreach ($this->tab_next_situation_invoice as $next_invoice) { @@ -2823,7 +2823,7 @@ class Facture extends CommonInvoice */ public function setDraft($user, $idwarehouse = -1) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $error = 0; @@ -2945,38 +2945,38 @@ class Facture extends CommonInvoice * @param string $ref_ext External reference of the line * @return int <0 if KO, Id of line if OK */ - public function addline( - $desc, - $pu_ht, - $qty, - $txtva, - $txlocaltax1 = 0, - $txlocaltax2 = 0, - $fk_product = 0, - $remise_percent = 0, - $date_start = '', - $date_end = '', - $ventil = 0, - $info_bits = 0, - $fk_remise_except = '', - $price_base_type = 'HT', - $pu_ttc = 0, - $type = self::TYPE_STANDARD, - $rang = -1, - $special_code = 0, - $origin = '', - $origin_id = 0, - $fk_parent_line = 0, - $fk_fournprice = null, - $pa_ht = 0, - $label = '', - $array_options = 0, - $situation_percent = 100, - $fk_prev_id = 0, - $fk_unit = null, - $pu_ht_devise = 0, - $ref_ext = '' - ) { + public function addline( + $desc, + $pu_ht, + $qty, + $txtva, + $txlocaltax1 = 0, + $txlocaltax2 = 0, + $fk_product = 0, + $remise_percent = 0, + $date_start = '', + $date_end = '', + $ventil = 0, + $info_bits = 0, + $fk_remise_except = '', + $price_base_type = 'HT', + $pu_ttc = 0, + $type = self::TYPE_STANDARD, + $rang = -1, + $special_code = 0, + $origin = '', + $origin_id = 0, + $fk_parent_line = 0, + $fk_fournprice = null, + $pa_ht = 0, + $label = '', + $array_options = 0, + $situation_percent = 100, + $fk_prev_id = 0, + $fk_unit = null, + $pu_ht_devise = 0, + $ref_ext = '' + ) { // Deprecation warning if ($label) { dol_syslog(__METHOD__.": using line label is deprecated", LOG_WARNING); @@ -3043,8 +3043,8 @@ class Facture extends CommonInvoice $product_type = $product->type; if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { - $langs->load("errors"); - $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $langs->load("errors"); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } @@ -3077,8 +3077,8 @@ class Facture extends CommonInvoice // MultiCurrency $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; // Rank to use @@ -3142,8 +3142,8 @@ class Facture extends CommonInvoice $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -3200,7 +3200,7 @@ class Facture extends CommonInvoice * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label of the line (deprecated, do not use) * @param int $special_code Special code (also used by externals modules!) - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param int $situation_percent Situation advance percentage * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency @@ -3208,7 +3208,7 @@ class Facture extends CommonInvoice * @param string $ref_ext External reference of the line * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') { global $conf, $user; // Deprecation warning @@ -3251,7 +3251,7 @@ class Facture extends CommonInvoice $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $pu_ht_devise = price2num($pu_ht_devise); + $pu_ht_devise = price2num($pu_ht_devise); $pa_ht = price2num($pa_ht); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); @@ -3267,12 +3267,12 @@ class Facture extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); @@ -3287,8 +3287,8 @@ class Facture extends CommonInvoice // MultiCurrency $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; // Old properties: $price, $remise (deprecated) @@ -3313,8 +3313,8 @@ class Facture extends CommonInvoice $product_type = $product->type; if (!empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE) && $product_type == 0 && $product->stock_reel < $qty) { - $langs->load("errors"); - $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); + $langs->load("errors"); + $this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnInvoice', $product->ref); $this->db->rollback(); return -3; } @@ -3324,7 +3324,7 @@ class Facture extends CommonInvoice $line->oldline = $staticline; $this->line = $line; - $this->line->context = $this->context; + $this->line->context = $this->context; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) @@ -3337,7 +3337,7 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; - $this->line->ref_ext = $ref_ext; + $this->line->ref_ext = $ref_ext; $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative $this->line->vat_src_code = $vat_src_code; @@ -3370,8 +3370,8 @@ class Facture extends CommonInvoice // Multicurrency $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -3391,7 +3391,7 @@ class Facture extends CommonInvoice $this->db->commit(); return $result; } else { - $this->error = $this->line->error; + $this->error = $this->line->error; $this->db->rollback(); return -1; } @@ -3408,7 +3408,7 @@ class Facture extends CommonInvoice * @param float $situation_percent progress percentage need to be test * @return false if KO, true if OK */ - public function checkProgressLine($idline, $situation_percent) + public function checkProgressLine($idline, $situation_percent) { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) @@ -3428,7 +3428,7 @@ class Facture extends CommonInvoice else return $situation_percent < $obj->situation_percent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update invoice line with percentage * @@ -3436,16 +3436,16 @@ class Facture extends CommonInvoice * @param int $percent Percentage * @return void */ - public function update_percent($line, $percent) + public function update_percent($line, $percent) { - // phpcs:enable - global $mysoc, $user; + // phpcs:enable + global $mysoc, $user; - // Progress should never be changed for discount lines - if (($line->info_bits & 2) == 2) - { - return; - } + // Progress should never be changed for discount lines + if (($line->info_bits & 2) == 2) + { + return; + } include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -3471,9 +3471,9 @@ class Facture extends CommonInvoice * @param int $rowid Id of line to delete * @return int <0 if KO, >0 if OK */ - public function deleteline($rowid) + public function deleteline($rowid) { - global $user; + global $user; dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); @@ -3501,7 +3501,7 @@ class Facture extends CommonInvoice $line = new FactureLigne($this->db); - $line->context = $this->context; + $line->context = $this->context; // For triggers $result = $line->fetch($rowid); @@ -3527,7 +3527,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set percent discount * @@ -3536,9 +3536,9 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable // Clean parameters if (empty($remise)) $remise = 0; @@ -3591,7 +3591,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set absolute discount * @@ -3600,9 +3600,9 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (empty($remise)) $remise = 0; if ($user->rights->facture->creer) @@ -3665,7 +3665,7 @@ class Facture extends CommonInvoice * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - public function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $langs; @@ -3763,7 +3763,7 @@ class Facture extends CommonInvoice * @param int $id Id of object to load * @return void */ - public function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; $sql .= ' date_closing as dateclosing,'; @@ -3809,7 +3809,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices (eventually filtered on a user) into an array * @@ -3823,9 +3823,9 @@ class Facture extends CommonInvoice * @param string $sortorder Sort order * @return array|int -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { - // phpcs:enable + // phpcs:enable global $conf, $user; $ga = array(); @@ -3880,7 +3880,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be replaced by another invoice. * Invoices matching the following rules are returned: @@ -3889,9 +3889,9 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array|int Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) */ - public function list_replacable_invoices($socid = 0) + public function list_replacable_invoices($socid = 0) { - // phpcs:enable + // phpcs:enable global $conf; $return = array(); @@ -3928,7 +3928,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be corrected by a credit note. * Invoices matching the following rules are returned: @@ -3937,9 +3937,9 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ - public function list_qualified_avoir_invoices($socid = 0) + public function list_qualified_avoir_invoices($socid = 0) { - // phpcs:enable + // phpcs:enable global $conf; $return = array(); @@ -3958,17 +3958,17 @@ class Facture extends CommonInvoice $sql .= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir if (!empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { - // Select the last situation invoice - $sqlSit = 'SELECT MAX(fs.rowid)'; - $sqlSit .= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit .= " WHERE fs.entity IN (".getEntity('invoice').")"; - $sqlSit .= " AND fs.type = ".self::TYPE_SITUATION; - $sqlSit .= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; - $sqlSit .= " GROUP BY fs.situation_cycle_ref"; - $sqlSit .= " ORDER BY fs.situation_counter"; - $sql .= " AND ( f.type != ".self::TYPE_SITUATION." OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir + // Select the last situation invoice + $sqlSit = 'SELECT MAX(fs.rowid)'; + $sqlSit .= " FROM ".MAIN_DB_PREFIX."facture as fs"; + $sqlSit .= " WHERE fs.entity IN (".getEntity('invoice').")"; + $sqlSit .= " AND fs.type = ".self::TYPE_SITUATION; + $sqlSit .= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sqlSit .= " GROUP BY fs.situation_cycle_ref"; + $sqlSit .= " ORDER BY fs.situation_counter"; + $sql .= " AND ( f.type != ".self::TYPE_SITUATION." OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir } else { - $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir + $sql .= " AND f.type != ".self::TYPE_SITUATION; // Type non 5 si facture non avoir } if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; @@ -3999,16 +3999,16 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user) + public function load_board($user) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $clause = " WHERE"; @@ -4071,7 +4071,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts facturation */ - public function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -4081,7 +4081,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts livraison */ - public function getIdShippingContact() + public function getIdShippingContact() { return $this->getIdContact('external', 'SHIPPING'); } @@ -4095,7 +4095,7 @@ class Facture extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - public function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $conf, $langs; @@ -4103,7 +4103,7 @@ class Facture extends CommonInvoice $arraynow = dol_getdate($now); $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -4250,15 +4250,15 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int <0 if KO, >0 if OK */ - public function load_state_board() + public function load_state_board() { - // phpcs:enable + // phpcs:enable global $conf, $user; $this->nb = array(); @@ -4283,7 +4283,7 @@ class Facture extends CommonInvoice { $this->nb["invoices"] = $obj->nb; } - $this->db->free($resql); + $this->db->free($resql); return 1; } else { dol_print_error($this->db); @@ -4297,9 +4297,9 @@ class Facture extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - public function getLinesArray() + public function getLinesArray() { - return $this->fetch_lines(); + return $this->fetch_lines(); } /** @@ -4344,7 +4344,7 @@ class Facture extends CommonInvoice * * @return int >= 1 if OK, -1 if error */ - public function newCycle() + public function newCycle() { $sql = 'SELECT max(situation_cycle_ref) FROM '.MAIN_DB_PREFIX.'facture as f'; $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; @@ -4367,27 +4367,27 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the first of a cycle * * @return boolean */ - public function is_first() + public function is_first() { - // phpcs:enable + // phpcs:enable return ($this->situation_counter == 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the previous situations as Facture objects * * @return mixed -1 if error, array of previous situations */ - public function get_prev_sits() + public function get_prev_sits() { - // phpcs:enable + // phpcs:enable global $conf; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture'; @@ -4419,7 +4419,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function setFinal(User $user, $notrigger = 0) + public function setFinal(User $user, $notrigger = 0) { $error = 0; @@ -4458,15 +4458,15 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the last in its cycle * * @return bool Last of the cycle status */ - public function is_last_in_cycle() + public function is_last_in_cycle() { - // phpcs:enable + // phpcs:enable global $conf; if (!empty($this->situation_cycle_ref)) { @@ -4524,21 +4524,21 @@ class Facture extends CommonInvoice $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { - $totalpaye = $this->getSommePaiement(); - $totalpaye = floatval($totalpaye); - $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); - if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) - { - if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) - { - $hasDelay = 1; - } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) - { - $hasDelay = 1; - } else { - $hasDelay = 0; - } - } + $totalpaye = $this->getSommePaiement(); + $totalpaye = floatval($totalpaye); + $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); + if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) + { + if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) + { + $hasDelay = 1; + } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) + { + $hasDelay = 1; + } else { + $hasDelay = 0; + } + } } return $hasDelay; @@ -4589,45 +4589,45 @@ class Facture extends CommonInvoice public function getRetainedWarrantyAmount($rounding = -1) { global $conf; - if (empty($this->retained_warranty)) { - return -1; - } + if (empty($this->retained_warranty)) { + return -1; + } - $retainedWarrantyAmount = 0; + $retainedWarrantyAmount = 0; - // Billed - retained warranty - if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) - { - $displayWarranty = true; - // Check if this situation invoice is 100% for real - if (!empty($this->lines)) { - foreach ($this->lines as $i => $line) { - if ($line->product_type < 2 && $line->situation_percent < 100) { - $displayWarranty = false; - break; - } - } - } + // Billed - retained warranty + if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) + { + $displayWarranty = true; + // Check if this situation invoice is 100% for real + if (!empty($this->lines)) { + foreach ($this->lines as $i => $line) { + if ($line->product_type < 2 && $line->situation_percent < 100) { + $displayWarranty = false; + break; + } + } + } - if ($displayWarranty && !empty($this->situation_final)) - { - $this->fetchPreviousNextSituationInvoice(); - $TPreviousIncoice = $this->tab_previous_situation_invoice; + if ($displayWarranty && !empty($this->situation_final)) + { + $this->fetchPreviousNextSituationInvoice(); + $TPreviousIncoice = $this->tab_previous_situation_invoice; - $total2BillWT = 0; - foreach ($TPreviousIncoice as &$fac) { - $total2BillWT += $fac->total_ttc; - } - $total2BillWT += $this->total_ttc; + $total2BillWT = 0; + foreach ($TPreviousIncoice as &$fac) { + $total2BillWT += $fac->total_ttc; + } + $total2BillWT += $this->total_ttc; - $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; - } else { - return -1; - } - } else { - // Because one day retained warranty could be used on standard invoices - $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; - } + $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100; + } else { + return -1; + } + } else { + // Because one day retained warranty could be used on standard invoices + $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; + } if ($rounding < 0) { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); @@ -4637,7 +4637,7 @@ class Facture extends CommonInvoice return round($retainedWarrantyAmount, $rounding); } - return $retainedWarrantyAmount; + return $retainedWarrantyAmount; } /** @@ -4648,28 +4648,28 @@ class Facture extends CommonInvoice */ public function setRetainedWarranty($value) { - dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')'); - if ($this->statut >= 0) - { - $fieldname = 'retained_warranty'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.floatval($value); - $sql .= ' WHERE rowid='.$this->id; + dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')'); + if ($this->statut >= 0) + { + $fieldname = 'retained_warranty'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.floatval($value); + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->retained_warranty = floatval($value); - return 1; - } else { - dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); - $this->error = $this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); - $this->error = 'Status of the object is incompatible '.$this->statut; - return -2; - } + if ($this->db->query($sql)) + { + $this->retained_warranty = floatval($value); + return 1; + } else { + dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error()); + $this->error = $this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible'); + $this->error = 'Status of the object is incompatible '.$this->statut; + return -2; + } } @@ -4682,33 +4682,33 @@ class Facture extends CommonInvoice */ public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) { - if (!$timestamp && $dateYmd) { - $timestamp = $this->db->jdate($dateYmd); - } + if (!$timestamp && $dateYmd) { + $timestamp = $this->db->jdate($dateYmd); + } - dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); - if ($this->statut >= 0) - { - $fieldname = 'retained_warranty_date_limit'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(strval($timestamp) != '' ? '\''.$this->db->idate($timestamp).'\'' : 'null'); - $sql .= ' WHERE rowid='.$this->id; + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')'); + if ($this->statut >= 0) + { + $fieldname = 'retained_warranty_date_limit'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.(strval($timestamp) != '' ? '\''.$this->db->idate($timestamp).'\'' : 'null'); + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->retained_warranty_date_limit = $timestamp; - return 1; - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); - $this->error = $this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); - $this->error = 'Status of the object is incompatible '.$this->statut; - return -2; - } + if ($this->db->query($sql)) + { + $this->retained_warranty_date_limit = $timestamp; + return 1; + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error()); + $this->error = $this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible'); + $this->error = 'Status of the object is incompatible '.$this->statut; + return -2; + } } } @@ -4718,12 +4718,12 @@ class Facture extends CommonInvoice */ class FactureLigne extends CommonInvoiceLine { - /** + /** * @var string ID to identify managed object */ public $element = 'facturedet'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'facturedet'; @@ -4809,7 +4809,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $rowid id of invoice line to get * @return int <0 if KO, >0 if OK */ - public function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice, fd.ref_ext,'; @@ -4888,7 +4888,7 @@ class FactureLigne extends CommonInvoiceLine return 1; } else { - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -4900,15 +4900,15 @@ class FactureLigne extends CommonInvoiceLine * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another * @return int <0 if KO, >0 if OK */ - public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) + public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { global $langs, $user, $conf; $error = 0; - $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. + $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); + dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); // Clean parameters $this->desc = trim($this->desc); @@ -4983,7 +4983,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " '".$this->db->escape($this->desc)."',"; $sql .= " ".price2num($this->qty).","; - $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; $sql .= " ".price2num($this->tva_tx).","; $sql .= " ".price2num($this->localtax1_tx).","; $sql .= " ".price2num($this->localtax2_tx).","; @@ -5028,14 +5028,14 @@ class FactureLigne extends CommonInvoiceLine $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); $this->rowid = $this->id; // For backward compatibility - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } // Si fk_remise_except defini, on lie la remise a la facture // ce qui la flague comme "consommee". @@ -5048,16 +5048,16 @@ class FactureLigne extends CommonInvoiceLine // Check if discount was found if ($result > 0) { - // Check if discount not already affected to another invoice + // Check if discount not already affected to another invoice if ($discount->fk_facture_line > 0) { - if (empty($noerrorifdiscountalreadylinked)) - { - $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); - dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } + if (empty($noerrorifdiscountalreadylinked)) + { + $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } } else { $result = $discount->link_to_invoice($this->rowid, 0); if ($result < 0) @@ -5084,14 +5084,14 @@ class FactureLigne extends CommonInvoiceLine if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('LINEBILL_INSERT', $user); - if ($result < 0) - { + // Call trigger + $result = $this->call_trigger('LINEBILL_INSERT', $user); + if ($result < 0) + { $this->db->rollback(); return -2; } - // End call triggers + // End call triggers } $this->db->commit(); @@ -5110,7 +5110,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function update($user = '', $notrigger = 0) + public function update($user = '', $notrigger = 0) { global $user, $conf; @@ -5157,35 +5157,35 @@ class FactureLigne extends CommonInvoiceLine $this->db->begin(); - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql .= " description='".$this->db->escape($this->desc)."'"; - $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", subprice=".price2num($this->subprice).""; - $sql .= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; - else $sql .= ", fk_remise_except=null"; + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", subprice=".price2num($this->subprice).""; + $sql .= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; + else $sql .= ", fk_remise_except=null"; $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; - $sql .= ", tva_tx=".price2num($this->tva_tx).""; - $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; - $sql .= ", localtax2_tx=".price2num($this->localtax2_tx).""; + $sql .= ", tva_tx=".price2num($this->tva_tx).""; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx).""; $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql .= ", qty=".price2num($this->qty); - $sql .= ", date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); - $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); - $sql .= ", product_type=".$this->product_type; - $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; - $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; - if (empty($this->skip_update_total)) - { - $sql .= ", total_ht=".price2num($this->total_ht); - $sql .= ", total_tva=".price2num($this->total_tva); - $sql .= ", total_ttc=".price2num($this->total_ttc); - $sql .= ", total_localtax1=".price2num($this->total_localtax1); - $sql .= ", total_localtax2=".price2num($this->total_localtax2); - } + $sql .= ", qty=".price2num($this->qty); + $sql .= ", date_start=".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql .= ", date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; + $sql .= ", special_code='".$this->db->escape($this->special_code)."'"; + if (empty($this->skip_update_total)) + { + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); @@ -5196,9 +5196,9 @@ class FactureLigne extends CommonInvoiceLine // Multicurrency $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; $sql .= " WHERE rowid = ".$this->rowid; @@ -5206,26 +5206,26 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql) { - if (!$error) - { - $this->id = $this->rowid; - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (!$error) + { + $this->id = $this->rowid; + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINEBILL_UPDATE', $user); - if ($result < 0) + // Call trigger + $result = $this->call_trigger('LINEBILL_UPDATE', $user); + if ($result < 0) { $this->db->rollback(); return -2; } - // End call triggers + // End call triggers } $this->db->commit(); return 1; @@ -5239,10 +5239,10 @@ class FactureLigne extends CommonInvoiceLine /** * Delete line in database * TODO Add param User $user and notrigger (see skeleton) - * + * * @return int <0 if KO, >0 if OK */ - public function delete() + public function delete() { global $user; @@ -5257,13 +5257,13 @@ class FactureLigne extends CommonInvoiceLine } // End call triggers - // extrafields - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $this->db->rollback(); - return -1; - } + // extrafields + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -5278,16 +5278,16 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Update DB line fields total_xxx + * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - public function update_total() + public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); dol_syslog(get_class($this)."::update_total", LOG_DEBUG); @@ -5318,7 +5318,7 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns situation_percent of the previous line. * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. @@ -5327,14 +5327,14 @@ class FactureLigne extends CommonInvoiceLine * @param bool $include_credit_note Include credit note or not * @return int >= 0 */ - public function get_prev_progress($invoiceid, $include_credit_note = true) + public function get_prev_progress($invoiceid, $include_credit_note = true) { - // phpcs:enable + // phpcs:enable global $invoicecache; if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { return 0; } else { - // If invoice is not a situation invoice, this->fk_prev_id is used for something else + // If invoice is not a situation invoice, this->fk_prev_id is used for something else if (!isset($invoicecache[$invoiceid])) { $invoicecache[$invoiceid] = new Facture($this->db); $invoicecache[$invoiceid]->fetch($invoiceid); @@ -5349,20 +5349,20 @@ class FactureLigne extends CommonInvoiceLine $returnPercent = floatval($res['situation_percent']); if ($include_credit_note) { - $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; - $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture f ON (f.rowid = fd.fk_facture) '; - $sql .= ' WHERE fd.fk_prev_id ='.$this->fk_prev_id; - $sql .= ' AND f.situation_cycle_ref = '.$invoicecache[$invoiceid]->situation_cycle_ref; // Prevent cycle outed - $sql .= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; + $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture f ON (f.rowid = fd.fk_facture) '; + $sql .= ' WHERE fd.fk_prev_id ='.$this->fk_prev_id; + $sql .= ' AND f.situation_cycle_ref = '.$invoicecache[$invoiceid]->situation_cycle_ref; // Prevent cycle outed + $sql .= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; - $res = $this->db->query($sql); - if ($res) { - while ($obj = $this->db->fetch_object($res)) { - $returnPercent = $returnPercent + floatval($obj->situation_percent); - } - } else { - dol_print_error($this->db); - } + $res = $this->db->query($sql); + if ($res) { + while ($obj = $this->db->fetch_object($res)) { + $returnPercent = $returnPercent + floatval($obj->situation_percent); + } + } else { + dol_print_error($this->db); + } } return $returnPercent; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 0331861ea03..606e4e626b0 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -177,10 +177,10 @@ if (empty($reshook)) if ($canvas) $object->canvas = $canvas; $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); - $object->socid = GETPOST("socid", 'int'); + $object->socid = GETPOST("socid", 'int'); $object->lastname = GETPOST("lastname", 'alpha'); $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); + $object->civility_code = GETPOST("civility_code", 'alpha'); $object->poste = GETPOST("poste", 'alpha'); $object->address = GETPOST("address", 'alpha'); $object->zip = GETPOST("zipcode", 'alpha'); @@ -1355,7 +1355,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object->fetch_thirdparty(); - if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { + if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) { print '
'; @@ -1368,11 +1368,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; + if ($action != 'editlevel' && $user->rights->societe->contact->creer) print ''; print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->contact->creer) print 'id . '">' . img_edit($langs->trans('Modify'), 1) . 'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; print ''; if ($action == 'editlevel') { - $formcompany->formProspectContactLevel($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1); + $formcompany->formProspectContactLevel($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1); } else { print $object->getLibProspLevel(); } @@ -1381,13 +1381,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Status of prospection $object->loadCacheOfProspStatus(); - print '' . $langs->trans("StatusProsp") . '' . $object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); + print ''.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '     '; print '
'; foreach ($object->cacheprospectstatus as $key => $val) { $titlealt = 'default'; if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; - if ($object->stcomm_id != $val['id']) print '' . img_action($titlealt, $val['code'], $val['picto']) . ''; + if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code'], $val['picto']).''; } print '
'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index a474df3b910..1772f94abfb 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -158,8 +158,8 @@ $fieldstosearchall = array( 'p.phone_perso'=>"PhonePerso", 'p.phone_mobile'=>"PhoneMobile", 'p.fax'=>"Fax", - 'p.note_public'=>"NotePublic", - 'p.note_private'=>"NotePrivate", + 'p.note_public'=>"NotePublic", + 'p.note_private'=>"NotePrivate", ); // Definition of fields for list @@ -541,7 +541,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); } print '
'; @@ -734,9 +734,9 @@ if (!empty($arrayfields['p.thirdparty']['checked'])) if (!empty($arrayfields['p.priv']['checked'])) { print ''; - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('search_priv', $selectarray, $search_priv, 1); - print ''; + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('search_priv', $selectarray, $search_priv, 1); + print ''; } // Prospect level if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) @@ -808,7 +808,7 @@ if (!empty($arrayfields['p.town']['checked'])) print_liste_field_ //if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); //if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "co.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'], $_SERVER["PHP_SELF"], "p.phone", $begin, $param, '', $sortfield, $sortorder); if (!empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'], $_SERVER["PHP_SELF"], "p.phone_perso", $begin, $param, '', $sortfield, $sortorder); @@ -831,24 +831,24 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) print_liste_field_ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array( - 'arrayfields'=>$arrayfields, - 'param'=>$param, - 'sortfield'=>$sortfield, - 'sortorder'=>$sortorder, + 'arrayfields'=>$arrayfields, + 'param'=>$param, + 'sortfield'=>$sortfield, + 'sortorder'=>$sortorder, ); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['p.datec']['checked'])) { - print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['p.tms']['checked'])) { - print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['p.statut']['checked'])) { - print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.import_key']['checked'])) { - print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -986,15 +986,15 @@ while ($i < min($num, $limit)) } } } - // Company + // Company if (!empty($arrayfields['p.thirdparty']['checked'])) { print ''; if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); } else print ' '; print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 5048bcd31e8..73a6043f095 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -170,7 +170,7 @@ class CMailFile $this->sendmode = ''; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); - $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $this->sendmode = $smtpContextSendMode; @@ -443,9 +443,9 @@ class CMailFile // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); - if (! empty($this->addr_from)) { + if (!empty($this->addr_from)) { try { - if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { + if (!empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) { // Prevent email spoofing for smtp server with a strict configuration $regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string $emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom); @@ -465,7 +465,7 @@ class CMailFile } // Set the To addresses with an associative array - if (! empty($this->addr_to)) { + if (!empty($this->addr_to)) { try { $result = $this->message->setTo($this->getArrayAddress($this->addr_to)); } catch (Exception $e) { @@ -473,7 +473,7 @@ class CMailFile } } - if (! empty($this->reply_to)) { + if (!empty($this->reply_to)) { try { $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to)); } catch (Exception $e) { @@ -529,8 +529,8 @@ class CMailFile } } - if (! empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc)); - if (! empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc)); + if (!empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc)); + if (!empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc)); //if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to)); if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from)); } else { @@ -641,15 +641,15 @@ class CMailFile $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); - $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; - $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; - $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; - $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; - $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; - $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d3abceb7097..2396ecb808e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4567,245 +4567,245 @@ abstract class CommonObject if (empty($reshook)) { - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); - // Increase limit for PDF build - $err = error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); + // Increase limit for PDF build + $err = error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); - // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp = explode(':', $modele, 2); - if (!empty($tmp[1])) - { - $modele = $tmp[0]; - $srctemplatepath = $tmp[1]; - } + // If selected model is a filename template (then $modele="modelname" or "modelname:filename") + $tmp = explode(':', $modele, 2); + if (!empty($tmp[1])) + { + $modele = $tmp[0]; + $srctemplatepath = $tmp[1]; + } - // Search template files + // Search template files $file = ''; $classname = ''; $filefound = ''; - $dirmodels = array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - foreach (array('doc', 'pdf') as $prefix) - { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php - else $file = $prefix."_".$modele.".modules.php"; + $dirmodels = array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + foreach (array('doc', 'pdf') as $prefix) + { + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + else $file = $prefix."_".$modele.".modules.php"; - // On verifie l'emplacement du modele - $file = dol_buildpath($reldir.$modelspath.$file, 0); - if (file_exists($file)) - { - $filefound = $file; - $classname = $prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } + // On verifie l'emplacement du modele + $file = dol_buildpath($reldir.$modelspath.$file, 0); + if (file_exists($file)) + { + $filefound = $file; + $classname = $prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } - // If generator was found - if ($filefound) - { - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. + // If generator was found + if ($filefound) + { + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. - require_once $file; + require_once $file; - $obj = new $classname($this->db); + $obj = new $classname($this->db); - // If generator is ODT, we must have srctemplatepath defined, if not we set it. - if ($obj->type == 'odt' && empty($srctemplatepath)) - { - $varfortemplatedir = $obj->scandir; - if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) - { - $dirtoscan = $conf->global->$varfortemplatedir; + // If generator is ODT, we must have srctemplatepath defined, if not we set it. + if ($obj->type == 'odt' && empty($srctemplatepath)) + { + $varfortemplatedir = $obj->scandir; + if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) + { + $dirtoscan = $conf->global->$varfortemplatedir; - $listoffiles = array(); + $listoffiles = array(); - // Now we add first model found in directories scanned - $listofdir = explode(',', $dirtoscan); - foreach ($listofdir as $key => $tmpdir) - { - $tmpdir = trim($tmpdir); - $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (is_dir($tmpdir)) - { - $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); - } - } + // Now we add first model found in directories scanned + $listofdir = explode(',', $dirtoscan); + foreach ($listofdir as $key => $tmpdir) + { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } + if (is_dir($tmpdir)) + { + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); + } + } - if (count($listoffiles)) - { - foreach ($listoffiles as $record) - { - $srctemplatepath = $record['fullname']; - break; - } - } - } + if (count($listoffiles)) + { + foreach ($listoffiles as $record) + { + $srctemplatepath = $record['fullname']; + break; + } + } + } - if (empty($srctemplatepath)) - { - $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; - return -1; - } - } + if (empty($srctemplatepath)) + { + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + return -1; + } + } - if ($obj->type == 'odt' && !empty($srctemplatepath)) - { - if (!dol_is_file($srctemplatepath)) - { - dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING); - $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; - return -1; - } - } + if ($obj->type == 'odt' && !empty($srctemplatepath)) + { + if (!dol_is_file($srctemplatepath)) + { + dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING); + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + return -1; + } + } - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output = $outputlangs->charset_output; + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output = $outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) - { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); - } else { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); - } - // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. + if (in_array(get_class($this), array('Adherent'))) + { + $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); + } else { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + } + // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. - if ($resultwritefile > 0) - { - $outputlangs->charset_output = $sav_charset_output; + if ($resultwritefile > 0) + { + $outputlangs->charset_output = $sav_charset_output; - // We delete old preview - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($this); + // We delete old preview + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($this); - // Index file in database - if (!empty($obj->result['fullpath'])) - { - $destfull = $obj->result['fullpath']; - $upload_dir = dirname($destfull); - $destfile = basename($destfull); - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); + // Index file in database + if (!empty($obj->result['fullpath'])) + { + $destfull = $obj->result['fullpath']; + $upload_dir = dirname($destfull); + $destfile = basename($destfull); + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); - if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir - { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($destfile); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile = new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile = new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); - // Set the public "share" key - $setsharekey = false; - if ($this->element == 'propal') - { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey = true; - if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; - } - if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey = true; - } - if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey = true; - } - if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey = true; - } + // Set the public "share" key + $setsharekey = false; + if ($this->element == 'propal') + { + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey = true; + if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; + } + if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; + } + if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; + } + if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; + } - if ($setsharekey) { - if (empty($ecmfile->share)) // Because object not found or share not set yet - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $ecmfile->share = getRandomPassword(true); - } - } + if ($setsharekey) { + if (empty($ecmfile->share)) // Because object not found or share not set yet + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + } - if ($result > 0) - { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->update($user); - if ($result < 0) { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } else { - $ecmfile->entity = $conf->entity; - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $ecmfile->src_object_type = $this->table_element; - $ecmfile->src_object_id = $this->id; + if ($result > 0) + { + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->update($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } else { + $ecmfile->entity = $conf->entity; + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_id = $this->id; - $result = $ecmfile->create($user); - if ($result < 0) { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } + $result = $ecmfile->create($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } - /*$this->result['fullname']=$destfull; + /*$this->result['fullname']=$destfull; $this->result['filepath']=$ecmfile->filepath; $this->result['filename']=$ecmfile->filename;*/ - //var_dump($obj->update_main_doc_field);exit; + //var_dump($obj->update_main_doc_field);exit; - // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field = 0; - if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; - if ($update_main_doc_field && !empty($this->table_element)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql .= ' WHERE rowid = '.$this->id; + // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) + $update_main_doc_field = 0; + if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; + if ($update_main_doc_field && !empty($this->table_element)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; + $sql .= ' WHERE rowid = '.$this->id; - $resql = $this->db->query($sql); - if (!$resql) { + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); } else { - $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; - } - } - } - } else { - dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); - } + $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; + } + } + } + } else { + dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); + } - // Success in building document. We build meta file. - dol_meta_create($this); + // Success in building document. We build meta file. + dol_meta_create($this); - return 1; - } else { - $outputlangs->charset_output = $sav_charset_output; - dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); - return -1; - } - } else { - if (!$filefound) { - $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; - dol_print_error('', $this->error); - } else { - $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound); - dol_print_error('', $this->error); - } - return -1; - } + return 1; + } else { + $outputlangs->charset_output = $sav_charset_output; + dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); + return -1; + } + } else { + if (!$filefound) { + $this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele; + dol_print_error('', $this->error); + } else { + $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound); + dol_print_error('', $this->error); + } + return -1; + } } else return $reshook; } @@ -7987,46 +7987,46 @@ abstract class CommonObject // Delete cascade first if (is_array($this->childtablesoncascade) && !empty($this->childtablesoncascade)) { - foreach ($this->childtablesoncascade as $table) - { - $deleteFromObject = explode(':', $table); - if (count($deleteFromObject) >= 2) { - $className = str_replace('@', '', $deleteFromObject[0]); - $filePath = $deleteFromObject[1]; - $columnName = $deleteFromObject[2]; - if (dol_include_once($filePath)) { - $childObject = new $className($this->db); - if (method_exists($childObject, 'deleteByParentField')) { - $result = $childObject->deleteByParentField($this->id, $columnName); - if ($result < 0) { + foreach ($this->childtablesoncascade as $table) + { + $deleteFromObject = explode(':', $table); + if (count($deleteFromObject) >= 2) { + $className = str_replace('@', '', $deleteFromObject[0]); + $filePath = $deleteFromObject[1]; + $columnName = $deleteFromObject[2]; + if (dol_include_once($filePath)) { + $childObject = new $className($this->db); + if (method_exists($childObject, 'deleteByParentField')) { + $result = $childObject->deleteByParentField($this->id, $columnName); + if ($result < 0) { $error++; - $this->errors[] = $childObject->error; - break; - } - } else { + $this->errors[] = $childObject->error; + break; + } + } else { $error++; $this->errors[] = "You defined a cascade delete on an object $childObject but there is no method deleteByParentField for it"; break; } - } else { - $error++; - $this->errors[] = 'Cannot include child class file '.$filePath; - break; - } - } else { - // Delete record in child table - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; - - $resql = $this->db->query($sql); - if (!$resql) { + } else { $error++; - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; + $this->errors[] = 'Cannot include child class file '.$filePath; break; - } - } - } - } + } + } else { + // Delete record in child table + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + break; + } + } + } + } if (!$error) { if (!$notrigger) { diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 42691f14307..ad7d93506f4 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -31,385 +31,385 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class CoreObject extends CommonObject { - public $withChild = true; + public $withChild = true; - /** - * @var Array $_fields Fields to synchronize with Database - */ - protected $fields = array(); + /** + * @var Array $_fields Fields to synchronize with Database + */ + protected $fields = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct(DoliDB &$db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB &$db) + { + $this->db = $db; + } - /** - * Function to init fields - * - * @return bool - */ - protected function init() - { - $this->id = 0; - $this->datec = 0; - $this->tms = 0; + /** + * Function to init fields + * + * @return bool + */ + protected function init() + { + $this->id = 0; + $this->datec = 0; + $this->tms = 0; - if (!empty($this->fields)) - { - foreach ($this->fields as $field=>$info) - { - if ($this->isDate($info)) $this->{$field} = time(); - elseif ($this->isArray($info)) $this->{$field} = array(); - elseif ($this->isInt($info)) $this->{$field} = (int) 0; - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; - else $this->{$field} = ''; - } + if (!empty($this->fields)) + { + foreach ($this->fields as $field=>$info) + { + if ($this->isDate($info)) $this->{$field} = time(); + elseif ($this->isArray($info)) $this->{$field} = array(); + elseif ($this->isInt($info)) $this->{$field} = (int) 0; + elseif ($this->isFloat($info)) $this->{$field} = (double) 0; + else $this->{$field} = ''; + } - $this->to_delete = false; - $this->is_clone = false; + $this->to_delete = false; + $this->is_clone = false; - return true; - } else { - return false; - } - } + return true; + } else { + return false; + } + } - /** - * Test type of field - * - * @param string $field name of field - * @param string $type type of field to test - * @return boolean value of field or false - */ - private function checkFieldType($field, $type) - { - if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) - { - return $this->{'is_'.$type}($this->fields[$field]); - } else { - return false; - } - } + /** + * Test type of field + * + * @param string $field name of field + * @param string $type type of field to test + * @return boolean value of field or false + */ + private function checkFieldType($field, $type) + { + if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) + { + return $this->{'is_'.$type}($this->fields[$field]); + } else { + return false; + } + } - /** - * Get object and children from database - * - * @param int $id Id of object to load - * @param bool $loadChild used to load children from database - * @return int >0 if OK, <0 if KO, 0 if not found - */ - public function fetch($id, $loadChild = true) - { - $res = $this->fetchCommon($id); - if ($res > 0) { - if ($loadChild) $this->fetchChild(); - } + /** + * Get object and children from database + * + * @param int $id Id of object to load + * @param bool $loadChild used to load children from database + * @return int >0 if OK, <0 if KO, 0 if not found + */ + public function fetch($id, $loadChild = true) + { + $res = $this->fetchCommon($id); + if ($res > 0) { + if ($loadChild) $this->fetchChild(); + } - return $res; - } + return $res; + } - /** - * Function to instantiate a new child - * - * @param string $tabName Table name of child - * @param int $id If id is given, we try to return his key if exist or load if we try_to_load - * @param string $key Attribute name of the object id - * @param bool $try_to_load Force the fetch if an id is given - * @return int - */ - public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) - { - if (!empty($id)) - { - foreach ($this->{$tabName} as $k=>&$object) - { - if ($object->{$key} === $id) return $k; - } - } + /** + * Function to instantiate a new child + * + * @param string $tabName Table name of child + * @param int $id If id is given, we try to return his key if exist or load if we try_to_load + * @param string $key Attribute name of the object id + * @param bool $try_to_load Force the fetch if an id is given + * @return int + */ + public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) + { + if (!empty($id)) + { + foreach ($this->{$tabName} as $k=>&$object) + { + if ($object->{$key} === $id) return $k; + } + } - $k = count($this->{$tabName}); + $k = count($this->{$tabName}); - $className = ucfirst($tabName); - $this->{$tabName}[$k] = new $className($this->db); - if ($id > 0 && $key === 'id' && $try_to_load) - { - $this->{$tabName}[$k]->fetch($id); - } + $className = ucfirst($tabName); + $this->{$tabName}[$k] = new $className($this->db); + if ($id > 0 && $key === 'id' && $try_to_load) + { + $this->{$tabName}[$k]->fetch($id); + } - return $k; - } + return $k; + } - /** - * Function to set a child as to delete - * - * @param string $tabName Table name of child - * @param int $id Id of child to set as to delete - * @param string $key Attribute name of the object id - * @return bool - */ - public function removeChild($tabName, $id, $key = 'id') - { - foreach ($this->{$tabName} as &$object) - { - if ($object->{$key} == $id) - { - $object->to_delete = true; - return true; - } - } - return false; - } + /** + * Function to set a child as to delete + * + * @param string $tabName Table name of child + * @param int $id Id of child to set as to delete + * @param string $key Attribute name of the object id + * @return bool + */ + public function removeChild($tabName, $id, $key = 'id') + { + foreach ($this->{$tabName} as &$object) + { + if ($object->{$key} == $id) + { + $object->to_delete = true; + return true; + } + } + return false; + } - /** - * Function to fetch children objects - * - * @return void - */ - public function fetchChild() - { - if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach ($this->childtables as &$childTable) - { - $className = ucfirst($childTable); + /** + * Function to fetch children objects + * + * @return void + */ + public function fetchChild() + { + if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach ($this->childtables as &$childTable) + { + $className = ucfirst($childTable); - $this->{$className} = array(); + $this->{$className} = array(); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; - $res = $this->db->query($sql); + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id; + $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { - $o = new $className($this->db); - $o->fetch($obj->rowid); + if ($res) + { + while ($obj = $this->db->fetch_object($res)) + { + $o = new $className($this->db); + $o->fetch($obj->rowid); - $this->{$className}[] = $o; - } - } else { - $this->errors[] = $this->db->lasterror(); - } - } - } - } + $this->{$className}[] = $o; + } + } else { + $this->errors[] = $this->db->lasterror(); + } + } + } + } - /** - * Function to update children data - * - * @param User $user user object - * @return void - */ - public function saveChild(User &$user) - { - if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach ($this->childtables as &$childTable) - { - $className = ucfirst($childTable); - if (!empty($this->{$className})) - { - foreach ($this->{$className} as $i => &$object) - { - $object->{$this->fk_element} = $this->id; + /** + * Function to update children data + * + * @param User $user user object + * @return void + */ + public function saveChild(User &$user) + { + if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach ($this->childtables as &$childTable) + { + $className = ucfirst($childTable); + if (!empty($this->{$className})) + { + foreach ($this->{$className} as $i => &$object) + { + $object->{$this->fk_element} = $this->id; - $object->update($user); - if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]); - } - } - } - } - } + $object->update($user); + if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]); + } + } + } + } + } - /** - * Function to update object or create or delete if needed - * - * @param User $user User object - * @return int < 0 if KO, > 0 if OK - */ - public function update(User &$user) - { - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed - elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user); + /** + * Function to update object or create or delete if needed + * + * @param User $user User object + * @return int < 0 if KO, > 0 if OK + */ + public function update(User &$user) + { + if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed + elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user); - $error = 0; - $this->db->begin(); + $error = 0; + $this->db->begin(); - $res = $this->updateCommon($user); - if ($res) - { - $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user); - if ($result < 0) $error++; - else $this->saveChild($user); - } else { - $error++; - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - } + $res = $this->updateCommon($user); + if ($res) + { + $result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user); + if ($result < 0) $error++; + else $this->saveChild($user); + } else { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } - if (empty($error)) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } + if (empty($error)) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Function to create object in database - * - * @param User $user User object - * @return int < 0 if KO, > 0 if OK - */ - public function create(User $user) - { - if ($this->id > 0) return $this->update($user); + /** + * Function to create object in database + * + * @param User $user User object + * @return int < 0 if KO, > 0 if OK + */ + public function create(User $user) + { + if ($this->id > 0) return $this->update($user); - $error = 0; - $this->db->begin(); + $error = 0; + $this->db->begin(); - $res = $this->createCommon($user); - if ($res) - { - $this->id = $this->db->last_insert_id($this->table_element); + $res = $this->createCommon($user); + if ($res) + { + $this->id = $this->db->last_insert_id($this->table_element); - $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user); - if ($result < 0) $error++; - else $this->saveChild($user); - } else { - $error++; - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - } + $result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user); + if ($result < 0) $error++; + else $this->saveChild($user); + } else { + $error++; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } - if (empty($error)) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } + if (empty($error)) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Function to delete object in database - * - * @param User $user user object - * @return int < 0 if KO, > 0 if OK - */ - public function delete(User &$user) - { - if ($this->id <= 0) return 0; + /** + * Function to delete object in database + * + * @param User $user user object + * @return int < 0 if KO, > 0 if OK + */ + public function delete(User &$user) + { + if ($this->id <= 0) return 0; - $error = 0; - $this->db->begin(); + $error = 0; + $this->db->begin(); - $result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user); - if ($result < 0) $error++; + $result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user); + if ($result < 0) $error++; - if (!$error) - { - $this->deleteCommon($user); - if ($this->withChild && !empty($this->childtables)) - { - foreach ($this->childtables as &$childTable) - { - $className = ucfirst($childTable); - if (!empty($this->{$className})) - { - foreach ($this->{$className} as &$object) - { - $object->delete($user); - } - } - } - } - } + if (!$error) + { + $this->deleteCommon($user); + if ($this->withChild && !empty($this->childtables)) + { + foreach ($this->childtables as &$childTable) + { + $className = ucfirst($childTable); + if (!empty($this->{$className})) + { + foreach ($this->{$className} as &$object) + { + $object->delete($user); + } + } + } + } + } - if (empty($error)) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - $this->db->rollback(); - return -1; - } - } + if (empty($error)) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $this->db->rollback(); + return -1; + } + } - /** - * Function to get a formatted date - * - * @param string $field Attribute to return - * @param string $format Output date format - * @return string - */ - public function getDate($field, $format = '') - { - if (empty($this->{$field})) return ''; - else { - return dol_print_date($this->{$field}, $format); - } - } + /** + * Function to get a formatted date + * + * @param string $field Attribute to return + * @param string $format Output date format + * @return string + */ + public function getDate($field, $format = '') + { + if (empty($this->{$field})) return ''; + else { + return dol_print_date($this->{$field}, $format); + } + } - /** - * Function to set date in field - * - * @param string $field field to set - * @param string $date formatted date to convert - * @return mixed - */ - public function setDate($field, $date) - { - if (empty($date)) - { - $this->{$field} = 0; - } else { - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $this->{$field} = dol_stringtotime($date); - } + /** + * Function to set date in field + * + * @param string $field field to set + * @param string $date formatted date to convert + * @return mixed + */ + public function setDate($field, $date) + { + if (empty($date)) + { + $this->{$field} = 0; + } else { + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + $this->{$field} = dol_stringtotime($date); + } - return $this->{$field}; - } + return $this->{$field}; + } - /** - * Function to update current object - * - * @param array $Tab Array of values - * @return int - */ - public function setValues(&$Tab) - { - foreach ($Tab as $key => $value) - { - if ($this->checkFieldType($key, 'date')) - { - $this->setDate($key, $value); - } elseif ($this->checkFieldType($key, 'float')) - { - $this->{$key} = (double) price2num($value); - } elseif ($this->checkFieldType($key, 'int')) { - $this->{$key} = (int) price2num($value); - } else { - $this->{$key} = dol_string_nohtmltag($value); - } - } + /** + * Function to update current object + * + * @param array $Tab Array of values + * @return int + */ + public function setValues(&$Tab) + { + foreach ($Tab as $key => $value) + { + if ($this->checkFieldType($key, 'date')) + { + $this->setDate($key, $value); + } elseif ($this->checkFieldType($key, 'float')) + { + $this->{$key} = (double) price2num($value); + } elseif ($this->checkFieldType($key, 'int')) { + $this->{$key} = (int) price2num($value); + } else { + $this->{$key} = dol_string_nohtmltag($value); + } + } - return 1; - } + return 1; + } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 993528464fd..1ed6056404e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -38,103 +38,103 @@ class ExtraFields { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** - * @var array Array with type of element (for what object is the extrafield) + * @var array Array with type of element (for what object is the extrafield) * @deprecated - */ - public $attribute_elementtype; + */ + public $attribute_elementtype; - /** - * @var array Array with type of the extra field + /** + * @var array Array with type of the extra field * @deprecated - */ - public $attribute_type; + */ + public $attribute_type; - /** - * @var array Array with label of extra field + /** + * @var array Array with label of extra field * @deprecated - */ - public $attribute_label; + */ + public $attribute_label; - /** - * @var array Array with size of extra field + /** + * @var array Array with size of extra field * @deprecated - */ + */ public $attribute_size; - /** - * @var array Array with list of possible values for some types of extra fields + /** + * @var array Array with list of possible values for some types of extra fields * @deprecated - */ + */ public $attribute_choice; - /** - * @var array Array to store compute formula for computed fields + /** + * @var array Array to store compute formula for computed fields * @deprecated - */ + */ public $attribute_computed; - /** - * @var array Array to store default value + /** + * @var array Array to store default value * @deprecated - */ + */ public $attribute_default; - /** - * @var array Array to store if attribute is unique or not + /** + * @var array Array to store if attribute is unique or not * @deprecated - */ + */ public $attribute_unique; - /** - * @var array Array to store if attribute is required or not + /** + * @var array Array to store if attribute is required or not * @deprecated - */ + */ public $attribute_required; - /** - * @var array Array to store parameters of attribute (used in select type) + /** + * @var array Array to store parameters of attribute (used in select type) * @deprecated - */ + */ public $attribute_param; - /** - * @var array Array to store position of attribute + /** + * @var array Array to store position of attribute * @deprecated - */ + */ public $attribute_pos; - /** - * @var array Array to store if attribute is editable regardless of the document status + /** + * @var array Array to store if attribute is editable regardless of the document status * @deprecated - */ + */ public $attribute_alwayseditable; - /** - * @var array Array to store permission to check + /** + * @var array Array to store permission to check * @deprecated - */ + */ public $attribute_perms; - /** - * @var array Array to store language file to translate label of values + /** + * @var array Array to store language file to translate label of values * @deprecated - */ + */ public $attribute_langfile; - /** - * @var array Array to store if field is visible by default on list + /** + * @var array Array to store if field is visible by default on list * @deprecated - */ + */ public $attribute_list; /** - * @var array New array to store extrafields definition - */ + * @var array New array to store extrafields definition + */ public $attributes; /** @@ -147,33 +147,33 @@ class ExtraFields */ public $errors = array(); - /** + /** * @var string DB Error number */ public $errno; public static $type2label = array( - 'varchar'=>'String1Line', - 'text'=>'TextLongNLines', - 'html'=>'HtmlText', - 'int'=>'Int', - 'double'=>'Float', - 'date'=>'Date', - 'datetime'=>'DateAndTime', - 'boolean'=>'Boolean', - 'price'=>'ExtrafieldPrice', - 'phone'=>'ExtrafieldPhone', - 'mail'=>'ExtrafieldMail', - 'url'=>'ExtrafieldUrl', - 'password' => 'ExtrafieldPassword', - 'select' => 'ExtrafieldSelect', - 'sellist' => 'ExtrafieldSelectList', - 'radio' => 'ExtrafieldRadio', - 'checkbox' => 'ExtrafieldCheckBox', - 'chkbxlst' => 'ExtrafieldCheckBoxFromList', - 'link' => 'ExtrafieldLink', - 'separate' => 'ExtrafieldSeparator', + 'varchar'=>'String1Line', + 'text'=>'TextLongNLines', + 'html'=>'HtmlText', + 'int'=>'Int', + 'double'=>'Float', + 'date'=>'Date', + 'datetime'=>'DateAndTime', + 'boolean'=>'Boolean', + 'price'=>'ExtrafieldPrice', + 'phone'=>'ExtrafieldPhone', + 'mail'=>'ExtrafieldMail', + 'url'=>'ExtrafieldUrl', + 'password' => 'ExtrafieldPassword', + 'select' => 'ExtrafieldSelect', + 'sellist' => 'ExtrafieldSelectList', + 'radio' => 'ExtrafieldRadio', + 'checkbox' => 'ExtrafieldCheckBox', + 'chkbxlst' => 'ExtrafieldCheckBoxFromList', + 'link' => 'ExtrafieldLink', + 'separate' => 'ExtrafieldSeparator', ); @@ -181,7 +181,7 @@ class ExtraFields * Constructor * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -225,7 +225,7 @@ class ExtraFields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @param int $totalizable Is a measure. Must show a total on lists - * @param int $printable Is extrafield displayed on PDF + * @param int $printable Is extrafield displayed on PDF * @return int <=0 if KO, >0 if OK */ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) @@ -345,7 +345,7 @@ class ExtraFields } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add description of a new optional attribute * @@ -368,13 +368,13 @@ class ExtraFields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @param int $totalizable Is a measure. Must show a total on lists - * @param int $printable Is extrafield displayed on PDF + * @param int $printable Is extrafield displayed on PDF * @return int <=0 if KO, >0 if OK - * @throws Exception + * @throws Exception */ private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) { - // phpcs:enable + // phpcs:enable global $conf, $user; if ($elementtype == 'thirdparty') $elementtype = 'societe'; @@ -485,33 +485,33 @@ class ExtraFields $result = $this->delete_label($attrname, $elementtype); if ($result < 0) { - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->errors[] = $this->db->lasterror(); - $error++; + $error++; } if (!$error) { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; - $sql .= " WHERE elementtype = '".$elementtype."'"; - $sql .= " AND name = '".$attrname."'"; - //$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb <= 0) - { - $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key - if ($result < 0) - { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->db->lasterror(); - $error++; - } - } - } + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."extrafields"; + $sql .= " WHERE elementtype = '".$elementtype."'"; + $sql .= " AND name = '".$attrname."'"; + //$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb <= 0) + { + $result = $this->db->DDLDropField(MAIN_DB_PREFIX.$table, $attrname); // This also drop the unique key + if ($result < 0) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + $error++; + } + } + } } return $result; @@ -520,7 +520,7 @@ class ExtraFields } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete description of an optional attribute * @@ -530,7 +530,7 @@ class ExtraFields */ private function delete_label($attrname, $elementtype = 'member') { - // phpcs:enable + // phpcs:enable global $conf; if ($elementtype == 'thirdparty') $elementtype = 'societe'; @@ -578,17 +578,17 @@ class ExtraFields * @param string $entity Entity of extrafields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not - * @param int $totalizable Is extrafield totalizable on list - * @param int $printable Is extrafield displayed on PDF + * @param int $totalizable Is extrafield totalizable on list + * @param int $printable Is extrafield displayed on PDF * @return int >0 if OK, <=0 if KO - * @throws Exception + * @throws Exception */ public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) { if ($elementtype == 'thirdparty') $elementtype = 'societe'; if ($elementtype == 'contact') $elementtype = 'socpeople'; - $table = $elementtype.'_extrafields'; + $table = $elementtype.'_extrafields'; if ($elementtype == 'categorie') $table = 'categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) @@ -660,7 +660,7 @@ class ExtraFields } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Modify description of personalized attribute * @@ -682,14 +682,14 @@ class ExtraFields * @param string $entity Entity of extrafields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not - * @param int $totalizable Is extrafield totalizable on list - * @param int $printable Is extrafield displayed on PDF - * @return int <=0 if KO, >0 if OK - * @throws Exception + * @param int $totalizable Is extrafield totalizable on list + * @param int $printable Is extrafield displayed on PDF + * @return int <=0 if KO, >0 if OK + * @throws Exception */ private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) { - // phpcs:enable + // phpcs:enable global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable.", ".$printable); @@ -699,9 +699,9 @@ class ExtraFields if (empty($pos)) $pos = 0; if (empty($list)) $list = '0'; - if (empty($totalizable)) { - $totalizable = 0; - } + if (empty($totalizable)) { + $totalizable = 0; + } if (empty($required)) $required = 0; if (empty($unique)) $unique = 0; if (empty($alwayseditable)) $alwayseditable = 0; @@ -752,7 +752,7 @@ class ExtraFields $sql .= " param,"; $sql .= " list,"; $sql .= " printable,"; - $sql .= " totalizable,"; + $sql .= " totalizable,"; $sql .= " fielddefault,"; $sql .= " fieldcomputed,"; $sql .= " fk_user_author,"; @@ -776,7 +776,7 @@ class ExtraFields $sql .= " '".$this->db->escape($params)."',"; $sql .= " '".$this->db->escape($list)."', "; $sql .= " '".$this->db->escape($printable)."', "; - $sql .= " ".($totalizable ? 'TRUE' : 'FALSE').","; + $sql .= " ".($totalizable ? 'TRUE' : 'FALSE').","; $sql .= " ".(($default != '') ? "'".$this->db->escape($default)."'" : "null").","; $sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").","; $sql .= " ".$user->id.","; @@ -803,7 +803,7 @@ class ExtraFields } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ... * @@ -813,7 +813,7 @@ class ExtraFields */ public function fetch_name_optionals_label($elementtype, $forceload = false) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($elementtype)) return array(); @@ -839,15 +839,15 @@ class ExtraFields { while ($tab = $this->db->fetch_object($resql)) { - if ($tab->entity != 0 && $tab->entity != $conf->entity) - { - // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value - if ($tab->fieldrequired && is_null($tab->fielddefault)) - { - $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name] = $tab->type; - } - continue; - } + if ($tab->entity != 0 && $tab->entity != $conf->entity) + { + // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value + if ($tab->fieldrequired && is_null($tab->fielddefault)) + { + $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name] = $tab->type; + } + continue; + } // We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label'] if ($tab->type != 'separate') @@ -889,7 +889,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['langfile'][$tab->name] = $tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name] = $tab->list; $this->attributes[$tab->elementtype]['printable'][$tab->name] = $tab->printable; - $this->attributes[$tab->elementtype]['totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0); + $this->attributes[$tab->elementtype]['totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0); $this->attributes[$tab->elementtype]['entityid'][$tab->name] = $tab->entity; $this->attributes[$tab->elementtype]['enabled'][$tab->name] = $tab->enabled; $this->attributes[$tab->elementtype]['help'][$tab->name] = $tab->help; @@ -1125,8 +1125,8 @@ class ExtraFields // 2 : key fields name (if differ of rowid) // 3 : key field parent (for dependent lists) // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value - // 5 : id category type - // 6 : ids categories list separated by comma for category root + // 5 : id category type + // 6 : ids categories list separated by comma for category root $keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid'); @@ -1145,122 +1145,122 @@ class ExtraFields $keyList .= ', '.$parentField; } - $filter_categorie = false; - if (count($InfoFieldList) > 5) { - if ($InfoFieldList[0] == 'categorie') { - $filter_categorie = true; - } - } + $filter_categorie = false; + if (count($InfoFieldList) > 5) { + if ($InfoFieldList[0] == 'categorie') { + $filter_categorie = true; + } + } - if ($filter_categorie === false) { - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label)) { - $keyList .= ', '; - $keyList .= implode(', ', $fields_label); - } + if ($filter_categorie === false) { + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label)) { + $keyList .= ', '; + $keyList .= implode(', ', $fields_label); + } - $sqlwhere = ''; - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; - if (!empty($InfoFieldList[4])) { - // can use curent entity filter - if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { - $InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]); - } - // can use SELECT request - if (strpos($InfoFieldList[4], '$SEL$') !== false) { - $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); - } + $sqlwhere = ''; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + if (!empty($InfoFieldList[4])) { + // can use curent entity filter + if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { + $InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]); + } + // can use SELECT request + if (strpos($InfoFieldList[4], '$SEL$') !== false) { + $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); + } - // current object id can be use into filter - if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); - } else { - $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); - } - //We have to join on extrafield table - if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; - } else { - $sqlwhere .= ' WHERE '.$InfoFieldList[4]; - } - } else { - $sqlwhere .= ' WHERE 1=1'; - } - // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0], array('tablewithentity'))) { - $sqlwhere .= ' AND entity = '.$conf->entity; - } - $sql .= $sqlwhere; - //print $sql; + // current object id can be use into filter + if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { + $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); + } else { + $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); + } + //We have to join on extrafield table + if (strpos($InfoFieldList[4], 'extra') !== false) { + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra'; + $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4]; + } else { + $sqlwhere .= ' WHERE '.$InfoFieldList[4]; + } + } else { + $sqlwhere .= ' WHERE 1=1'; + } + // Some tables may have field, some other not. For the moment we disable it. + if (in_array($InfoFieldList[0], array('tablewithentity'))) { + $sqlwhere .= ' AND entity = '.$conf->entity; + } + $sql .= $sqlwhere; + //print $sql; - $sql .= ' ORDER BY '.implode(', ', $fields_label); + $sql .= ' ORDER BY '.implode(', ', $fields_label); - dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $out .= ''; - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $labeltoshow = ''; - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $out .= ''; + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $labeltoshow = ''; + $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) - $notrans = false; - $fields_label = explode('|', $InfoFieldList[1]); - if (is_array($fields_label) && count($fields_label) > 1) { - $notrans = true; - foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow.' '; - } - } else { - $labeltoshow = $obj->{$InfoFieldList[1]}; - } - $labeltoshow = dol_trunc($labeltoshow, 45); + // Several field into label (eq table:code|libelle:rowid) + $notrans = false; + $fields_label = explode('|', $InfoFieldList[1]); + if (is_array($fields_label) && count($fields_label) > 1) { + $notrans = true; + foreach ($fields_label as $field_toshow) { + $labeltoshow .= $obj->$field_toshow.' '; + } + } else { + $labeltoshow = $obj->{$InfoFieldList[1]}; + } + $labeltoshow = dol_trunc($labeltoshow, 45); - if ($value == $obj->rowid) { - if (!$notrans) { - foreach ($fields_label as $field_toshow) { - $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18).' '; - } - } - $out .= ''; - } else { - if (!$notrans) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - $labeltoshow =$translabel; - } - if (empty($labeltoshow)) $labeltoshow = '(not defined)'; + if ($value == $obj->rowid) { + if (!$notrans) { + foreach ($fields_label as $field_toshow) { + $translabel = $langs->trans($obj->$field_toshow); + $labeltoshow = dol_trunc($translabel, 18).' '; + } + } + $out .= ''; + } else { + if (!$notrans) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + $labeltoshow =$translabel; + } + if (empty($labeltoshow)) $labeltoshow = '(not defined)'; - if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName.':'.$obj->{$parentField}; - } + if (!empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName.':'.$obj->{$parentField}; + } - $out .= ''; - } + $out .= ''; + } - $i++; - } - $this->db->free($resql); - } else { - print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; - } - } else { + $i++; + } + $this->db->free($resql); + } else { + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; + } + } else { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); - $out .= ''; - foreach ($data as $data_key => $data_value) { - $out .= ''; + foreach ($data as $data_key => $data_value) { + $out .= '
'; - } - if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { - if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; - } - $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($usercancreate) && $action == 'edit_thirdparty') { + $morehtmlref .= ' : '; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300'); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } + if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; + } + $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } // Project - if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($usercancreate) { - if ($action != 'classify') - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($usercancreate) { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref .= ''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 3fb825c06b9..617de720ae5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -111,152 +111,152 @@ if (empty($reshook)) header("Location: ".$backtopage); exit; } - $action = ''; + $action = ''; } // If create a request if ($action == 'create') { - // If no right to create a request - if (!$cancreate) - { - $error++; - setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); - $action = 'request'; - } + // If no right to create a request + if (!$cancreate) + { + $error++; + setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); + $action = 'request'; + } - if (!$error) - { - $object = new Holiday($db); + if (!$error) + { + $object = new Holiday($db); - $db->begin(); + $db->begin(); - $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); - $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); - $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); - $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); - $starthalfday = GETPOST('starthalfday'); - $endhalfday = GETPOST('endhalfday'); - $type = GETPOST('type'); - $halfday = 0; - if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2; - elseif ($starthalfday == 'afternoon') $halfday = -1; - elseif ($endhalfday == 'morning') $halfday = 1; + $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); + $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); + $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1); + $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1); + $starthalfday = GETPOST('starthalfday'); + $endhalfday = GETPOST('endhalfday'); + $type = GETPOST('type'); + $halfday = 0; + if ($starthalfday == 'afternoon' && $endhalfday == 'morning') $halfday = 2; + elseif ($starthalfday == 'afternoon') $halfday = -1; + elseif ($endhalfday == 'morning') $halfday = 1; - $valideur = GETPOST('valideur', 'int'); - $description = trim(GETPOST('description', 'none')); + $valideur = GETPOST('valideur', 'int'); + $description = trim(GETPOST('description', 'none')); - // If no type - if ($type <= 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error++; - $action = 'create'; - } + // If no type + if ($type <= 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $error++; + $action = 'create'; + } - // If no start date - if (empty($date_debut)) - { - setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); - $error++; - $action = 'create'; - } - // If no end date - if (empty($date_fin)) - { - setEventMessages($langs->trans("NoDateFin"), null, 'errors'); - $error++; - $action = 'create'; - } - // If start date after end date - if ($date_debut > $date_fin) - { - setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); - $error++; - $action = 'create'; - } + // If no start date + if (empty($date_debut)) + { + setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); + $error++; + $action = 'create'; + } + // If no end date + if (empty($date_fin)) + { + setEventMessages($langs->trans("NoDateFin"), null, 'errors'); + $error++; + $action = 'create'; + } + // If start date after end date + if ($date_debut > $date_fin) + { + setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); + $error++; + $action = 'create'; + } - // Check if there is already holiday for this period - $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); - if (!$verifCP) - { - setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); - $error++; - $action = 'create'; - } + // Check if there is already holiday for this period + $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); + if (!$verifCP) + { + setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); + $error++; + $action = 'create'; + } - // If there is no Business Days within request - $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if ($nbopenedday < 0.5) - { - setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); - $error++; - $action = 'create'; - } + // If there is no Business Days within request + $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); + if ($nbopenedday < 0.5) + { + setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); + $error++; + $action = 'create'; + } - // If no validator designated - if ($valideur < 1) - { - setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); - $error++; - } + // If no validator designated + if ($valideur < 1) + { + setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors'); + $error++; + } - $result = 0; + $result = 0; - if (!$error) - { - $object->fk_user = $fuserid; - $object->description = $description; - $object->fk_validator = $valideur; - $object->fk_type = $type; - $object->date_debut = $date_debut; - $object->date_fin = $date_fin; - $object->halfday = $halfday; + if (!$error) + { + $object->fk_user = $fuserid; + $object->description = $description; + $object->fk_validator = $valideur; + $object->fk_type = $type; + $object->date_debut = $date_debut; + $object->date_fin = $date_fin; + $object->halfday = $halfday; - $result = $object->create($user); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } + $result = $object->create($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } - // If no SQL error we redirect to the request card - if (!$error) - { + // If no SQL error we redirect to the request card + if (!$error) + { $db->commit(); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } else { - $db->rollback(); - } - } + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } else { + $db->rollback(); + } + } } if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { - $object->fetch($id); + $object->fetch($id); - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); - $object->fk_validator = GETPOST('valideur', 'int'); + $object->fk_validator = GETPOST('valideur', 'int'); - if ($object->fk_validator != $object->oldcopy->fk_validator) - { - $verif = $object->update($user); + if ($object->fk_validator != $object->oldcopy->fk_validator) + { + $verif = $object->update($user); - if ($verif <= 0) - { - setEventMessages($object->error, $object->errors, 'warnings'); - $action = 'editvalidator'; - } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } + if ($verif <= 0) + { + setEventMessages($object->error, $object->errors, 'warnings'); + $action = 'editvalidator'; + } else { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } - $action = ''; + $action = ''; } if ($action == 'update' && !GETPOSTISSET('savevalidator')) diff --git a/htdocs/index.php b/htdocs/index.php index 307b356d522..65787fda020 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -450,14 +450,14 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); - $dashboardlines[$board->element . '_toapprove'] = $board->load_board($user, 'toapprove'); + $dashboardlines[$board->element.'_toapprove'] = $board->load_board($user, 'toapprove'); } // Number of expense reports to pay if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); - $dashboardlines[$board->element . '_topay'] = $board->load_board($user, 'topay'); + $dashboardlines[$board->element.'_topay'] = $board->load_board($user, 'topay'); } // Number of holidays to approve diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 2d9501ea549..9c5c1b559ad 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -41,63 +41,63 @@ class PaymentLoan extends CommonObject */ public $table_element = 'payment_loan'; - /** - * @var string String with name of icon for PaymentLoan - */ - public $picto = 'money-bill-alt'; + /** + * @var string String with name of icon for PaymentLoan + */ + public $picto = 'money-bill-alt'; - /** - * @var int Loan ID - */ - public $fk_loan; + /** + * @var int Loan ID + */ + public $fk_loan; - /** - * @var string Create date - */ - public $datec = ''; + /** + * @var string Create date + */ + public $datec = ''; - public $tms = ''; + public $tms = ''; - /** - * @var string Payment date - */ - public $datep = ''; + /** + * @var string Payment date + */ + public $datep = ''; - public $amounts = array(); // Array of amounts + public $amounts = array(); // Array of amounts - public $amount_capital; // Total amount of payment + public $amount_capital; // Total amount of payment - public $amount_insurance; + public $amount_insurance; - public $amount_interest; + public $amount_interest; - /** - * @var int Payment mode ID - */ - public $fk_typepayment; + /** + * @var int Payment mode ID + */ + public $fk_typepayment; - /** - * @var int Payment ID - */ - public $num_payment; + /** + * @var int Payment ID + */ + public $num_payment; - /** - * @var int Bank ID - */ - public $fk_bank; + /** + * @var int Bank ID + */ + public $fk_bank; - /** - * @var int User ID - */ - public $fk_user_creat; + /** + * @var int User ID + */ + public $fk_user_creat; - /** - * @var int user ID - */ - public $fk_user_modif; + /** + * @var int user ID + */ + public $fk_user_modif; - public $type_code; - public $type_label; + public $type_code; + public $type_label; /** @@ -367,23 +367,23 @@ class PaymentLoan extends CommonObject if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - // Set loan unpaid if loan has no other payment - if (!$error) - { - require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; - $loan = new Loan($this->db); - $loan->fetch($this->fk_loan); - $sum_payment = $loan->getSumPayment(); - if ($sum_payment == 0) - { - dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); - if ($loan->set_unpaid($user) < 1) - { - $error++; - dol_print_error($this->db); - } - } - } + // Set loan unpaid if loan has no other payment + if (!$error) + { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; + $loan = new Loan($this->db); + $loan->fetch($this->fk_loan); + $sum_payment = $loan->getSumPayment(); + if ($sum_payment == 0) + { + dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG); + if ($loan->set_unpaid($user) < 1) + { + $error++; + dol_print_error($this->db); + } + } + } //if (! $error) //{ @@ -435,7 +435,7 @@ class PaymentLoan extends CommonObject global $conf; $error = 0; - $this->db->begin(); + $this->db->begin(); if (!empty($conf->banque->enabled)) { @@ -448,9 +448,9 @@ class PaymentLoan extends CommonObject if ($mode == 'payment_loan') $total = -$total; // Insert payment into llx_bank - $bank_line_id = $acc->addline( + $bank_line_id = $acc->addline( $this->datep, - $this->fk_typepayment, // Payment mode ID or code ("CHQ or VIR for example") + $this->fk_typepayment, // Payment mode ID or code ("CHQ or VIR for example") $label, $total, $this->num_payment, @@ -498,36 +498,36 @@ class PaymentLoan extends CommonObject } - // Set loan payment started if no set - if (!$error) - { - require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; - $loan = new Loan($this->db); - $loan->fetch($fk_loan); - if ($loan->paid == $loan::STATUS_UNPAID) - { - dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); - if ($loan->set_started($user) < 1) - { - $error++; - dol_print_error($this->db); - } - } - } + // Set loan payment started if no set + if (!$error) + { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; + $loan = new Loan($this->db); + $loan->fetch($fk_loan); + if ($loan->paid == $loan::STATUS_UNPAID) + { + dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG); + if ($loan->set_started($user) < 1) + { + $error++; + dol_print_error($this->db); + } + } + } if (!$error) { - $this->db->commit(); + $this->db->commit(); return 1; } else { - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between loan's payment and the line generate in llx_bank * @@ -536,14 +536,14 @@ class PaymentLoan extends CommonObject */ public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->fk_bank = $id_bank; + $this->fk_bank = $id_bank; return 1; } else { $this->error = $this->db->error(); @@ -556,9 +556,9 @@ class PaymentLoan extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=No picto * @param int $maxlen Max length label - * @param int $notooltip 1=Disable tooltip - * @param string $moretitle Add more text to title tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param string $moretitle Add more text to title tooltip + * @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, $maxlen = 0, $notooltip = 0, $moretitle = '', $save_lastsearch_value = -1) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 2f9b8babfed..2d714deeb2c 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -49,8 +49,8 @@ $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); if ($result <= 0) { - dol_print_error($db, $object->error); - exit; + dol_print_error($db, $object->error); + exit; } $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); @@ -67,112 +67,112 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) $action = ''; + if ($cancel) $action = ''; - // Delete - if ($action == 'delete_confirm') - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + // Delete + if ($action == 'delete_confirm') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); - $result = $object->delete($user, '', $numsondage); + $result = $object->delete($user, '', $numsondage); - header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); - exit(); - } + header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); + exit(); + } - // Close - if ($action == 'close') - { - $object->status = Opensurveysondage::STATUS_CLOSED; - $object->update($user); - } + // Close + if ($action == 'close') + { + $object->status = Opensurveysondage::STATUS_CLOSED; + $object->update($user); + } - // Reopend - if ($action == 'reopen') - { - $object->status = Opensurveysondage::STATUS_VALIDATED; - $object->update($user); - } + // Reopend + if ($action == 'reopen') + { + $object->status = Opensurveysondage::STATUS_VALIDATED; + $object->update($user); + } - // Update - if ($action == 'update') - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + // Update + if ($action == 'update') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); - $error = 0; + $error = 0; - if (!GETPOST('nouveautitre')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); - $error++; - $action = 'edit'; - } + if (!GETPOST('nouveautitre')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); + $error++; + $action = 'edit'; + } - if (!$error) - { - $object->title = GETPOST('nouveautitre', 'nohtml'); - $object->description = GETPOST('nouveauxcommentaires', 'restricthtml'); - $object->mail_admin = GETPOST('nouvelleadresse', 'alpha'); - $object->date_fin = $expiredate; - $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0; - $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0; - $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; + if (!$error) + { + $object->title = GETPOST('nouveautitre', 'nohtml'); + $object->description = GETPOST('nouveauxcommentaires', 'restricthtml'); + $object->mail_admin = GETPOST('nouvelleadresse', 'alpha'); + $object->date_fin = $expiredate; + $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? 1 : 0; + $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? 1 : 0; + $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; - $res = $object->update($user); - if ($res < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } - } - } + $res = $object->update($user); + if ($res < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } + } + } - // Add comment - if (GETPOST('ajoutcomment')) - { - $error = 0; + // Add comment + if (GETPOST('ajoutcomment')) + { + $error = 0; - if (!GETPOST('comment')) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); - } - if (!GETPOST('commentuser')) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); - } + if (!GETPOST('comment')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); + } + if (!GETPOST('commentuser')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); + } - if (!$error) - { - $comment = GETPOST("comment"); - $comment_user = GETPOST('commentuser'); + if (!$error) + { + $comment = GETPOST("comment"); + $comment_user = GETPOST('commentuser'); - $resql = $object->addComment($comment, $comment_user); + $resql = $object->addComment($comment, $comment_user); - if (!$resql) - { - setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); - } - } - } + if (!$resql) + { + setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); + } + } + } - // Delete comment - $idcomment = GETPOST('deletecomment', 'int'); - if ($idcomment) - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + // Delete comment + $idcomment = GETPOST('deletecomment', 'int'); + if ($idcomment) + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); - $resql = $object->deleteComment($idcomment); - } + $resql = $object->deleteComment($idcomment); + } - if ($action == 'edit') { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - } + if ($action == 'edit') { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + } } @@ -302,8 +302,8 @@ print ''; print ''.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); else { - print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); + print dol_print_date($object->date_fin, 'day'); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); } print ''; @@ -356,19 +356,19 @@ print ''."\n"; print '
'; if ($action != 'edit' && $user->rights->opensurvey->write) { - //Modify button - print ''.$langs->trans("Modify").''; + //Modify button + print ''.$langs->trans("Modify").''; - if ($object->status == Opensurveysondage::STATUS_VALIDATED) - { - //Close button - print ''.$langs->trans("Close").''; - } - if ($object->status == Opensurveysondage::STATUS_CLOSED) - { - //Opened button - print ''.$langs->trans("ReOpen").''; - } + if ($object->status == Opensurveysondage::STATUS_VALIDATED) + { + //Close button + print ''.$langs->trans("Close").''; + } + if ($object->status == Opensurveysondage::STATUS_CLOSED) + { + //Opened button + print ''.$langs->trans("ReOpen").''; + } //Delete button print ''.$langs->trans('Delete').''; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 0c2b00735ff..71288266b45 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -34,616 +34,616 @@ require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; */ class Opensurveysondage extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'opensurvey_sondage'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'opensurvey_sondage'; - - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'poll'; - - - /** - * @var string ID survey - */ - public $id_sondage; - - /** - * @var string description - */ - public $description; - - public $mail_admin; - public $nom_admin; - - /** - * Id of user author of the poll - * @var int - */ - public $fk_user_creat; - - /** - * @var string Title - */ - public $title; - - public $date_fin = ''; - public $status = 1; - public $format; - public $mailsonde; - - public $sujet; - - /** - * @var int Allow comments on this poll - */ - public $allow_comments; - - /** - * @var int Allow users see others vote - */ - public $allow_spy; - - - /** - * Draft status (not used) - */ - const STATUS_DRAFT = 0; - /** - * Validated/Opened status - */ - const STATUS_VALIDATED = 1; - /** - * Closed - */ - const STATUS_CLOSED = 2; - - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - - - /** - * Create object into database - * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = 0) - { - $error = 0; - - // Clean parameters - $this->cleanParameters(); - - // Check parameters - if (!$this->date_fin > 0) - { - $this->error = 'BadValueForEndDate'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } - - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; - $sql .= "id_sondage,"; - $sql .= "commentaires,"; - $sql .= "fk_user_creat,"; - $sql .= "titre,"; - $sql .= "date_fin,"; - $sql .= "status,"; - $sql .= "format,"; - $sql .= "mailsonde,"; - $sql .= "allow_comments,"; - $sql .= "allow_spy,"; - $sql .= "sujet"; - $sql .= ") VALUES ("; - $sql .= "'".$this->db->escape($this->id_sondage)."',"; - $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; - $sql .= " ".$user->id.","; - $sql .= " '".$this->db->escape($this->title)."',"; - $sql .= " '".$this->db->idate($this->date_fin)."',"; - $sql .= " ".$this->status.","; - $sql .= " '".$this->db->escape($this->format)."',"; - $sql .= " ".$this->db->escape($this->mailsonde).","; - $sql .= " ".$this->db->escape($this->allow_comments).","; - $sql .= " ".$this->db->escape($this->allow_spy).","; - $sql .= " '".$this->db->escape($this->sujet)."'"; - $sql .= ")"; - - $this->db->begin(); - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - - if (!$error) - { - if (!$notrigger) - { - global $langs, $conf; - - // Call trigger - $result = $this->call_trigger('OPENSURVEY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return $this->id; - } - } - - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $numsurvey Ref of survey (admin or not) - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $numsurvey = '') - { - $sql = "SELECT"; - $sql .= " t.id_sondage,"; - $sql .= " t.titre as title,"; - $sql .= " t.commentaires as description,"; - $sql .= " t.mail_admin,"; - $sql .= " t.nom_admin,"; - $sql .= " t.fk_user_creat,"; - $sql .= " t.date_fin,"; - $sql .= " t.status,"; - $sql .= " t.format,"; - $sql .= " t.mailsonde,"; - $sql .= " t.allow_comments,"; - $sql .= " t.allow_spy,"; - $sql .= " t.sujet,"; - $sql .= " t.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; - $sql .= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id_sondage = $obj->id_sondage; - $this->ref = $this->id_sondage; //For compatibility - - $this->description = $obj->description; - $this->mail_admin = $obj->mail_admin; - $this->nom_admin = $obj->nom_admin; - $this->title = $obj->title; - $this->date_fin = $this->db->jdate($obj->date_fin); - $this->status = $obj->status; - $this->format = $obj->format; - $this->mailsonde = $obj->mailsonde; - $this->allow_comments = $obj->allow_comments; - $this->allow_spy = $obj->allow_spy; - $this->sujet = $obj->sujet; - $this->fk_user_creat = $obj->fk_user_creat; - - $this->date_m = $this->db->jdate($obj->tls); - $ret = 1; - } else { - $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); - $this->error = 'Fetch no poll found for '.$sondage; - dol_syslog($this->error, LOG_ERR); - $ret = 0; - } - - $this->db->free($resql); - } else { - $this->error = "Error ".$this->db->lasterror(); - $ret = -1; - } - - return $ret; - } - - - /** - * Update object into database - * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = 0) - { - global $conf, $langs; - $error = 0; - - // Clean parameters - $this->cleanParameters(); - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; - $sql .= " id_sondage=".(isset($this->id_sondage) ? "'".$this->db->escape($this->id_sondage)."'" : "null").","; - $sql .= " commentaires=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; - $sql .= " mail_admin=".(isset($this->mail_admin) ? "'".$this->db->escape($this->mail_admin)."'" : "null").","; - $sql .= " nom_admin=".(isset($this->nom_admin) ? "'".$this->db->escape($this->nom_admin)."'" : "null").","; - $sql .= " titre=".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "null").","; - $sql .= " date_fin=".(dol_strlen($this->date_fin) != 0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; - $sql .= " status=".(isset($this->status) ? "'".$this->db->escape($this->status)."'" : "null").","; - $sql .= " format=".(isset($this->format) ? "'".$this->db->escape($this->format)."'" : "null").","; - $sql .= " mailsonde=".(isset($this->mailsonde) ? $this->db->escape($this->mailsonde) : "null").","; - $sql .= " allow_comments=".$this->db->escape($this->allow_comments).","; - $sql .= " allow_spy=".$this->db->escape($this->allow_spy); - $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - - $this->db->begin(); - - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } - - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @param string $numsondage Num sondage admin to delete - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = 0, $numsondage = '') - { - global $conf, $langs; - $error = 0; - - if (empty($numsondage)) - { - $numsondage = $this->id_sondage; - } - - $this->db->begin(); - - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('OPENSURVEY_DELETE', $user); - if ($result < 0) $error++; - // End call triggers - } - } - - if (!$error) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; - $sql .= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - } - - // Commit or rollback - if ($error) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - 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 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, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - - $result = ''; - $companylink = ''; - - $label = ''.$langs->trans("ShowSurvey").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; - $label .= ''.$langs->trans('Title').': '.$this->title.'
'; - - $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; - - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - - $linkstart = ''; - $linkend = ''; - - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; - - return $result; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return array of lines - * - * @return int <0 if KO, >0 if OK - */ - public function fetch_lines() - { - // phpcs:enable - $ret = array(); - - $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; - $resql = $this->db->query($sql); - - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); - - $ret[] = $tmp; - $i++; - } - } else dol_print_error($this->db); - - $this->lines = $ret; - - return count($this->lines); - } - - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->id = 0; - - $this->id_sondage = ''; - $this->description = 'Description of the specimen survey'; - $this->mail_admin = ''; - $this->nom_admin = ''; - $this->title = 'This is a specimen survey'; - $this->date_fin = dol_now() + 3600 * 24 * 10; - $this->status = 1; - $this->format = 'classic'; - $this->mailsonde = ''; - } - - /** - * Returns all comments for the current opensurvey poll - * - * @return Object[] - */ - public function getComments() - { - $comments = array(); - - $sql = 'SELECT id_comment, usercomment, comment'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; - $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $sql .= " ORDER BY id_comment"; - $resql = $this->db->query($sql); - - if ($resql) - { - $num_rows = $this->db->num_rows($resql); - - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { - $comments[] = $obj; - } - } - } - - return $comments; - } - - /** - * Adds a comment to the poll - * - * @param string $comment Comment content - * @param string $comment_user Comment author - * @return boolean False in case of the query fails, true if it was successful - */ - public function addComment($comment, $comment_user) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; - $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; - $resql = $this->db->query($sql); - - if (!$resql) { - return false; - } - - return true; - } - - /** - * Deletes a comment of the poll - * - * @param int $id_comment Id of the comment - * @return boolean False in case of the query fails, true if it was successful - */ - public function deleteComment($id_comment) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; - $resql = $this->db->query($sql); - - if (!$resql) { - return false; - } - - return true; - } - - /** - * Cleans all the class variables before doing an update or an insert - * - * @return void - */ - private function cleanParameters() - { - $this->id_sondage = trim($this->id_sondage); - $this->description = trim($this->description); - $this->mail_admin = trim($this->mail_admin); - $this->nom_admin = trim($this->nom_admin); - $this->title = trim($this->title); - $this->status = trim($this->status); - $this->format = trim($this->format); - $this->mailsonde = ($this->mailsonde ? 1 : 0); - $this->allow_comments = ($this->allow_comments ? 1 : 0); - $this->allow_spy = ($this->allow_spy ? 1 : 0); - $this->sujet = trim($this->sujet); - } - - - /** - * Return status label of Order - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - public function getLibStatut($mode) - { - return $this->LibStatut($this->status, $mode); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of status - * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode) - { - // phpcs:enable - global $langs, $conf; - - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { - global $langs; - //$langs->load("mymodule"); - $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Opened'); - $this->labelStatus[self::STATUS_CLOSED] = $langs->trans('Closed'); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Opened'); - $this->labelStatusShort[self::STATUS_CLOSED] = $langs->trans('Closed'); - } - - $statusType = 'status'.$status; - if ($status == self::STATUS_VALIDATED) { - if (0) $statusType = 'status1'; - else $statusType = 'status4'; - } - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; - - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } + /** + * @var string ID to identify managed object + */ + public $element = 'opensurvey_sondage'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'opensurvey_sondage'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'poll'; + + + /** + * @var string ID survey + */ + public $id_sondage; + + /** + * @var string description + */ + public $description; + + public $mail_admin; + public $nom_admin; + + /** + * Id of user author of the poll + * @var int + */ + public $fk_user_creat; + + /** + * @var string Title + */ + public $title; + + public $date_fin = ''; + public $status = 1; + public $format; + public $mailsonde; + + public $sujet; + + /** + * @var int Allow comments on this poll + */ + public $allow_comments; + + /** + * @var int Allow users see others vote + */ + public $allow_spy; + + + /** + * Draft status (not used) + */ + const STATUS_DRAFT = 0; + /** + * Validated/Opened status + */ + const STATUS_VALIDATED = 1; + /** + * Closed + */ + const STATUS_CLOSED = 2; + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = 0) + { + $error = 0; + + // Clean parameters + $this->cleanParameters(); + + // Check parameters + if (!$this->date_fin > 0) + { + $this->error = 'BadValueForEndDate'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; + $sql .= "id_sondage,"; + $sql .= "commentaires,"; + $sql .= "fk_user_creat,"; + $sql .= "titre,"; + $sql .= "date_fin,"; + $sql .= "status,"; + $sql .= "format,"; + $sql .= "mailsonde,"; + $sql .= "allow_comments,"; + $sql .= "allow_spy,"; + $sql .= "sujet"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->id_sondage)."',"; + $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; + $sql .= " ".$user->id.","; + $sql .= " '".$this->db->escape($this->title)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->status.","; + $sql .= " '".$this->db->escape($this->format)."',"; + $sql .= " ".$this->db->escape($this->mailsonde).","; + $sql .= " ".$this->db->escape($this->allow_comments).","; + $sql .= " ".$this->db->escape($this->allow_spy).","; + $sql .= " '".$this->db->escape($this->sujet)."'"; + $sql .= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + + if (!$error) + { + if (!$notrigger) + { + global $langs, $conf; + + // Call trigger + $result = $this->call_trigger('OPENSURVEY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $numsurvey Ref of survey (admin or not) + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $numsurvey = '') + { + $sql = "SELECT"; + $sql .= " t.id_sondage,"; + $sql .= " t.titre as title,"; + $sql .= " t.commentaires as description,"; + $sql .= " t.mail_admin,"; + $sql .= " t.nom_admin,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.date_fin,"; + $sql .= " t.status,"; + $sql .= " t.format,"; + $sql .= " t.mailsonde,"; + $sql .= " t.allow_comments,"; + $sql .= " t.allow_spy,"; + $sql .= " t.sujet,"; + $sql .= " t.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; + $sql .= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id_sondage = $obj->id_sondage; + $this->ref = $this->id_sondage; //For compatibility + + $this->description = $obj->description; + $this->mail_admin = $obj->mail_admin; + $this->nom_admin = $obj->nom_admin; + $this->title = $obj->title; + $this->date_fin = $this->db->jdate($obj->date_fin); + $this->status = $obj->status; + $this->format = $obj->format; + $this->mailsonde = $obj->mailsonde; + $this->allow_comments = $obj->allow_comments; + $this->allow_spy = $obj->allow_spy; + $this->sujet = $obj->sujet; + $this->fk_user_creat = $obj->fk_user_creat; + + $this->date_m = $this->db->jdate($obj->tls); + $ret = 1; + } else { + $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); + $this->error = 'Fetch no poll found for '.$sondage; + dol_syslog($this->error, LOG_ERR); + $ret = 0; + } + + $this->db->free($resql); + } else { + $this->error = "Error ".$this->db->lasterror(); + $ret = -1; + } + + return $ret; + } + + + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf, $langs; + $error = 0; + + // Clean parameters + $this->cleanParameters(); + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; + $sql .= " id_sondage=".(isset($this->id_sondage) ? "'".$this->db->escape($this->id_sondage)."'" : "null").","; + $sql .= " commentaires=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; + $sql .= " mail_admin=".(isset($this->mail_admin) ? "'".$this->db->escape($this->mail_admin)."'" : "null").","; + $sql .= " nom_admin=".(isset($this->nom_admin) ? "'".$this->db->escape($this->nom_admin)."'" : "null").","; + $sql .= " titre=".(isset($this->title) ? "'".$this->db->escape($this->title)."'" : "null").","; + $sql .= " date_fin=".(dol_strlen($this->date_fin) != 0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql .= " status=".(isset($this->status) ? "'".$this->db->escape($this->status)."'" : "null").","; + $sql .= " format=".(isset($this->format) ? "'".$this->db->escape($this->format)."'" : "null").","; + $sql .= " mailsonde=".(isset($this->mailsonde) ? $this->db->escape($this->mailsonde) : "null").","; + $sql .= " allow_comments=".$this->db->escape($this->allow_comments).","; + $sql .= " allow_spy=".$this->db->escape($this->allow_spy); + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('OPENSURVEY_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param string $numsondage Num sondage admin to delete + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = 0, $numsondage = '') + { + global $conf, $langs; + $error = 0; + + if (empty($numsondage)) + { + $numsondage = $this->id_sondage; + } + + $this->db->begin(); + + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('OPENSURVEY_DELETE', $user); + if ($result < 0) $error++; + // End call triggers + } + } + + if (!$error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; + $sql .= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + 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 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, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = ''.$langs->trans("ShowSurvey").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; + $label .= ''.$langs->trans('Title').': '.$this->title.'
'; + + $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; + + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + + $linkstart = ''; + $linkend = ''; + + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; + + return $result; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array of lines + * + * @return int <0 if KO, >0 if OK + */ + public function fetch_lines() + { + // phpcs:enable + $ret = array(); + + $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; + $resql = $this->db->query($sql); + + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); + + $ret[] = $tmp; + $i++; + } + } else dol_print_error($this->db); + + $this->lines = $ret; + + return count($this->lines); + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->id_sondage = ''; + $this->description = 'Description of the specimen survey'; + $this->mail_admin = ''; + $this->nom_admin = ''; + $this->title = 'This is a specimen survey'; + $this->date_fin = dol_now() + 3600 * 24 * 10; + $this->status = 1; + $this->format = 'classic'; + $this->mailsonde = ''; + } + + /** + * Returns all comments for the current opensurvey poll + * + * @return Object[] + */ + public function getComments() + { + $comments = array(); + + $sql = 'SELECT id_comment, usercomment, comment'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql .= " ORDER BY id_comment"; + $resql = $this->db->query($sql); + + if ($resql) + { + $num_rows = $this->db->num_rows($resql); + + if ($num_rows > 0) + { + while ($obj = $this->db->fetch_object($resql)) + { + $comments[] = $obj; + } + } + } + + return $comments; + } + + /** + * Adds a comment to the poll + * + * @param string $comment Comment content + * @param string $comment_user Comment author + * @return boolean False in case of the query fails, true if it was successful + */ + public function addComment($comment, $comment_user) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; + $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; + $resql = $this->db->query($sql); + + if (!$resql) { + return false; + } + + return true; + } + + /** + * Deletes a comment of the poll + * + * @param int $id_comment Id of the comment + * @return boolean False in case of the query fails, true if it was successful + */ + public function deleteComment($id_comment) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; + $resql = $this->db->query($sql); + + if (!$resql) { + return false; + } + + return true; + } + + /** + * Cleans all the class variables before doing an update or an insert + * + * @return void + */ + private function cleanParameters() + { + $this->id_sondage = trim($this->id_sondage); + $this->description = trim($this->description); + $this->mail_admin = trim($this->mail_admin); + $this->nom_admin = trim($this->nom_admin); + $this->title = trim($this->title); + $this->status = trim($this->status); + $this->format = trim($this->format); + $this->mailsonde = ($this->mailsonde ? 1 : 0); + $this->allow_comments = ($this->allow_comments ? 1 : 0); + $this->allow_spy = ($this->allow_spy ? 1 : 0); + $this->sujet = trim($this->sujet); + } + + + /** + * Return status label of Order + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of status + * + * @param int $status Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode) + { + // phpcs:enable + global $langs, $conf; + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Opened'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->trans('Closed'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Opened'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->trans('Closed'); + } + + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) { + if (0) $statusType = 'status1'; + else $statusType = 'status4'; + } + if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 697c51f09c4..1753cf7e8df 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2210,7 +2210,7 @@ class Product extends CommonObject } }*/ } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } @@ -2255,12 +2255,12 @@ class Product extends CommonObject } $this->prices_by_qty_list[0] = $resultat; } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity @@ -2314,12 +2314,12 @@ class Product extends CommonObject } $this->prices_by_qty_list[$i] = $resultat; } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } @@ -2346,7 +2346,7 @@ class Product extends CommonObject return 0; } } else { - $this->error=$this->db->lasterror; + $this->error = $this->db->lasterror; return -1; } } @@ -4769,7 +4769,7 @@ class Product extends CommonObject if ($result < 0) dol_print_error($this->db, $this->error); $stock_sending_client = $this->stats_expedition['qty']; } - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled)) + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { $filterStatus = '1,2,3,4'; if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 3949f8af6fe..357251fe512 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -447,11 +447,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Documents if ($includedocgeneration) { $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref . '/' . $objref . '.pdf'; + $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 001194495bb..790d30b444f 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -133,7 +133,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); } - if (! $error && ! empty($conf->productbatch->enabled)) { + if (!$error && !empty($conf->productbatch->enabled)) { $tmpproduct = new Product($db); $result = $tmpproduct->fetch($fk_product); @@ -320,53 +320,53 @@ if ($object->id > 0) print '
'; print ''; } else { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - { - if ($object->status == Inventory::STATUS_DRAFT) - { - if ($permissiontoadd) - { - print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'."\n"; - } else { - print ''.$langs->trans('Validate').' ('.$langs->trans("Start").')'."\n"; - } - } + if (empty($reshook)) + { + if ($object->status == Inventory::STATUS_DRAFT) + { + if ($permissiontoadd) + { + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'."\n"; + } else { + print ''.$langs->trans('Validate').' ('.$langs->trans("Start").')'."\n"; + } + } - if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - /* + if ($object->status == Inventory::STATUS_VALIDATED) + { + if ($permissiontoadd) + { + /* if ($conf->barcode->enabled) { print ''.$langs->trans("UpdateByScaningProductBarcode").''; } if ($conf->productbatch->enabled) { print ''.$langs->trans('UpdateByScaningLot').''; }*/ - if ($conf->barcode->enabled || $conf->productbatch->enabled) { - print ''.$langs->trans("UpdateByScaning").''; - } - } else { - print ''.$langs->trans('Save').''."\n"; - } - } + if ($conf->barcode->enabled || $conf->productbatch->enabled) { + print ''.$langs->trans("UpdateByScaning").''; + } + } else { + print ''.$langs->trans('Save').''."\n"; + } + } - if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - print ''.$langs->trans("Finish").''."\n"; - } else { - print ''.$langs->trans('Finish').''."\n"; - } - } + if ($object->status == Inventory::STATUS_VALIDATED) + { + if ($permissiontoadd) + { + print ''.$langs->trans("Finish").''."\n"; + } else { + print ''.$langs->trans('Finish').''."\n"; + } + } - /*if ($object->status == Inventory::STATUS_VALIDATED) + /*if ($object->status == Inventory::STATUS_VALIDATED) { if ($permissiontoadd) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d28bbef42c3..35a04f93613 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -219,7 +219,7 @@ $arrayfields = array( ); // MultiPrices -if ($conf->global->PRODUIT_MULTIPRICES){ +if ($conf->global->PRODUIT_MULTIPRICES) { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i; @@ -753,7 +753,7 @@ if ($resql) } // Multiprice - if ($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES) { foreach ($arraypricelevel as $key => $value) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) @@ -905,7 +905,7 @@ if ($resql) } // Multiprices - if ($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES) { foreach ($arraypricelevel as $key => $value) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) @@ -1265,7 +1265,7 @@ if ($resql) // Multiprices - if ($conf->global->PRODUIT_MULTIPRICES){ + if ($conf->global->PRODUIT_MULTIPRICES) { foreach ($arraypricelevel as $key => $value) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 25857803843..d63469308b3 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -736,7 +736,7 @@ class Entrepot extends CommonObject $result .= $linkstart; if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label)?$this->libelle:$this->label)); + if ($withpicto != 2) $result .= (($showfullpath || !empty($conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO)) ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label)); $result .= $linkend; global $action; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index fe6e8d3e829..cd83f2c19c8 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; if (!empty($conf->productbatch->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; } if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -88,7 +88,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref); } if (empty($id) && !empty($object->id)) $id = $object->id; @@ -100,9 +100,9 @@ $canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas"); $objcanvas = null; if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('stockproduct', 'card', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('stockproduct', 'card', $canvas); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -168,27 +168,27 @@ if ($action == 'delete_productstockwarehouse' && !empty($user->rights->produit-> // Set stock limit if ($action == 'setseuil_stock_alerte' && !empty($user->rights->produit->creer)) { - $object = new Product($db); - $result = $object->fetch($id); - $object->seuil_stock_alerte = $stocklimit; - $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - //else - // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); - $action = ''; + $object = new Product($db); + $result = $object->fetch($id); + $object->seuil_stock_alerte = $stocklimit; + $result = $object->update($object->id, $user, 0, 'update'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + //else + // setEventMessages($lans->trans("SavedRecordSuccessfully"), null, 'mesgs'); + $action = ''; } // Set desired stock if ($action == 'setdesiredstock' && !empty($user->rights->produit->creer)) { - $object = new Product($db); - $result = $object->fetch($id); - $object->desiredstock = $desiredstock; - $result = $object->update($object->id, $user, 0, 'update'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; + $object = new Product($db); + $result = $object->fetch($id); + $object->desiredstock = $desiredstock; + $result = $object->update($object->id, $user, 0, 'update'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; } @@ -258,12 +258,12 @@ if ($action == "correct_stock" && !$cancel) ); // We do not change value of stock for a correction } else { $result = $object->correct_stock( - $user, - GETPOST("id_entrepot", 'int'), + $user, + GETPOST("id_entrepot", 'int'), $nbpiece, - GETPOST("mouvement", 'int'), - GETPOST("label", 'alphanohtml'), - $priceunit, + GETPOST("mouvement", 'int'), + GETPOST("label", 'alphanohtml'), + $priceunit, GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id @@ -277,12 +277,12 @@ if ($action == "correct_stock" && !$cancel) header("Location: ".$backtopage); exit; } else { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'correction'; + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'correction'; } } } @@ -311,15 +311,15 @@ if ($action == "transfert_stock" && !$cancel) } if (!empty($conf->productbatch->enabled)) { - $object = new Product($db); - $result = $object->fetch($id); + $object = new Product($db); + $result = $object->fetch($id); - if ($object->hasbatch() && !$batchnumber) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); - $error++; - $action = 'transfert'; - } + if ($object->hasbatch() && !$batchnumber) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); + $error++; + $action = 'transfert'; + } } if (!$error) @@ -399,31 +399,31 @@ if ($action == "transfert_stock" && !$cancel) } else { if (!$error) { - // Remove stock - $result1 = $object->correct_stock( - $user, - GETPOST("id_entrepot", 'int'), - $nbpiece, - 1, - GETPOST("label", 'alphanohtml'), - $pricesrc, - GETPOST('inventorycode', 'alphanohtml') - ); - if ($result1 < 0) $error++; + // Remove stock + $result1 = $object->correct_stock( + $user, + GETPOST("id_entrepot", 'int'), + $nbpiece, + 1, + GETPOST("label", 'alphanohtml'), + $pricesrc, + GETPOST('inventorycode', 'alphanohtml') + ); + if ($result1 < 0) $error++; } if (!$error) { - // Add stock - $result2 = $object->correct_stock( - $user, - GETPOST("id_entrepot_destination", 'int'), - $nbpiece, - 0, - GETPOST("label", 'alphanohtml'), - $pricedest, - GETPOST('inventorycode', 'alphanohtml') - ); - if ($result2 < 0) $error++; + // Add stock + $result2 = $object->correct_stock( + $user, + GETPOST("id_entrepot_destination", 'int'), + $nbpiece, + 0, + GETPOST("label", 'alphanohtml'), + $pricedest, + GETPOST('inventorycode', 'alphanohtml') + ); + if ($result2 < 0) $error++; } } @@ -452,35 +452,35 @@ if ($action == "transfert_stock" && !$cancel) // Update batch information if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) { - $pdluo = new Productbatch($db); - $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); + $pdluo = new Productbatch($db); + $result = $pdluo->fetch(GETPOST('pdluoid', 'int')); - if ($result > 0) - { - if ($pdluo->id) - { - if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); - } else { - $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); - $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); - $pdluo->batch = $batchnumber; - $pdluo->eatby = $d_eatby; - $pdluo->sellby = $d_sellby; - $result = $pdluo->update($user); - if ($result < 0) - { - setEventMessages($pdluo->error, $pdluo->errors, 'errors'); - } - } - } else { - setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); - } - } else { - setEventMessages($pdluo->error, null, 'errors'); - } - header("Location: product.php?id=".$id); - exit; + if ($result > 0) + { + if ($pdluo->id) + { + if ((!GETPOST("sellby")) && (!GETPOST("eatby")) && (!$batchnumber)) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); + } else { + $d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $pdluo->batch = $batchnumber; + $pdluo->eatby = $d_eatby; + $pdluo->sellby = $d_sellby; + $result = $pdluo->update($user); + if ($result < 0) + { + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); + } + } + } else { + setEventMessages($langs->trans('BatchInformationNotfound'), null, 'errors'); + } + } else { + setEventMessages($pdluo->error, null, 'errors'); + } + header("Location: product.php?id=".$id); + exit; } @@ -528,17 +528,17 @@ if ($id > 0 || $ref) dol_htmloutput_events(); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $shownav = 1; - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; + $shownav = 1; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; - dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); + dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; if (!$variants) { if ($conf->productbatch->enabled) { @@ -629,7 +629,7 @@ if ($id > 0 || $ref) $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill").'
' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder").'
' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder").'
' : ''); - $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
' : ''); + $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? $langs->trans("StockOnReception").'
' : ''); print '
'; print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); @@ -656,13 +656,13 @@ if ($id > 0 || $ref) // Number of product from customer order already sent (partial shipping) if (!empty($conf->expedition->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $filterShipmentStatus = ''; - if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; - } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $filterShipmentStatus = Expedition::STATUS_CLOSED; - } + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $filterShipmentStatus = ''; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { + $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; + } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $filterShipmentStatus = Expedition::STATUS_CLOSED; + } if ($found) $helpondiff .= '
'; else $found = 1; $result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus); $helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; @@ -730,8 +730,8 @@ if ($id > 0 || $ref) } print "
"; - print '
'; - print '
'; + print '
'; + print '
'; dol_fiche_end(); } @@ -763,7 +763,7 @@ if (empty($reshook)) { if (empty($action) && $object->id) { - print "
\n"; + print "
\n"; if ($user->rights->stock->mouvement->creer) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index a9175780491..539617f55aa 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -492,7 +492,7 @@ class Project extends CommonObject $sql .= " WHERE entity IN (".getEntity('project').")"; if (!empty($ref)) { $sql .= " AND ref = '".$this->db->escape($ref)."'"; - } elseif (! empty($ref_ext)) { + } elseif (!empty($ref_ext)) { $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; } else { $sql .= " AND email_msgid = '".$this->db->escape($email_msgid)."'"; diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 5b7a268d6fb..4087ae25bd7 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -321,14 +321,14 @@ $NBMAX = 3; $max = 3; // Last modified job position -if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) +if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status"; - $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.fk_soc = $socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.fk_soc = $socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); @@ -379,15 +379,15 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm } // Last modified job position -if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) +if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; - $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND s.fk_soc = $socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.fk_soc = $socid"; $sql .= " ORDER BY rc.tms DESC"; $sql .= $db->plimit($max, 0); @@ -409,9 +409,9 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitm while ($i < $num) { $objp = $db->fetch_object($resql); - $staticrecruitmentcandidature->id=$objp->rowid; - $staticrecruitmentcandidature->ref=$objp->ref; - $staticrecruitmentcandidature->email=$objp->email; + $staticrecruitmentcandidature->id = $objp->rowid; + $staticrecruitmentcandidature->ref = $objp->ref; + $staticrecruitmentcandidature->email = $objp->email; $staticrecruitmentcandidature->status = $objp->status; $staticrecruitmentcandidature->date_creation = $objp->date_creation; $staticrecruitmentcandidature->firstname = $objp->firstname; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 539a39b4140..6d412ae6f0a 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -36,11 +36,11 @@ class Stripe extends CommonObject /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_key; /** @@ -62,9 +62,9 @@ class Stripe extends CommonObject public $code; public $declinecode; - /** - * @var string Message - */ + /** + * @var string Message + */ public $message; /** @@ -102,21 +102,21 @@ class Stripe extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); - $tokenstring = $obj->tokenstring; + $tokenstring = $obj->tokenstring; - $tmparray = dol_json_decode($tokenstring); - $key = $tmparray->stripe_user_id; - } else { - $tokenstring = ''; - } - } else { - dol_print_error($this->db); - } + $tmparray = dol_json_decode($tokenstring); + $key = $tmparray->stripe_user_id; + } else { + $tokenstring = ''; + } + } else { + dol_print_error($this->db); + } - dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity); + dol_syslog("No dedicated Stripe Connect account available for entity ".$conf->entity); return $key; } @@ -194,7 +194,7 @@ class Stripe extends CommonObject } } elseif ($createifnotlinkedtostripe) { - $ipaddress = getUserRemoteIP(); + $ipaddress = getUserRemoteIP(); $dataforcustomer = array( "email" => $object->email, @@ -291,9 +291,9 @@ class Stripe extends CommonObject return $stripepaymentmethod; } - /** + /** * Get the Stripe payment intent. Create it with confirmnow=false - * Warning. If a payment was tried and failed, a payment intent was created. + * Warning. If a payment was tried and failed, a payment intent was created. * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed by Stripe. * Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), * that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) @@ -333,9 +333,9 @@ class Stripe extends CommonObject $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; + $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; + $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } if (!in_array($currency_code, $arrayzerounitcurrency)) { $stripefee = round($fee * 100); @@ -345,7 +345,7 @@ class Stripe extends CommonObject $paymentintent = null; - if (is_object($object) && ! empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) + if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) { // Warning. If a payment was tried and failed, a payment intent was created. // But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe. @@ -354,167 +354,167 @@ class Stripe extends CommonObject // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; - $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; - $sql.= " WHERE pi.fk_facture = " . $object->id; - $sql.= " AND pi.sourcetype = '" . $object->element . "'"; - $sql.= " AND pi.entity IN (".getEntity('societe').")"; - $sql.= " AND pi.ext_payment_site = '" . $service . "'"; + $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; + $sql.= " WHERE pi.fk_facture = " . $object->id; + $sql.= " AND pi.sourcetype = '" . $object->element . "'"; + $sql.= " AND pi.entity IN (".getEntity('societe').")"; + $sql.= " AND pi.ext_payment_site = '" . $service . "'"; - dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) - { - $obj = $this->db->fetch_object($resql); - $intent = $obj->ext_payment_id; + dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) + { + $obj = $this->db->fetch_object($resql); + $intent = $obj->ext_payment_id; - dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record"); + dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record"); - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); - try { - if (empty($key)) { // If the Stripe connect account not set, we use common API usage - $paymentintent = \Stripe\PaymentIntent::retrieve($intent); - } else { - $paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key)); - } - } - catch (Exception $e) { - $error++; - $this->error = $e->getMessage(); - } - } - } + try { + if (empty($key)) { // If the Stripe connect account not set, we use common API usage + $paymentintent = \Stripe\PaymentIntent::retrieve($intent); + } else { + $paymentintent = \Stripe\PaymentIntent::retrieve($intent, array("stripe_account" => $key)); + } + } + catch (Exception $e) { + $error++; + $this->error = $e->getMessage(); + } + } + } } if (empty($paymentintent)) { - $ipaddress = getUserRemoteIP(); - $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); - if (is_object($object)) - { - $metadata['dol_type'] = $object->element; - $metadata['dol_id'] = $object->id; + $ipaddress = getUserRemoteIP(); + $metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress); + if (is_object($object)) + { + $metadata['dol_type'] = $object->element; + $metadata['dol_id'] = $object->id; if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; - } + } - // list of payment method types - $paymentmethodtypes = array("card"); - if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) - if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) + // list of payment method types + $paymentmethodtypes = array("card"); + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) - $dataforintent = array( - "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent - "confirmation_method" => $mode, - "amount" => $stripeamount, - "currency" => $currency_code, - "payment_method_types" => $paymentmethodtypes, - "description" => $description, - "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - //"save_payment_method" => true, + $dataforintent = array( + "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent + "confirmation_method" => $mode, + "amount" => $stripeamount, + "currency" => $currency_code, + "payment_method_types" => $paymentmethodtypes, + "description" => $description, + "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + //"save_payment_method" => true, "setup_future_usage" => "on_session", - "metadata" => $metadata - ); - if (!is_null($customer)) $dataforintent["customer"] = $customer; - // payment_method = - // payment_method_types = array('card') - //var_dump($dataforintent); - if ($off_session) - { - unset($dataforintent['setup_future_usage']); - $dataforintent["off_session"] = true; - } - if (!is_null($payment_method)) - { - $dataforintent["payment_method"] = $payment_method; - $description .= ' - '.$payment_method; - } + "metadata" => $metadata + ); + if (!is_null($customer)) $dataforintent["customer"] = $customer; + // payment_method = + // payment_method_types = array('card') + //var_dump($dataforintent); + if ($off_session) + { + unset($dataforintent['setup_future_usage']); + $dataforintent["off_session"] = true; + } + if (!is_null($payment_method)) + { + $dataforintent["payment_method"] = $payment_method; + $description .= ' - '.$payment_method; + } - if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) - { - $dataforintent["application_fee_amount"] = $stripefee; - } - if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) - { - $dataforintent["receipt_email"] = $object->thirdparty->email; - } + if ($conf->entity != $conf->global->STRIPECONNECT_PRINCIPAL && $stripefee > 0) + { + $dataforintent["application_fee_amount"] = $stripefee; + } + if ($usethirdpartyemailforreceiptemail && is_object($object) && $object->thirdparty->email) + { + $dataforintent["receipt_email"] = $object->thirdparty->email; + } - try { - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + try { + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); - $arrayofoptions = array(); - if (empty($noidempotency_key)) { - $arrayofoptions["idempotency_key"] = $description; - } - // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. - if (!empty($key)) { // If the Stripe connect account not set, we use common API usage - $arrayofoptions["stripe_account"] = $key; - } - $paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions); + $arrayofoptions = array(); + if (empty($noidempotency_key)) { + $arrayofoptions["idempotency_key"] = $description; + } + // Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent. + if (!empty($key)) { // If the Stripe connect account not set, we use common API usage + $arrayofoptions["stripe_account"] = $key; + } + $paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions); - // Store the payment intent - if (is_object($object)) - { - $paymentintentalreadyexists = 0; - // Check that payment intent $paymentintent->id is not already recorded. - $sql = "SELECT pi.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; - $sql .= " WHERE pi.entity IN (".getEntity('societe').")"; - $sql .= " AND pi.ext_payment_site = '".$service."'"; - $sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'"; + // Store the payment intent + if (is_object($object)) + { + $paymentintentalreadyexists = 0; + // Check that payment intent $paymentintent->id is not already recorded. + $sql = "SELECT pi.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; + $sql .= " WHERE pi.entity IN (".getEntity('societe').")"; + $sql .= " AND pi.ext_payment_site = '".$service."'"; + $sql .= " AND pi.ext_payment_id = '".$this->db->escape($paymentintent->id)."'"; - dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) - { - $obj = $this->db->fetch_object($resql); - if ($obj) $paymentintentalreadyexists++; - } - } else dol_print_error($this->db); + dol_syslog(get_class($this)."::getPaymentIntent search if payment intent already in prelevement_facture_demande", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) + { + $obj = $this->db->fetch_object($resql); + if ($obj) $paymentintentalreadyexists++; + } + } else dol_print_error($this->db); - // If not, we create it. - if (!$paymentintentalreadyexists) - { - $now = dol_now(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; - $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$service."', ".$amount.")"; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database."); - } - } - } else { - $_SESSION["stripe_payment_intent"] = $paymentintent; - } - } catch (Stripe\Error\Card $e) - { - $error++; - $this->error = $e->getMessage(); - $this->code = $e->getStripeCode(); - $this->declinecode = $e->getDeclineCode(); - } catch (Exception $e) - { - /*var_dump($dataforintent); + // If not, we create it. + if (!$paymentintentalreadyexists) + { + $now = dol_now(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture_demande (date_demande, fk_user_demande, ext_payment_id, fk_facture, sourcetype, entity, ext_payment_site, amount)"; + $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", '".$this->db->escape($paymentintent->id)."', ".$object->id.", '".$this->db->escape($object->element)."', ".$conf->entity.", '".$service."', ".$amount.")"; + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database."); + } + } + } else { + $_SESSION["stripe_payment_intent"] = $paymentintent; + } + } catch (Stripe\Error\Card $e) + { + $error++; + $this->error = $e->getMessage(); + $this->code = $e->getStripeCode(); + $this->declinecode = $e->getDeclineCode(); + } catch (Exception $e) + { + /*var_dump($dataforintent); var_dump($description); var_dump($key); var_dump($paymentintent); var_dump($e->getMessage()); var_dump($e);*/ - $error++; - $this->error = $e->getMessage(); - $this->code = ''; - $this->declinecode = ''; - } + $error++; + $this->error = $e->getMessage(); + $this->code = ''; + $this->declinecode = ''; + } } dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); @@ -572,7 +572,7 @@ class Stripe extends CommonObject // list of payment method types $paymentmethodtypes = array("card"); - if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) // iDEAL not supported with setupIntent $dataforintent = array( @@ -933,10 +933,10 @@ class Stripe extends CommonObject } } elseif (preg_match('/acct_/i', $source)) { - $charge = \Stripe\Charge::create(array( + $charge = \Stripe\Charge::create(array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -946,7 +946,7 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) + "statement_descriptor_suffix" => dol_trunc($description, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) "description" => "Stripe payment: ".$description, "capture" => $capture, "metadata" => $metadata, @@ -965,9 +965,9 @@ class Stripe extends CommonObject // With Stripe Connect $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; + $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; + $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } if (!in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 344bea2d6be..d2f1ef2011e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -776,1897 +776,1897 @@ class SupplierProposal extends CommonObject $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - $result = $this->line->update(); - if ($result > 0) - { - // Reorder if child line - if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); + $result = $this->line->update(); + if ($result > 0) + { + // Reorder if child line + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); - $this->update_price(1); + $this->update_price(1); - $this->fk_supplier_proposal = $this->id; + $this->fk_supplier_proposal = $this->id; - $this->db->commit(); - return $result; - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } else { - dol_syslog(get_class($this)."::updateline Erreur -2 SupplierProposal en mode incompatible pour cette action"); - return -2; - } - } + $this->db->commit(); + return $result; + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } else { + dol_syslog(get_class($this)."::updateline Erreur -2 SupplierProposal en mode incompatible pour cette action"); + return -2; + } + } - /** - * Delete detail line - * - * @param int $lineid Id of line to delete - * @return int >0 if OK, <0 if KO - */ - public function deleteline($lineid) - { - if ($this->statut == 0) - { - $line = new SupplierProposalLine($this->db); + /** + * Delete detail line + * + * @param int $lineid Id of line to delete + * @return int >0 if OK, <0 if KO + */ + public function deleteline($lineid) + { + if ($this->statut == 0) + { + $line = new SupplierProposalLine($this->db); - // For triggers - $line->fetch($lineid); + // For triggers + $line->fetch($lineid); - if ($line->delete() > 0) - { - $this->update_price(1); + if ($line->delete() > 0) + { + $this->update_price(1); - return 1; - } else { - return -1; - } - } else { - return -2; - } - } + return 1; + } else { + return -1; + } + } else { + return -2; + } + } - /** - * Create commercial proposal into database - * this->ref can be set or empty. If empty, we will use "(PROVid)" - * - * @param User $user User that create - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >=0 if OK - */ - public function create($user, $notrigger = 0) - { - global $langs, $conf, $mysoc, $hookmanager; - $error = 0; + /** + * Create commercial proposal into database + * this->ref can be set or empty. If empty, we will use "(PROVid)" + * + * @param User $user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >=0 if OK + */ + public function create($user, $notrigger = 0) + { + global $langs, $conf, $mysoc, $hookmanager; + $error = 0; - $now = dol_now(); + $now = dol_now(); - dol_syslog(get_class($this)."::create"); + dol_syslog(get_class($this)."::create"); - // Check parameters - $result = $this->fetch_thirdparty(); - if ($result < 0) - { - $this->error = "Failed to fetch company"; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -3; - } + // Check parameters + $result = $this->fetch_thirdparty(); + if ($result < 0) + { + $this->error = "Failed to fetch company"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -3; + } - // Check parameters - if (!empty($this->ref)) // We check that ref is not already used - { - $result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used - if ($result > 0) - { - $this->error = 'ErrorRefAlreadyExists'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); - $this->db->rollback(); - return -1; - } - } + // Check parameters + if (!empty($this->ref)) // We check that ref is not already used + { + $result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + if ($result > 0) + { + $this->error = 'ErrorRefAlreadyExists'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); + $this->db->rollback(); + return -1; + } + } - // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $now); - if (empty($this->fk_multicurrency)) - { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $now); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } - $this->db->begin(); + $this->db->begin(); - // Insert into database - $sql = "INSERT INTO ".MAIN_DB_PREFIX."supplier_proposal ("; - $sql .= "fk_soc"; - $sql .= ", price"; - $sql .= ", remise"; - $sql .= ", remise_percent"; - $sql .= ", remise_absolue"; - $sql .= ", tva"; - $sql .= ", total"; - $sql .= ", datec"; - $sql .= ", ref"; - $sql .= ", fk_user_author"; - $sql .= ", note_private"; - $sql .= ", note_public"; - $sql .= ", model_pdf"; - $sql .= ", fk_cond_reglement"; - $sql .= ", fk_mode_reglement"; - $sql .= ", fk_account"; - $sql .= ", date_livraison"; - $sql .= ", fk_shipping_method"; - $sql .= ", fk_projet"; - $sql .= ", entity"; - $sql .= ", fk_multicurrency"; - $sql .= ", multicurrency_code"; - $sql .= ", multicurrency_tx"; - $sql .= ") "; - $sql .= " VALUES ("; - $sql .= $this->socid; - $sql .= ", 0"; - $sql .= ", ".$this->remise; - $sql .= ", ".($this->remise_percent ? $this->db->escape($this->remise_percent) : 'null'); - $sql .= ", ".($this->remise_absolue ? $this->db->escape($this->remise_absolue) : 'null'); - $sql .= ", 0"; - $sql .= ", 0"; - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ", '(PROV)'"; - $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); - $sql .= ", '".$this->db->escape($this->note_private)."'"; - $sql .= ", '".$this->db->escape($this->note_public)."'"; - $sql .= ", '".$this->db->escape($this->modelpdf)."'"; - $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); - $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); - $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); - $sql .= ", ".($this->date_livraison != '' ? "'".$this->db->idate($this->date_livraison)."'" : "null"); - $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); - $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); - $sql .= ", ".$conf->entity; - $sql .= ", ".(int) $this->fk_multicurrency; - $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", ".(double) $this->multicurrency_tx; - $sql .= ")"; + // Insert into database + $sql = "INSERT INTO ".MAIN_DB_PREFIX."supplier_proposal ("; + $sql .= "fk_soc"; + $sql .= ", price"; + $sql .= ", remise"; + $sql .= ", remise_percent"; + $sql .= ", remise_absolue"; + $sql .= ", tva"; + $sql .= ", total"; + $sql .= ", datec"; + $sql .= ", ref"; + $sql .= ", fk_user_author"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_cond_reglement"; + $sql .= ", fk_mode_reglement"; + $sql .= ", fk_account"; + $sql .= ", date_livraison"; + $sql .= ", fk_shipping_method"; + $sql .= ", fk_projet"; + $sql .= ", entity"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ") "; + $sql .= " VALUES ("; + $sql .= $this->socid; + $sql .= ", 0"; + $sql .= ", ".$this->remise; + $sql .= ", ".($this->remise_percent ? $this->db->escape($this->remise_percent) : 'null'); + $sql .= ", ".($this->remise_absolue ? $this->db->escape($this->remise_absolue) : 'null'); + $sql .= ", 0"; + $sql .= ", 0"; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", '(PROV)'"; + $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); + $sql .= ", '".$this->db->escape($this->note_private)."'"; + $sql .= ", '".$this->db->escape($this->note_public)."'"; + $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->date_livraison != '' ? "'".$this->db->idate($this->date_livraison)."'" : "null"); + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); + $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); + $sql .= ", ".$conf->entity; + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."supplier_proposal"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."supplier_proposal"); - if ($this->id) - { - $this->ref = '(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."supplier_proposal SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; + if ($this->id) + { + $this->ref = '(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."supplier_proposal SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) $error++; + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) $error++; - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects - { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds - } + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + { + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + } - // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - dol_print_error($this->db); - $error++; - } - } - } - } - } + // Add object linked + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + dol_print_error($this->db); + $error++; + } + } + } + } + } - /* + /* * Insertion du detail des produits dans la base */ - if (!$error) - { - $fk_parent_line = 0; - $num = count($this->lines); + if (!$error) + { + $fk_parent_line = 0; + $num = count($this->lines); - for ($i = 0; $i < $num; $i++) - { - // Reset fk_parent_line for no child products and special product - if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } + for ($i = 0; $i < $num; $i++) + { + // Reset fk_parent_line for no child products and special product + if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } - $result = $this->addline( - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line, - $this->lines[$i]->fk_fournprice, - $this->lines[$i]->pa_ht, - $this->lines[$i]->label, - $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn, - $this->lines[$i]->fk_unit, - 'supplier_proposal', - $this->lines[$i]->rowid - ); + $result = $this->addline( + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->array_options, + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid + ); - if ($result < 0) - { - $error++; - $this->error = $this->db->error; - dol_print_error($this->db); - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $this->lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } + if ($result < 0) + { + $error++; + $this->error = $this->db->error; + dol_print_error($this->db); + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $this->lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } - if (!$error) - { - // Mise a jour infos denormalisees - $resql = $this->update_price(1); - if ($resql) - { - $action = 'update'; + if (!$error) + { + // Mise a jour infos denormalisees + $resql = $this->update_price(1); + if ($resql) + { + $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('PROPOSAL_SUPPLIER_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } - } else { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else { - $this->error = $this->db->lasterror(); - $error++; - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('PROPOSAL_SUPPLIER_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } + } else { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else { + $this->error = $this->db->lasterror(); + $error++; + } - if (!$error) - { - $this->db->commit(); - dol_syslog(get_class($this)."::create done id=".$this->id); - return $this->id; - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + dol_syslog(get_class($this)."::create done id=".$this->id); + return $this->id; + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - $this->products = $this->lines; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). + * + * @param User $user User that create + * @return int Id of the new object if ok, <0 if ko + * @see create() + */ + public function create_from($user) + { + // phpcs:enable + $this->products = $this->lines; - return $this->create($user); - } + return $this->create($user); + } - /** - * Load an object from its id and create a new one in database - * + /** + * Load an object from its id and create a new one in database + * * @param User $user User making the clone - * @param int $fromid Id of thirdparty - * @return int New id of clone - */ - public function createFromClone(User $user, $fromid = 0) - { - global $conf, $hookmanager; - - $error = 0; - $now = dol_now(); - - $this->db->begin(); - - // get extrafields so they will be clone - foreach ($this->lines as $line) - $line->fetch_optionals(); - - // Load source object - $objFrom = clone $this; - - $objsoc = new Societe($this->db); - - // Change socid if needed - if (!empty($fromid) && $fromid != $this->socid) - { - if ($objsoc->fetch($fromid) > 0) - { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; - } - - // TODO Change product price if multi-prices - } else { - $objsoc->fetch($this->socid); - } - - $this->id = 0; - $this->statut = 0; - - if (empty($conf->global->SUPPLIER_PROPOSAL_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.".php")) - { - $this->error = 'ErrorSetupNotComplete'; - return -1; - } - - // Clear fields - $this->user_author = $user->id; - $this->user_valid = ''; - $this->date = $now; - - // Set ref - require_once DOL_DOCUMENT_ROOT."/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.'.php'; - $obj = $conf->global->SUPPLIER_PROPOSAL_ADDON; - $modSupplierProposal = new $obj; - $this->ref = $modSupplierProposal->getNextValue($objsoc, $this); - - // Create clone - $this->context['createfromclone'] = 'createfromclone'; - $result = $this->create($user); - if ($result < 0) $error++; - - if (!$error) - { - // Hook of thirdparty module - if (is_object($hookmanager)) - { - $parameters = array('objFrom'=>$objFrom); - $action = ''; - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; - } - } - - unset($this->context['createfromclone']); - - // End - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - return -1; - } - } - - /** - * Load a proposal from database and its ligne array - * - * @param int $rowid id of object to load - * @param string $ref Ref of proposal - * @return int >0 if OK, <0 if KO - */ - public function fetch($rowid, $ref = '') - { - global $conf; - - $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; - $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; - $sql .= ", p.datec"; - $sql .= ", p.date_valid as datev"; - $sql .= ", p.date_livraison as date_livraison"; - $sql .= ", p.model_pdf, p.extraparams"; - $sql .= ", p.note_private, p.note_public"; - $sql .= ", p.fk_projet as fk_project, p.fk_statut"; - $sql .= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; - $sql .= ", p.fk_cond_reglement"; - $sql .= ", p.fk_mode_reglement"; - $sql .= ', p.fk_account'; - $sql .= ", p.fk_shipping_method"; - $sql .= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; - $sql .= ", c.label as statut_label"; - $sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; - $sql .= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; - $sql .= " WHERE p.fk_statut = c.id"; - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if ($ref) $sql .= " AND p.ref='".$ref."'"; - else $sql .= " AND p.rowid=".$rowid; - - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->entity = $obj->entity; - - $this->ref = $obj->ref; - $this->remise = $obj->remise; - $this->remise_percent = $obj->remise_percent; - $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO deprecated - $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; - $this->total_localtax1 = $obj->localtax1; - $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total; - $this->socid = $obj->fk_soc; - $this->fk_project = $obj->fk_project; - $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; - $this->note = $obj->note_private; // TODO deprecated - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->statut = (int) $obj->fk_statut; - $this->statut_libelle = $obj->statut_label; - $this->datec = $this->db->jdate($obj->datec); // TODO deprecated - $this->datev = $this->db->jdate($obj->datev); // TODO deprecated - $this->date_creation = $this->db->jdate($obj->datec); //Creation date - $this->date_validation = $this->db->jdate($obj->datev); //Validation date - $this->date_livraison = $this->db->jdate($obj->date_livraison); - $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; - - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement; - $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - - $this->extraparams = (array) json_decode($obj->extraparams, true); - - $this->user_author_id = $obj->fk_user_author; - $this->user_valid_id = $obj->fk_user_valid; - $this->user_close_id = $obj->fk_user_cloture; - - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - - if ($obj->fk_statut == 0) - { - $this->brouillon = 1; - } - - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - $this->db->free($resql); - - $this->lines = array(); - - // Lines of supplier proposals - $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; - $sql .= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; - $sql .= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; - $sql .= ' d.ref_fourn as ref_produit_fourn,'; - $sql .= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql .= " WHERE d.fk_supplier_proposal = ".$this->id; - $sql .= " ORDER by d.rang"; - - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($result); - - $line = new SupplierProposalLine($this->db); - - $line->rowid = $objp->rowid; // deprecated - $line->id = $objp->rowid; - $line->fk_supplier_proposal = $objp->fk_supplier_proposal; - $line->fk_parent_line = $objp->fk_parent_line; - $line->product_type = $objp->product_type; - $line->label = $objp->custom_label; - $line->desc = $objp->description; // Description ligne - $line->qty = $objp->qty; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->subprice = $objp->subprice; - $line->fk_remise_except = $objp->fk_remise_except; - $line->remise_percent = $objp->remise_percent; - - $line->info_bits = $objp->info_bits; - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1 = $objp->total_localtax1; - $line->total_localtax2 = $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; - $line->special_code = $objp->special_code; - $line->rang = $objp->rang; - - $line->fk_product = $objp->fk_product; - - $line->ref = $objp->product_ref; // deprecated - $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // deprecated - $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; // Description produit - $line->fk_product_type = $objp->fk_product_type; - - $line->ref_fourn = $objp->ref_produit_fourn; - - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fk_unit = $objp->fk_unit; - - $this->lines[$i] = $line; - - $i++; - } - $this->db->free($result); - } else { - $this->error = $this->db->error(); - return -1; - } - - // Retreive all extrafield - // fetch optionals attributes and labels - $this->fetch_optionals(); - - return 1; - } - - $this->error = "Record Not Found"; - return 0; - } else { - $this->error = $this->db->error(); - return -1; - } - } - - /** - * Set status to validated - * - * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >=0 if OK - */ - public function valid($user, $notrigger = 0) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - global $conf, $langs; - - $error = 0; - $now = dol_now(); - - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance))) - { - $this->db->begin(); - - // Numbering module definition - $soc = new Societe($this->db); - $soc->fetch($this->socid); - - // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life - { - $num = $this->getNextNumRef($soc); - } else { - $num = $this->ref; - } - $this->newref = dol_sanitizeFileName($num); - - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; - $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - dol_syslog(get_class($this)."::valid", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - dol_print_error($this->db); - $error++; - } - - // Trigger calls - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('PROPOSAL_SUPPLIER_VALIDATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } - - if (!$error) - { - $this->oldref = $this->ref; - - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'supplier_proposal/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'supplier_proposal/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->error = $this->db->lasterror(); } - - // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; - $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; - if (!$error && file_exists($dirsource)) - { - dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } - - $this->ref = $num; - $this->brouillon = 0; - $this->statut = 1; - $this->user_valid_id = $user->id; - $this->datev = $now; - - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); - return -2; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set delivery date - * - * @param User $user Object user that modify - * @param int $date_livraison Delivery date - * @return int <0 if ko, >0 if ok - */ - public function set_date_livraison($user, $date_livraison) - { - // phpcs:enable - if (!empty($user->rights->supplier_proposal->creer)) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; - $sql .= " SET date_livraison = ".($date_livraison != '' ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql .= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql)) - { - $this->date_livraison = $date_livraison; - return 1; - } else { - $this->error = $this->db->error(); - dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); - return -1; - } - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set an overall discount on the proposal - * - * @param User $user Object user that modify - * @param double $remise Amount discount - * @return int <0 if ko, >0 if ok - */ - public function set_remise_percent($user, $remise) - { - // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; - - if (!empty($user->rights->supplier_proposal->creer)) - { - $remise = price2num($remise); - - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".$remise; - $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql)) - { - $this->remise_percent = $remise; - $this->update_price(1); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set an absolute overall discount on the proposal - * - * @param User $user Object user that modify - * @param double $remise Amount discount - * @return int <0 if ko, >0 if ok - */ - public function set_remise_absolue($user, $remise) - { - // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; - - if (!empty($user->rights->supplier_proposal->creer)) - { - $remise = price2num($remise); - - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; - $sql .= " SET remise_absolue = ".$remise; - $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql)) - { - $this->remise_absolue = $remise; - $this->update_price(1); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } - } - - - - /** - * Reopen the commercial proposal - * - * @param User $user Object user that close - * @param int $statut Statut - * @param string $note Comment - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK - */ - public function reopen($user, $statut, $note = '', $notrigger = 0) - { - global $langs, $conf; - - $this->statut = $statut; - $error = 0; - - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$this->statut.","; - if (!empty($note)) $sql .= " note_private = '".$this->db->escape($note)."',"; - $sql .= " date_cloture=NULL, fk_user_cloture=NULL"; - $sql .= " WHERE rowid = ".$this->id; - - $this->db->begin(); - - dol_syslog(get_class($this)."::reopen", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); - } - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('PROPOSAL_SUPPLIER_REOPEN', $user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - // Commit or rollback - if ($error) - { - if (!empty($this->errors)) - { - foreach ($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } - - - /** - * Close the askprice - * - * @param User $user Object user that close - * @param int $status Status - * @param string $note Comment - * @return int <0 if KO, >0 if OK - */ - public function cloture($user, $status, $note) - { - global $langs, $conf; - - $this->statut = $status; - $error = 0; - $now = dol_now(); - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; - $sql .= " WHERE rowid = ".$this->id; - - $resql = $this->db->query($sql); - if ($resql) - { - $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED : $this->modelpdf; - $triggerName = 'PROPOSAL_SUPPLIER_CLOSE_REFUSED'; - - if ($status == 2) - { - $triggerName = 'PROPOSAL_SUPPLIER_CLOSE_SIGNED'; - $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL : $this->modelpdf; - - if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists - { - $result = $this->updateOrCreatePriceFournisseur($user); - } - } - if ($status == 4) - { - $triggerName = 'PROPOSAL_SUPPLIER_CLASSIFY_BILLED'; - } - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (!empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - // Call trigger - $result = $this->call_trigger($triggerName, $user); - if ($result < 0) { $error++; } - // End call triggers - - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } - - /** - * Add or update supplier price according to result of proposal - * - * @param User $user Object user - * @return int > 0 if OK - */ - public function updateOrCreatePriceFournisseur($user) - { - global $conf; - - dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) - { - if ($product->subprice <= 0) continue; - $productsupplier = new ProductFournisseur($this->db); - - $multicurrency_tx = 1; - $fk_multicurrency = 0; - - if (empty($this->thirdparty)) $this->fetch_thirdparty(); - - $ref_fourn = $product->ref_fourn; - if (empty($ref_fourn)) $ref_fourn = $product->ref_supplier; - if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code); - $productsupplier->id = $product->fk_product; - - $productsupplier->update_buyprice($product->qty, $product->total_ht, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_total_ht, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', ''); - } - - return 1; - } - - /** - * Upate ProductFournisseur - * - * @param int $idProductFournPrice id of llx_product_fournisseur_price - * @param Product $product contain informations to update - * @param User $user Object user - * @return int <0 if KO, >0 if OK - */ - public function updatePriceFournisseur($idProductFournPrice, $product, $user) - { - $price = price2num($product->subprice * $product->qty, 'MU'); - $unitPrice = price2num($product->subprice, 'MU'); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; - - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } - - /** - * Create ProductFournisseur - * - * @param Product $product Object Product - * @param User $user Object user - * @return int <0 if KO, >0 if OK - */ - public function createPriceFournisseur($product, $user) - { - global $conf; - - $price = price2num($product->subprice * $product->qty, 'MU'); - $qty = price2num($product->qty); - $unitPrice = price2num($product->subprice, 'MU'); - - $now = dol_now(); - - $values = array( - "'".$this->db->idate($now)."'", - $product->fk_product, - $this->thirdparty->id, - "'".$product->ref_fourn."'", - $price, - $qty, - $unitPrice, - $product->tva_tx, - $user->id - ); - if (!empty($conf->multicurrency->enabled)) { - if (!empty($product->multicurrency_code)) { + * @param int $fromid Id of thirdparty + * @return int New id of clone + */ + public function createFromClone(User $user, $fromid = 0) + { + global $conf, $hookmanager; + + $error = 0; + $now = dol_now(); + + $this->db->begin(); + + // get extrafields so they will be clone + foreach ($this->lines as $line) + $line->fetch_optionals(); + + // Load source object + $objFrom = clone $this; + + $objsoc = new Societe($this->db); + + // Change socid if needed + if (!empty($fromid) && $fromid != $this->socid) + { + if ($objsoc->fetch($fromid) > 0) + { + $this->socid = $objsoc->id; + $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = ''; + } + + // TODO Change product price if multi-prices + } else { + $objsoc->fetch($this->socid); + } + + $this->id = 0; + $this->statut = 0; + + if (empty($conf->global->SUPPLIER_PROPOSAL_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.".php")) + { + $this->error = 'ErrorSetupNotComplete'; + return -1; + } + + // Clear fields + $this->user_author = $user->id; + $this->user_valid = ''; + $this->date = $now; + + // Set ref + require_once DOL_DOCUMENT_ROOT."/core/modules/supplier_proposal/".$conf->global->SUPPLIER_PROPOSAL_ADDON.'.php'; + $obj = $conf->global->SUPPLIER_PROPOSAL_ADDON; + $modSupplierProposal = new $obj; + $this->ref = $modSupplierProposal->getNextValue($objsoc, $this); + + // Create clone + $this->context['createfromclone'] = 'createfromclone'; + $result = $this->create($user); + if ($result < 0) $error++; + + if (!$error) + { + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } + } + + unset($this->context['createfromclone']); + + // End + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load a proposal from database and its ligne array + * + * @param int $rowid id of object to load + * @param string $ref Ref of proposal + * @return int >0 if OK, <0 if KO + */ + public function fetch($rowid, $ref = '') + { + global $conf; + + $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql .= ", p.datec"; + $sql .= ", p.date_valid as datev"; + $sql .= ", p.date_livraison as date_livraison"; + $sql .= ", p.model_pdf, p.extraparams"; + $sql .= ", p.note_private, p.note_public"; + $sql .= ", p.fk_projet as fk_project, p.fk_statut"; + $sql .= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; + $sql .= ", p.fk_cond_reglement"; + $sql .= ", p.fk_mode_reglement"; + $sql .= ', p.fk_account'; + $sql .= ", p.fk_shipping_method"; + $sql .= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; + $sql .= ", c.label as statut_label"; + $sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; + $sql .= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql .= " WHERE p.fk_statut = c.id"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + if ($ref) $sql .= " AND p.ref='".$ref."'"; + else $sql .= " AND p.rowid=".$rowid; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->entity = $obj->entity; + + $this->ref = $obj->ref; + $this->remise = $obj->remise; + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->total = $obj->total; // TODO deprecated + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; + $this->total_ttc = $obj->total; + $this->socid = $obj->fk_soc; + $this->fk_project = $obj->fk_project; + $this->model_pdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; + $this->note = $obj->note_private; // TODO deprecated + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->statut = (int) $obj->fk_statut; + $this->statut_libelle = $obj->statut_label; + $this->datec = $this->db->jdate($obj->datec); // TODO deprecated + $this->datev = $this->db->jdate($obj->datev); // TODO deprecated + $this->date_creation = $this->db->jdate($obj->datec); //Creation date + $this->date_validation = $this->db->jdate($obj->datev); //Validation date + $this->date_livraison = $this->db->jdate($obj->date_livraison); + $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement; + $this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + + $this->extraparams = (array) json_decode($obj->extraparams, true); + + $this->user_author_id = $obj->fk_user_author; + $this->user_valid_id = $obj->fk_user_valid; + $this->user_close_id = $obj->fk_user_cloture; + + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + + if ($obj->fk_statut == 0) + { + $this->brouillon = 1; + } + + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + $this->db->free($resql); + + $this->lines = array(); + + // Lines of supplier proposals + $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql .= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; + $sql .= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; + $sql .= ' d.ref_fourn as ref_produit_fourn,'; + $sql .= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql .= " WHERE d.fk_supplier_proposal = ".$this->id; + $sql .= " ORDER by d.rang"; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + while ($i < $num) + { + $objp = $this->db->fetch_object($result); + + $line = new SupplierProposalLine($this->db); + + $line->rowid = $objp->rowid; // deprecated + $line->id = $objp->rowid; + $line->fk_supplier_proposal = $objp->fk_supplier_proposal; + $line->fk_parent_line = $objp->fk_parent_line; + $line->product_type = $objp->product_type; + $line->label = $objp->custom_label; + $line->desc = $objp->description; // Description ligne + $line->qty = $objp->qty; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->subprice = $objp->subprice; + $line->fk_remise_except = $objp->fk_remise_except; + $line->remise_percent = $objp->remise_percent; + + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $line->special_code = $objp->special_code; + $line->rang = $objp->rang; + + $line->fk_product = $objp->fk_product; + + $line->ref = $objp->product_ref; // deprecated + $line->product_ref = $objp->product_ref; + $line->libelle = $objp->product_label; // deprecated + $line->product_label = $objp->product_label; + $line->product_desc = $objp->product_desc; // Description produit + $line->fk_product_type = $objp->fk_product_type; + + $line->ref_fourn = $objp->ref_produit_fourn; + + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fk_unit = $objp->fk_unit; + + $this->lines[$i] = $line; + + $i++; + } + $this->db->free($result); + } else { + $this->error = $this->db->error(); + return -1; + } + + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + return 1; + } + + $this->error = "Record Not Found"; + return 0; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Set status to validated + * + * @param User $user Object user that validate + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >=0 if OK + */ + public function valid($user, $notrigger = 0) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + global $conf, $langs; + + $error = 0; + $now = dol_now(); + + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance))) + { + $this->db->begin(); + + // Numbering module definition + $soc = new Societe($this->db); + $soc->fetch($this->socid); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + { + $num = $this->getNextNumRef($soc); + } else { + $num = $this->ref; + } + $this->newref = dol_sanitizeFileName($num); + + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dol_syslog(get_class($this)."::valid", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + dol_print_error($this->db); + $error++; + } + + // Trigger calls + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('PROPOSAL_SUPPLIER_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (!$error) + { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'supplier_proposal/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'supplier_proposal/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; + $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; + if (!$error && file_exists($dirsource)) + { + dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + + $this->ref = $num; + $this->brouillon = 0; + $this->statut = 1; + $this->user_valid_id = $user->id; + $this->datev = $now; + + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); + return -2; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $date_livraison Delivery date + * @return int <0 if ko, >0 if ok + */ + public function set_date_livraison($user, $date_livraison) + { + // phpcs:enable + if (!empty($user->rights->supplier_proposal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; + $sql .= " SET date_livraison = ".($date_livraison != '' ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->date_livraison = $date_livraison; + return 1; + } else { + $this->error = $this->db->error(); + dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); + return -1; + } + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set an overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + public function set_remise_percent($user, $remise) + { + // phpcs:enable + $remise = trim($remise) ?trim($remise) : 0; + + if (!empty($user->rights->supplier_proposal->creer)) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".$remise; + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->remise_percent = $remise; + $this->update_price(1); + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set an absolute overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + public function set_remise_absolue($user, $remise) + { + // phpcs:enable + $remise = trim($remise) ?trim($remise) : 0; + + if (!empty($user->rights->supplier_proposal->creer)) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; + $sql .= " SET remise_absolue = ".$remise; + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->remise_absolue = $remise; + $this->update_price(1); + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + } + + + + /** + * Reopen the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Statut + * @param string $note Comment + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK + */ + public function reopen($user, $statut, $note = '', $notrigger = 0) + { + global $langs, $conf; + + $this->statut = $statut; + $error = 0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; + $sql .= " SET fk_statut = ".$this->statut.","; + if (!empty($note)) $sql .= " note_private = '".$this->db->escape($note)."',"; + $sql .= " date_cloture=NULL, fk_user_cloture=NULL"; + $sql .= " WHERE rowid = ".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::reopen", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } + if (!$error) + { + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('PROPOSAL_SUPPLIER_REOPEN', $user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + if (!empty($this->errors)) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + + /** + * Close the askprice + * + * @param User $user Object user that close + * @param int $status Status + * @param string $note Comment + * @return int <0 if KO, >0 if OK + */ + public function cloture($user, $status, $note) + { + global $langs, $conf; + + $this->statut = $status; + $error = 0; + $now = dol_now(); + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; + $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $resql = $this->db->query($sql); + if ($resql) + { + $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED : $this->modelpdf; + $triggerName = 'PROPOSAL_SUPPLIER_CLOSE_REFUSED'; + + if ($status == 2) + { + $triggerName = 'PROPOSAL_SUPPLIER_CLOSE_SIGNED'; + $modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL : $this->modelpdf; + + if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists + { + $result = $this->updateOrCreatePriceFournisseur($user); + } + } + if ($status == 4) + { + $triggerName = 'PROPOSAL_SUPPLIER_CLASSIFY_BILLED'; + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + // Call trigger + $result = $this->call_trigger($triggerName, $user); + if ($result < 0) { $error++; } + // End call triggers + + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + /** + * Add or update supplier price according to result of proposal + * + * @param User $user Object user + * @return int > 0 if OK + */ + public function updateOrCreatePriceFournisseur($user) + { + global $conf; + + dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); + foreach ($this->lines as $product) + { + if ($product->subprice <= 0) continue; + $productsupplier = new ProductFournisseur($this->db); + + $multicurrency_tx = 1; + $fk_multicurrency = 0; + + if (empty($this->thirdparty)) $this->fetch_thirdparty(); + + $ref_fourn = $product->ref_fourn; + if (empty($ref_fourn)) $ref_fourn = $product->ref_supplier; + if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code); + $productsupplier->id = $product->fk_product; + + $productsupplier->update_buyprice($product->qty, $product->total_ht, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_total_ht, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', ''); + } + + return 1; + } + + /** + * Upate ProductFournisseur + * + * @param int $idProductFournPrice id of llx_product_fournisseur_price + * @param Product $product contain informations to update + * @param User $user Object user + * @return int <0 if KO, >0 if OK + */ + public function updatePriceFournisseur($idProductFournPrice, $product, $user) + { + $price = price2num($product->subprice * $product->qty, 'MU'); + $unitPrice = price2num($product->subprice, 'MU'); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Create ProductFournisseur + * + * @param Product $product Object Product + * @param User $user Object user + * @return int <0 if KO, >0 if OK + */ + public function createPriceFournisseur($product, $user) + { + global $conf; + + $price = price2num($product->subprice * $product->qty, 'MU'); + $qty = price2num($product->qty); + $unitPrice = price2num($product->subprice, 'MU'); + + $now = dol_now(); + + $values = array( + "'".$this->db->idate($now)."'", + $product->fk_product, + $this->thirdparty->id, + "'".$product->ref_fourn."'", + $price, + $qty, + $unitPrice, + $product->tva_tx, + $user->id + ); + if (!empty($conf->multicurrency->enabled)) { + if (!empty($product->multicurrency_code)) { include_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - $multicurrency = new MultiCurrency($this->db); //need to fetch because empty fk_multicurrency and rate - $multicurrency->fetch(0, $product->multicurrency_code); - if (!empty($multicurrency->id)) { - $values[] = $multicurrency->id; - $values[] = "'".$product->multicurrency_code."'"; - $values[] = $product->multicurrency_subprice; - $values[] = $product->multicurrency_total_ht; - $values[] = $multicurrency->rate->rate; - } else { - for ($i = 0; $i < 5; $i++) $values[] = 'NULL'; - } - } - } + $multicurrency = new MultiCurrency($this->db); //need to fetch because empty fk_multicurrency and rate + $multicurrency->fetch(0, $product->multicurrency_code); + if (!empty($multicurrency->id)) { + $values[] = $multicurrency->id; + $values[] = "'".$product->multicurrency_code."'"; + $values[] = $product->multicurrency_subprice; + $values[] = $product->multicurrency_total_ht; + $values[] = $multicurrency->rate->rate; + } else { + for ($i = 0; $i < 5; $i++) $values[] = 'NULL'; + } + } + } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; - $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user'; - if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) $sql .= ',fk_multicurrency, multicurrency_code, multicurrency_unitprice, multicurrency_price, multicurrency_tx'; - $sql .= ') VALUES ('.implode(',', $values).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; + $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user'; + if (!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) $sql .= ',fk_multicurrency, multicurrency_code, multicurrency_unitprice, multicurrency_price, multicurrency_tx'; + $sql .= ') VALUES ('.implode(',', $values).')'; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set draft status - * - * @param User $user Object user that modify - * @return int <0 if KO, >0 if OK - */ - public function setDraft($user) - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set draft status + * + * @param User $user Object user that modify + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user) + { + // phpcs:enable + global $conf, $langs; - $error = 0; + $error = 0; - if ($this->statut == self::STATUS_DRAFT) - { - dol_syslog(get_class($this)."::setDraft already draft status", LOG_WARNING); - return 0; - } + if ($this->statut == self::STATUS_DRAFT) + { + dol_syslog(get_class($this)."::setDraft already draft status", LOG_WARNING); + return 0; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".self::STATUS_DRAFT; - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { - if (!$error) { - $this->oldcopy = clone $this; - } + if ($this->db->query($sql)) + { + if (!$error) { + $this->oldcopy = clone $this; + } - if (!$error) { - // Call trigger - $result = $this->call_trigger('PROPOSAL_SUPPLIER_UNVALIDATE', $user); - if ($result < 0) $error++; - } + if (!$error) { + // Call trigger + $result = $this->call_trigger('PROPOSAL_SUPPLIER_UNVALIDATE', $user); + if ($result < 0) $error++; + } - if (!$error) { - $this->statut = self::STATUS_DRAFT; - $this->brouillon = 1; - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } else { - return -1; - } - } + if (!$error) { + $this->statut = self::STATUS_DRAFT; + $this->brouillon = 1; + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } else { + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return list of askprice (eventually filtered on user) into an array - * - * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) - * @param int $draft 0=not draft, 1=draft - * @param int $notcurrentuser 0=all user, 1=not current user - * @param int $socid Id third pary - * @param int $limit For pagination - * @param int $offset For pagination - * @param string $sortfield Sort criteria - * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK - */ - public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') - { - // phpcs:enable - global $conf, $user; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of askprice (eventually filtered on user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param int $notcurrentuser 0=all user, 1=not current user + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') + { + // phpcs:enable + global $conf, $user; - $ga = array(); + $ga = array(); - $sql = "SELECT s.rowid, s.nom as name, s.client,"; - $sql .= " p.rowid as supplier_proposalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; - $sql .= " p.datep as dp, p.fin_validite as datelimite"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.entity IN (".getEntity('supplier_proposal').")"; - $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.fk_statut = c.id"; - if (!$user->rights->societe->client->voir && !$socid) //restriction - { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - if ($socid) $sql .= " AND s.rowid = ".$socid; - if ($draft) $sql .= " AND p.fk_statut = 0"; - if ($notcurrentuser > 0) $sql .= " AND p.fk_user_author <> ".$user->id; - $sql .= $this->db->order($sortfield, $sortorder); - $sql .= $this->db->plimit($limit, $offset); + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql .= " p.rowid as supplier_proposalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; + $sql .= " p.datep as dp, p.fin_validite as datelimite"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.entity IN (".getEntity('supplier_proposal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.fk_statut = c.id"; + if (!$user->rights->societe->client->voir && !$socid) //restriction + { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) $sql .= " AND s.rowid = ".$socid; + if ($draft) $sql .= " AND p.fk_statut = 0"; + if ($notcurrentuser > 0) $sql .= " AND p.fk_user_author <> ".$user->id; + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); - if ($shortlist == 1) - { - $ga[$obj->supplier_proposalid] = $obj->ref; - } elseif ($shortlist == 2) - { - $ga[$obj->supplier_proposalid] = $obj->ref.' ('.$obj->name.')'; - } else { - $ga[$i]['id'] = $obj->supplier_proposalid; - $ga[$i]['ref'] = $obj->ref; - $ga[$i]['name'] = $obj->name; - } + if ($shortlist == 1) + { + $ga[$obj->supplier_proposalid] = $obj->ref; + } elseif ($shortlist == 2) + { + $ga[$obj->supplier_proposalid] = $obj->ref.' ('.$obj->name.')'; + } else { + $ga[$i]['id'] = $obj->supplier_proposalid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } - $i++; - } - } - return $ga; - } else { - dol_print_error($this->db); - return -1; - } - } + $i++; + } + } + return $ga; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Delete askprice - * - * @param User $user Object user that delete - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int 1 if ok, otherwise if error - */ - public function delete($user, $notrigger = 0) - { - global $conf, $langs; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + /** + * Delete askprice + * + * @param User $user Object user that delete + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int 1 if ok, otherwise if error + */ + public function delete($user, $notrigger = 0) + { + global $conf, $langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error = 0; + $error = 0; - $this->db->begin(); + $this->db->begin(); - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('PROPOSAL_SUPPLIER_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$notrigger) + { + // Call trigger + $result = $this->call_trigger('PROPOSAL_SUPPLIER_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $main = MAIN_DB_PREFIX.'supplier_proposaldet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_supplier_proposal = ".$this->id.")"; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal = ".$this->id; - if ($this->db->query($sql)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal WHERE rowid = ".$this->id; - if ($this->db->query($sqlef) && $this->db->query($sql)) - { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; + if (!$error) + { + $main = MAIN_DB_PREFIX.'supplier_proposaldet'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_supplier_proposal = ".$this->id.")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal = ".$this->id; + if ($this->db->query($sql)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal WHERE rowid = ".$this->id; + if ($this->db->query($sqlef) && $this->db->query($sql)) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; - if (!$error) - { - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->supplier_proposal->dir_output && !empty($this->ref)) - { - $dir = $conf->supplier_proposal->dir_output."/".$ref; - $file = $dir."/".$ref.".pdf"; - if (file_exists($file)) - { - dol_delete_preview($this); + if (!$error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->supplier_proposal->dir_output && !empty($this->ref)) + { + $dir = $conf->supplier_proposal->dir_output."/".$ref; + $file = $dir."/".$ref.".pdf"; + if (file_exists($file)) + { + dol_delete_preview($this); - if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers - { - $this->error = 'ErrorFailToDeleteFile'; - $this->errors = array('ErrorFailToDeleteFile'); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) - { - $res = @dol_delete_dir_recursive($dir); - if (!$res) - { - $this->error = 'ErrorFailToDeleteDir'; - $this->errors = array('ErrorFailToDeleteDir'); - $this->db->rollback(); - return 0; - } - } - } - } + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers + { + $this->error = 'ErrorFailToDeleteFile'; + $this->errors = array('ErrorFailToDeleteFile'); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) + { + $res = @dol_delete_dir_recursive($dir); + if (!$res) + { + $this->error = 'ErrorFailToDeleteDir'; + $this->errors = array('ErrorFailToDeleteDir'); + $this->db->rollback(); + return 0; + } + } + } + } - // Removed extrafields - if (!$error) - { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + // Removed extrafields + if (!$error) + { + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag = -4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } - if (!$error) - { - dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return 0; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -3; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return 0; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -3; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Object SupplierProposal Information - * - * @param int $id Proposal id - * @return void - */ - public function info($id) - { - $sql = "SELECT c.rowid, "; - $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; - $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c"; - $sql .= " WHERE c.rowid = ".$id; + /** + * Object SupplierProposal Information + * + * @param int $id Proposal id + * @return void + */ + public function info($id) + { + $sql = "SELECT c.rowid, "; + $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; + $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c"; + $sql .= " WHERE c.rowid = ".$id; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_validation = $this->db->jdate($obj->datev); - $this->date_cloture = $this->db->jdate($obj->dateo); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_cloture = $this->db->jdate($obj->dateo); - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } - /** - * Return label of status of proposal (draft, validated, ...) - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut((isset($this->statut) ? $this->statut : $this->status), $mode); - } + /** + * Return label of status of proposal (draft, validated, ...) + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut((isset($this->statut) ? $this->statut : $this->status), $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of a status (draft, validated, ...) - * - * @param int $status Id status + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status (draft, validated, ...) + * + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label - */ - public function LibStatut($status, $mode = 1) - { - // phpcs:enable + * @return string Label + */ + public function LibStatut($status, $mode = 1) + { + // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelStatus) || empty($this->labelStatusShort)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelStatus[self::STATUS_DRAFT] = $langs->trans("SupplierProposalStatusDraft"); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans("SupplierProposalStatusValidated"); - $this->labelStatus[self::STATUS_SIGNED] = $langs->trans("SupplierProposalStatusSigned"); - $this->labelStatus[self::STATUS_NOTSIGNED] = $langs->trans("SupplierProposalStatusNotSigned"); - $this->labelStatus[self::STATUS_CLOSE] = $langs->trans("SupplierProposalStatusClosed"); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans("SupplierProposalStatusDraftShort"); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans("Opened"); - $this->labelStatusShort[self::STATUS_SIGNED] = $langs->trans("SupplierProposalStatusSignedShort"); - $this->labelStatusShort[self::STATUS_NOTSIGNED] = $langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelStatusShort[self::STATUS_CLOSE] = $langs->trans("SupplierProposalStatusClosedShort"); - } + // Init/load array of translation of status + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans("SupplierProposalStatusDraft"); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans("SupplierProposalStatusValidated"); + $this->labelStatus[self::STATUS_SIGNED] = $langs->trans("SupplierProposalStatusSigned"); + $this->labelStatus[self::STATUS_NOTSIGNED] = $langs->trans("SupplierProposalStatusNotSigned"); + $this->labelStatus[self::STATUS_CLOSE] = $langs->trans("SupplierProposalStatusClosed"); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans("SupplierProposalStatusDraftShort"); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans("Opened"); + $this->labelStatusShort[self::STATUS_SIGNED] = $langs->trans("SupplierProposalStatusSignedShort"); + $this->labelStatusShort[self::STATUS_NOTSIGNED] = $langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelStatusShort[self::STATUS_CLOSE] = $langs->trans("SupplierProposalStatusClosedShort"); + } - $statusnew = ''; - if ($status == self::STATUS_DRAFT) $statusnew = 'status0'; - elseif ($status == self::STATUS_VALIDATED) $statusnew = 'status1'; - elseif ($status == self::STATUS_SIGNED) $statusnew = 'status4'; - elseif ($status == self::STATUS_NOTSIGNED) $statusnew = 'status9'; - elseif ($status == self::STATUS_CLOSE) $statusnew = 'status6'; + $statusnew = ''; + if ($status == self::STATUS_DRAFT) $statusnew = 'status0'; + elseif ($status == self::STATUS_VALIDATED) $statusnew = 'status1'; + elseif ($status == self::STATUS_SIGNED) $statusnew = 'status4'; + elseif ($status == self::STATUS_NOTSIGNED) $statusnew = 'status9'; + elseif ($status == self::STATUS_CLOSE) $statusnew = 'status6'; - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusnew, $mode); - } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusnew, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Object user - * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice - * @return int <0 if KO, >0 if OK - */ - public function load_board($user, $mode) - { - // phpcs:enable - global $conf, $user, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Object user + * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice + * @return int <0 if KO, >0 if OK + */ + public function load_board($user, $mode) + { + // phpcs:enable + global $conf, $user, $langs; - $now = dol_now(); + $now = dol_now(); - $this->nbtodo = $this->nbtodolate = 0; - $clause = " WHERE"; + $this->nbtodo = $this->nbtodolate = 0; + $clause = " WHERE"; - $sql = "SELECT p.rowid, p.ref, p.datec as datec"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) - { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; - $sql .= " WHERE sc.fk_user = ".$user->id; - $clause = " AND"; - } - $sql .= $clause." p.entity IN (".getEntity('supplier_proposal').")"; - if ($mode == 'opened') $sql .= " AND p.fk_statut = 1"; - if ($mode == 'signed') $sql .= " AND p.fk_statut = 2"; - if ($user->socid) $sql .= " AND p.fk_soc = ".$user->socid; + $sql = "SELECT p.rowid, p.ref, p.datec as datec"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; + $clause = " AND"; + } + $sql .= $clause." p.entity IN (".getEntity('supplier_proposal').")"; + if ($mode == 'opened') $sql .= " AND p.fk_statut = 1"; + if ($mode == 'signed') $sql .= " AND p.fk_statut = 2"; + if ($user->socid) $sql .= " AND p.fk_soc = ".$user->socid; - $resql = $this->db->query($sql); - if ($resql) - { + $resql = $this->db->query($sql); + if ($resql) + { $label = $labelShort = ''; $status = ''; - if ($mode == 'opened') { - $delay_warning = $conf->supplier_proposal->cloture->warning_delay; - $status = self::STATUS_VALIDATED; - $label = $langs->trans("SupplierProposalsToClose"); - $labelShort = $langs->trans("ToAcceptRefuse"); - } - if ($mode == 'signed') { - $delay_warning = $conf->supplier_proposal->facturation->warning_delay; - $status = self::STATUS_SIGNED; - $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + if ($mode == 'opened') { + $delay_warning = $conf->supplier_proposal->cloture->warning_delay; + $status = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); + $labelShort = $langs->trans("ToAcceptRefuse"); + } + if ($mode == 'signed') { + $delay_warning = $conf->supplier_proposal->facturation->warning_delay; + $status = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered $labelShort = $langs->trans("ToClose"); - } + } - $response = new WorkboardResponse(); - $response->warning_delay = $delay_warning / 60 / 60 / 24; - $response->label = $label; - $response->labelShort = $labelShort; - $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?search_status='.$status; - $response->img = img_object('', "propal"); + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning / 60 / 60 / 24; + $response->label = $label; + $response->labelShort = $labelShort; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?search_status='.$status; + $response->img = img_object('', "propal"); - // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { - $response->nbtodo++; - if ($mode == 'opened') - { - $datelimit = $this->db->jdate($obj->datefin); - if ($datelimit < ($now - $delay_warning)) - { - $response->nbtodolate++; - } - } - // TODO Definir regle des propales a facturer en retard - // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; - } - return $response; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + // This assignment in condition is not a bug. It allows walking the results. + while ($obj = $this->db->fetch_object($resql)) + { + $response->nbtodo++; + if ($mode == 'opened') + { + $datelimit = $this->db->jdate($obj->datefin); + if ($datelimit < ($now - $delay_warning)) + { + $response->nbtodolate++; + } + } + // TODO Definir regle des propales a facturer en retard + // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; + } + return $response; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { - global $user, $langs, $conf; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + global $user, $langs, $conf; - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $sql .= $this->db->plimit(100); + // Load array of products prodids + $num_prods = 0; + $prodids = array(); + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; + $sql .= $this->db->plimit(100); - $resql = $this->db->query($sql); - if ($resql) - { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) - { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } - // Initialise parametres - $this->id = 0; - $this->ref = 'SPECIMEN'; - $this->specimen = 1; - $this->socid = 1; - $this->date = time(); - $this->cond_reglement_id = 1; - $this->cond_reglement_code = 'RECEP'; - $this->mode_reglement_id = 7; - $this->mode_reglement_code = 'CHQ'; - $this->note_public = 'This is a comment (public)'; - $this->note_private = 'This is a comment (private)'; - // Lines - $nbp = 5; - $xnbp = 0; - while ($xnbp < $nbp) - { - $line = new SupplierProposalLine($this->db); - $line->desc = $langs->trans("Description")." ".$xnbp; - $line->qty = 1; - $line->subprice = 100; - $line->tva_tx = 19.6; - $line->localtax1_tx = 0; - $line->localtax2_tx = 0; - if ($xnbp == 2) - { - $line->total_ht = 50; - $line->total_ttc = 59.8; - $line->total_tva = 9.8; - $line->remise_percent = 50; - } else { - $line->total_ht = 100; - $line->total_ttc = 119.6; - $line->total_tva = 19.6; - $line->remise_percent = 00; - } + // Initialise parametres + $this->id = 0; + $this->ref = 'SPECIMEN'; + $this->specimen = 1; + $this->socid = 1; + $this->date = time(); + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->mode_reglement_id = 7; + $this->mode_reglement_code = 'CHQ'; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $line = new SupplierProposalLine($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + if ($xnbp == 2) + { + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->remise_percent = 50; + } else { + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->remise_percent = 00; + } - if ($num_prods > 0) - { - $prodid = mt_rand(1, $num_prods); - $line->fk_product = $prodids[$prodid]; - } + if ($num_prods > 0) + { + $prodid = mt_rand(1, $num_prods); + $line->fk_product = $prodids[$prodid]; + } - $this->lines[$xnbp] = $line; + $this->lines[$xnbp] = $line; - $this->total_ht += $line->total_ht; - $this->total_tva += $line->total_tva; - $this->total_ttc += $line->total_ttc; + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; - $xnbp++; - } - } + $xnbp++; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load indicator this->nb of global stats widget - * - * @return int <0 if ko, >0 if ok - */ - public function load_state_board() - { - // phpcs:enable - global $conf, $user; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicator this->nb of global stats widget + * + * @return int <0 if ko, >0 if ok + */ + public function load_state_board() + { + // phpcs:enable + global $conf, $user; - $this->nb = array(); - $clause = "WHERE"; + $this->nb = array(); + $clause = "WHERE"; - $sql = "SELECT count(p.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) - { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql .= " WHERE sc.fk_user = ".$user->id; - $clause = "AND"; - } - $sql .= " ".$clause." p.entity IN (".getEntity('supplier_proposal').")"; + $sql = "SELECT count(p.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) + { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; + $clause = "AND"; + } + $sql .= " ".$clause." p.entity IN (".getEntity('supplier_proposal').")"; - $resql = $this->db->query($sql); - if ($resql) - { - // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { - $this->nb["supplier_proposals"] = $obj->nb; - } - $this->db->free($resql); - return 1; - } else { - dol_print_error($this->db); - $this->error = $this->db->lasterror(); - return -1; - } - } + $resql = $this->db->query($sql); + if ($resql) + { + // This assignment in condition is not a bug. It allows walking the results. + while ($obj = $this->db->fetch_object($resql)) + { + $this->nb["supplier_proposals"] = $obj->nb; + } + $this->db->free($resql); + return 1; + } else { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Returns the reference to the following non used Proposal used depending on the active numbering module - * defined into SUPPLIER_PROPOSAL_ADDON - * - * @param Societe $soc Object thirdparty - * @return string Reference libre pour la propale - */ - public function getNextNumRef($soc) - { - global $conf, $db, $langs; - $langs->load("supplier_proposal"); + /** + * Returns the reference to the following non used Proposal used depending on the active numbering module + * defined into SUPPLIER_PROPOSAL_ADDON + * + * @param Societe $soc Object thirdparty + * @return string Reference libre pour la propale + */ + public function getNextNumRef($soc) + { + global $conf, $db, $langs; + $langs->load("supplier_proposal"); - if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON)) - { - $mybool = false; + if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON)) + { + $mybool = false; - $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.".php"; - $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON; + $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.".php"; + $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON; - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_proposal/"); + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/supplier_proposal/"); - // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; - } + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } - if (!$mybool) - { - dol_print_error('', "Failed to include file ".$file); - return ''; - } + if (!$mybool) + { + dol_print_error('', "Failed to include file ".$file); + return ''; + } - $obj = new $classname(); - $numref = ""; - $numref = $obj->getNextValue($soc, $this); + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc, $this); - if ($numref != "") - { - return $numref; - } else { - $this->error = $obj->error; - return ""; - } - } else { - $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("SupplierProposal")); - return ""; - } - } + if ($numref != "") + { + return $numref; + } else { + $this->error = $obj->error; + return ""; + } + } else { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("SupplierProposal")); + return ""; + } + } - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('compta', 'expedition', 'document', ...) - * @param string $get_params Parametres added to url - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $addlinktonotes Add link to show notes - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) - { - global $langs, $conf, $user; + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $get_params Parametres added to url + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $addlinktonotes Add link to show notes + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) + { + global $langs, $conf, $user; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $url = ''; - $result = ''; + $url = ''; + $result = ''; - $label = ''.$langs->trans("SupplierProposal").''; - if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->ref_fourn)) $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_fourn; - if (!empty($this->total_ht)) $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_tva)) $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (!empty($this->total_ttc)) $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if (isset($this->status)) { - $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); - } + $label = ''.$langs->trans("SupplierProposal").''; + if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->ref_fourn)) $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_fourn; + if (!empty($this->total_ht)) $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_tva)) $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + if (!empty($this->total_ttc)) $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + if (isset($this->status)) { + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + } - if ($option == '') { - $url = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$this->id.$get_params; - } - if ($option == 'document') { - $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id.$get_params; - } + if ($option == '') { + $url = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$this->id.$get_params; + } + if ($option == 'document') { + $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id.$get_params; + } - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkclose = ''; - if (empty($notooltip) && $user->rights->propal->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowSupplierProposal"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->propal->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowSupplierProposal"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - if ($addlinktonotes) - { - $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); - if ($txttoshow) - { - $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); - $result .= ' '; - $result .= ''; - $result .= img_picto('', 'note'); - $result .= ''; - //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); - //$result.=''; - $result .= ''; - } - } + if ($addlinktonotes) + { + $txttoshow = ($user->socid > 0 ? $this->note_public : $this->note_private); + if ($txttoshow) + { + $notetoshow = $langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow, 1); + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); + //$result.=''; + $result .= ''; + } + } - return $result; - } + return $result; + } - /** - * Retrieve an array of supplier proposal lines - * - * @return int >0 if OK, <0 if KO - */ - public function getLinesArray() - { - // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal + /** + * Retrieve an array of supplier proposal lines + * + * @return int >0 if OK, <0 if KO + */ + public function getLinesArray() + { + // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal - $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; - $sql .= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; - $sql .= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; - $sql .= ' pt.product_type, pt.rang, pt.fk_parent_line,'; - $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; - $sql .= ' p.description as product_desc, pt.ref_fourn as ref_supplier,'; - $sql .= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; - $sql .= ' WHERE pt.fk_supplier_proposal = '.$this->id; - $sql .= ' ORDER BY pt.rang ASC, pt.rowid'; + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; + $sql .= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; + $sql .= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; + $sql .= ' pt.product_type, pt.rang, pt.fk_parent_line,'; + $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; + $sql .= ' p.description as product_desc, pt.ref_fourn as ref_supplier,'; + $sql .= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql .= ' WHERE pt.fk_supplier_proposal = '.$this->id; + $sql .= ' ORDER BY pt.rang ASC, pt.rowid'; - dol_syslog(get_class($this).'::getLinesArray', LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; + dol_syslog(get_class($this).'::getLinesArray', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - $this->lines[$i] = new SupplierProposalLine($this->db); - $this->lines[$i]->id = $obj->rowid; // for backward compatibility - $this->lines[$i]->rowid = $obj->rowid; - $this->lines[$i]->label = $obj->custom_label; - $this->lines[$i]->description = $obj->description; - $this->lines[$i]->fk_product = $obj->fk_product; - $this->lines[$i]->ref = $obj->ref; - $this->lines[$i]->product_label = $obj->product_label; - $this->lines[$i]->product_desc = $obj->product_desc; - $this->lines[$i]->fk_product_type = $obj->fk_product_type; // deprecated - $this->lines[$i]->product_type = $obj->product_type; - $this->lines[$i]->qty = $obj->qty; - $this->lines[$i]->subprice = $obj->subprice; - $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; - $this->lines[$i]->remise_percent = $obj->remise_percent; - $this->lines[$i]->tva_tx = $obj->tva_tx; - $this->lines[$i]->info_bits = $obj->info_bits; - $this->lines[$i]->total_ht = $obj->total_ht; - $this->lines[$i]->total_tva = $obj->total_tva; - $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; - $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); - $this->lines[$i]->pa_ht = $marginInfos[0]; - $this->lines[$i]->marge_tx = $marginInfos[1]; - $this->lines[$i]->marque_tx = $marginInfos[2]; - $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; - $this->lines[$i]->special_code = $obj->special_code; - $this->lines[$i]->rang = $obj->rang; + $this->lines[$i] = new SupplierProposalLine($this->db); + $this->lines[$i]->id = $obj->rowid; // for backward compatibility + $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->label = $obj->custom_label; + $this->lines[$i]->description = $obj->description; + $this->lines[$i]->fk_product = $obj->fk_product; + $this->lines[$i]->ref = $obj->ref; + $this->lines[$i]->product_label = $obj->product_label; + $this->lines[$i]->product_desc = $obj->product_desc; + $this->lines[$i]->fk_product_type = $obj->fk_product_type; // deprecated + $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->qty = $obj->qty; + $this->lines[$i]->subprice = $obj->subprice; + $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; + $this->lines[$i]->remise_percent = $obj->remise_percent; + $this->lines[$i]->tva_tx = $obj->tva_tx; + $this->lines[$i]->info_bits = $obj->info_bits; + $this->lines[$i]->total_ht = $obj->total_ht; + $this->lines[$i]->total_tva = $obj->total_tva; + $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); + $this->lines[$i]->pa_ht = $marginInfos[0]; + $this->lines[$i]->marge_tx = $marginInfos[1]; + $this->lines[$i]->marque_tx = $marginInfos[2]; + $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->special_code = $obj->special_code; + $this->lines[$i]->rang = $obj->rang; - $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated - $this->lines[$i]->ref_supplier = $obj->ref_supplier; + $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated + $this->lines[$i]->ref_supplier = $obj->ref_supplier; - // Multicurrency - $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; - $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; - $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; - $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->lines[$i]->fk_unit = $obj->fk_unit; + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->lines[$i]->fk_unit = $obj->fk_unit; - $i++; - } - $this->db->free($resql); + $i++; + } + $this->db->free($resql); - return 1; - } else { - $this->error = $this->db->error(); - return -1; - } - } + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force model to use ('' to not force) - * @param Translate $outputlangs Object langs to use for output - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; - $langs->load("supplier_proposal"); + $langs->load("supplier_proposal"); $outputlangs->load("products"); - if (!dol_strlen($modele)) { - $modele = 'aurore'; + if (!dol_strlen($modele)) { + $modele = 'aurore'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { - $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { + $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; + } + } - $modelpath = "core/modules/supplier_proposal/doc/"; + $modelpath = "core/modules/supplier_proposal/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'supplier_proposal' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'supplier_proposal' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index aaffdd7e01a..2f45d24c401 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -369,38 +369,38 @@ if ($action == "freezone") { $tva_tx = get_default_tva($mysoc, $customer); } - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); - $invoice->fetch($placeid); + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->fetch($placeid); } if ($action == "addnote") { - foreach ($invoice->lines as $line) - { - if ($line->id == $number) + foreach ($invoice->lines as $line) + { + if ($line->id == $number) { $line->array_options['order_notes'] = $desc; $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - $invoice->fetch($placeid); + } + } + $invoice->fetch($placeid); } if ($action == "deleteline") { - if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); - $invoice->fetch($placeid); - } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); - $invoice->fetch($placeid); - } + if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='".$placeid."' order by rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + $deletelineid = $row[0]; + $invoice->deleteline($deletelineid); + $invoice->fetch($placeid); + } if (count($invoice->lines) == 0) $invoice->delete($user); } @@ -830,7 +830,7 @@ $( document ).ready(function() { $s .= '
'.$langs->trans("SubscriptionNotReceived"); if ($adh->statut > 0) $s .= " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } - if (empty($adh->statut)) { $s .= ""; } + if (empty($adh->statut)) { $s .= ""; } } else { $s .= '
'.$langs->trans("ThirdpartyNotLinkedToMember"); } @@ -1011,47 +1011,47 @@ if ($placeid > 0) $htmlsupplements[$line->fk_parent_line] .= ''."\n"; continue; } - $htmlforlines = ''; + $htmlforlines = ''; - $htmlforlines .= 'id.'">'; - $htmlforlines .= ''; + $htmlforlines .= 'id.'">'; + $htmlforlines .= ''; if ($_SESSION["basiclayout"] == 1) $htmlforlines .= ''.$line->qty." x "; - if (isset($line->product_type)) - { - if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; - else $htmlforlines .= img_object('', 'service').' '; - } - if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { - $tooltiptext = ''; - if ($line->product_ref) { - $tooltiptext .= ''.$langs->trans("Ref").' : '.$line->product_ref.'
'; - $tooltiptext .= ''.$langs->trans("Label").' : '.$line->product_label.'
'; - if ($line->product_label != $line->desc) { - if ($line->desc) $tooltiptext .= '
'; - $tooltiptext .= $line->desc; - } - } - $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); - } else { - if ($line->product_label) $htmlforlines .= $line->product_label; - if ($line->product_label != $line->desc) - { - if ($line->product_label && $line->desc) $htmlforlines .= '
'; - $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); - if ($firstline != $line->desc) - { - $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); - } else { - $htmlforlines .= $line->desc; - } - } - } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; - if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '  '; + if (isset($line->product_type)) + { + if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; + else $htmlforlines .= img_object('', 'service').' '; + } + if (empty($conf->global->TAKEPOS_SHOW_N_FIRST_LINES)) { + $tooltiptext = ''; + if ($line->product_ref) { + $tooltiptext .= ''.$langs->trans("Ref").' : '.$line->product_ref.'
'; + $tooltiptext .= ''.$langs->trans("Label").' : '.$line->product_label.'
'; + if ($line->product_label != $line->desc) { + if ($line->desc) $tooltiptext .= '
'; + $tooltiptext .= $line->desc; + } + } + $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); + } else { + if ($line->product_label) $htmlforlines .= $line->product_label; + if ($line->product_label != $line->desc) + { + if ($line->product_label && $line->desc) $htmlforlines .= '
'; + $firstline = dolGetFirstLineOfText($line->desc, $conf->global->TAKEPOS_SHOW_N_FIRST_LINES); + if ($firstline != $line->desc) + { + $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } else { + $htmlforlines .= $line->desc; + } + } + } + if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; + if ($_SESSION["basiclayout"] == 1) $htmlforlines .= '  '; if ($_SESSION["basiclayout"] != 1) { $moreinfo = ''; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index f521076e640..6c7a1278c99 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -138,7 +138,7 @@ if (empty($reshook)) { if ($cancel) { if (!empty($backtopage)) { - header("Location: " . $backtopage); + header("Location: ".$backtopage); exit; } @@ -254,10 +254,10 @@ if (empty($reshook)) { if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?track_id=' . $object->track_id; + $url = 'card.php?track_id='.$object->track_id; } - header("Location: " . $url); + header("Location: ".$url); exit; } else { $db->rollback(); @@ -325,7 +325,7 @@ if (empty($reshook)) { if ($object->markAsRead($user) > 0) { setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); - header("Location: card.php?track_id=" . $object->track_id . "&action=view"); + header("Location: card.php?track_id=".$object->track_id."&action=view"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -376,7 +376,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); - header("Location: card.php?track_id=" . $object->track_id . "&action=view"); + header("Location: card.php?track_id=".$object->track_id."&action=view"); exit; } else { array_push($object->errors, $object->error); @@ -392,10 +392,10 @@ if (empty($reshook)) { if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?action=view&track_id=' . $object->track_id; + $url = 'card.php?action=view&track_id='.$object->track_id; } - header("Location: " . $url); + header("Location: ".$url); exit; } else { setEventMessages($object->error, null, 'errors'); @@ -409,8 +409,8 @@ if (empty($reshook)) { if ($object->close($user)) { setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); + header("Location: ".$url); } else { $action = ''; setEventMessages($object->error, $object->errors, 'errors'); @@ -425,10 +425,10 @@ if (empty($reshook)) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); + setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); - $url = 'card.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); + $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha'); + header("Location: ".$url); } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; @@ -438,12 +438,12 @@ if (empty($reshook)) { if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->delete($user) > 0) { - setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); - Header("Location: " . DOL_URL_ROOT . "/ticket/list.php"); + setEventMessages('
'.$langs->trans('TicketDeletedSuccess').'
', null, 'mesgs'); + Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); exit; } else { $langs->load("errors"); - $mesg = '
' . $langs->trans($object->error) . '
'; + $mesg = '
'.$langs->trans($object->error).'
'; $action = ''; } } @@ -453,8 +453,8 @@ if (empty($reshook)) { if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); + header("Location: ".$url); exit(); } } @@ -463,8 +463,8 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setProgression(GETPOST('progress', 'alpha')); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.$object->track_id; + header("Location: ".$url); exit(); } } @@ -476,12 +476,12 @@ if (empty($reshook)) { } if ($action == 'setsubject' && empty($object->subject)) { - $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); + $mesg .= ($mesg ? '
' : '').$langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); } if (!$mesg) { if ($object->update($user) >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); + header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id); exit; } $mesg = $object->error; @@ -498,8 +498,8 @@ if (empty($reshook)) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogReopen'); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.$object->track_id; + header("Location: ".$url); exit(); } } @@ -508,16 +508,16 @@ if (empty($reshook)) { elseif ($action == 'classin' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setProject(GETPOST('projectid', 'int')); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.$object->track_id; + header("Location: ".$url); exit(); } } // Categorisation dans contrat elseif ($action == 'setcontract' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setContract(GETPOST('contractid', 'int')); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.$object->track_id; + header("Location: ".$url); exit(); } } elseif ($action == "set_message" && $user->rights->ticket->manage) { @@ -530,7 +530,7 @@ if (empty($reshook)) { $object->message = $fieldtomodify; $ret = $object->update($user); if ($ret > 0) { - $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; + $log_action = $langs->trans('TicketInitialMessageModified')." \n"; // include the Diff class dol_include_once('/ticket/class/utils_diff.class.php'); // output the result of comparing two files as plain text @@ -551,8 +551,8 @@ if (empty($reshook)) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); + $url = 'card.php?action=view&track_id='.$object->track_id; + header("Location: ".$url); exit(); } } @@ -597,19 +597,19 @@ if (empty($reshook)) { $permissiondellink = $user->rights->ticket->write; - include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Actions to build doc $upload_dir = $conf->ticket->dir_output; $permissiontoadd = $user->rights->ticket->write; - include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails $triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add - $trackid = 'tic' . $object->id; - include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; + $trackid = 'tic'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Set $action to correct value for the case we used presend action to add a message if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; @@ -1027,15 +1027,15 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } else { // Type print ''.$langs->trans("Type").''; - print $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); + print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print ''; // Group print ''.$langs->trans("TicketCategory").''; - print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); + print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); print ''; // Severity print ''.$langs->trans("TicketSeverity").''; - print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); + print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); print ''; } print ''; // End table actions @@ -1299,7 +1299,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab) - if (! empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { + if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; @@ -1308,17 +1308,17 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $morehtmlright = ''; - $messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object->track_id; + $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1); // Show link to add a message (if read and not closed) $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; - $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; + $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); // Show link to add event (if read and not closed) - $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";; - $url = dol_buildpath('/comm/action/card.php', 1) . '?action=create&datep=' . date('YmdHi') . '&origin=ticket&originid=' . $object->id . '&projectid=' . $object->fk_project . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id); + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; ; + $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); @@ -1352,7 +1352,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id); // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 6b3b1ea8fd4..bf24fa83626 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1701,7 +1701,7 @@ class Ticket extends CommonObject $error = 0; // Valid and close fichinter linked - if (!empty($conf->ficheinter->enabled) && ! empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) { + if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) { dol_syslog("We have closed the ticket, so we close all linked interventions"); $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); if ($this->linkedObjectsIds) @@ -2549,23 +2549,23 @@ class Ticket extends CommonObject // Customer company infos $message .= '

'; $message .= "=============================================="; - $message .= !empty($object->thirdparty->name) ? '
' . $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; - $message .= !empty($object->thirdparty->town) ? '
' . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; - $message .= !empty($object->thirdparty->phone) ? '
' . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; + $message .= !empty($object->thirdparty->name) ? '
'.$langs->trans('Thirdparty')." : ".$object->thirdparty->name : ''; + $message .= !empty($object->thirdparty->town) ? '
'.$langs->trans('Town')." : ".$object->thirdparty->town : ''; + $message .= !empty($object->thirdparty->phone) ? '
'.$langs->trans('Phone')." : ".$object->thirdparty->phone : ''; // Email send to $message .= '

'; if (!empty($assigned_user_dont_have_email)) { - $message .= '
' . $langs->trans('NoEMail') . ' : ' . $assigned_user_dont_have_email; + $message .= '
'.$langs->trans('NoEMail').' : '.$assigned_user_dont_have_email; } foreach ($sendto as $val) { - $message .= '
' . $langs->trans('TicketNotificationRecipient') . ' : ' . $val; + $message .= '
'.$langs->trans('TicketNotificationRecipient').' : '.$val; } // URL ticket - $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; + $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id; $message .= '

'; - $message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $object->track_id . ''; + $message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.''; $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); } @@ -2602,9 +2602,9 @@ class Ticket extends CommonObject // Coordonnées client $message .= '

'; $message .= "==============================================
"; - $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; - $message .= !empty($object->thirdparty->town) ? '
' . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; - $message .= !empty($object->thirdparty->phone) ? '
' . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; + $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : ''; + $message .= !empty($object->thirdparty->town) ? '
'.$langs->trans('Town')." : ".$object->thirdparty->town : ''; + $message .= !empty($object->thirdparty->phone) ? '
'.$langs->trans('Phone')." : ".$object->thirdparty->phone : ''; // Build array to display recipient list foreach ($internal_contacts as $key => $info_sendto) { @@ -2614,19 +2614,19 @@ class Ticket extends CommonObject } if ($info_sendto['email'] != '') { - if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; //Contact type - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . '
' : ''); + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'
' : ''); } } $message .= '
'; // URL ticket - $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; + $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id; // altairis: make html link on url - $message .= '
' . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $object->track_id . '
'; + $message .= '
'.$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.'
'; // Add global email address recipient if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { @@ -2688,23 +2688,23 @@ class Ticket extends CommonObject } if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { - if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . '
' : ''); + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'
' : ''); } } // If public interface is not enable, use link to internal page into mail $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)) . '?track_id=' . $object->track_id; - $message .= '
' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $object->track_id . '
'; + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)).'?track_id='.$object->track_id; + $message .= '
'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$object->track_id.'
'; // Build final message - $message = $message_intro . '

' . $message; + $message = $message_intro.'

'.$message; // Add signature - $message .= '
' . $message_signature; + $message .= '
'.$message_signature; if (!empty($object->origin_email)) { $sendto[] = $object->origin_email; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 184216ea47e..c4c1cbadcc9 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -100,9 +100,9 @@ foreach ($object->fields as $key => $val) { if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } -$fieldstosearchall['s.name_alias']="AliasNameShort"; -$fieldstosearchall['s.zip']="Zip"; -$fieldstosearchall['s.town']="Town"; +$fieldstosearchall['s.name_alias'] = "AliasNameShort"; +$fieldstosearchall['s.zip'] = "Zip"; +$fieldstosearchall['s.town'] = "Town"; // Definition of fields for list $arrayfields = array(); @@ -755,13 +755,13 @@ while ($i < min($num, $limit)) print '>'; if ($key == 'fk_statut') print $object->getLibStatut(5); elseif ($key == 'type_code') { - $s = $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); + $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print ''; print $s; print ''; } - elseif ($key == 'category_code') print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); - elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); + elseif ($key == 'category_code') print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); + elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); elseif ($key == 'fk_user_create') { if ($object->fk_user_create > 0) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f6a3862d0bb..1dfd090eb5c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3233,9 +3233,9 @@ class User extends CommonObject } return $num; } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } + $this->errors[] = $this->db->lasterror(); + return -1; + } } /** diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index d8d6c74f00b..b22dafce758 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -303,7 +303,7 @@ if ($object->id > 0) print ' '; // Module id - if ($user->admin) print ''. $objMod->numero.''; + if ($user->admin) print ''.$objMod->numero.''; print ''; } diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 4b99cfb7e18..f87785da31f 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -365,7 +365,7 @@ if ($result) print ' '; // Module Id - if ($user->admin) print ''. $objMod->numero.''; + if ($user->admin) print ''.$objMod->numero.''; print ''."\n"; } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 52884afc875..f1b10559898 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -165,11 +165,11 @@ class ProductCombination /** * for auto retrocompatibility with last behavior */ - if ($fk_price_level>0){ + if ($fk_price_level > 0) { $combination_price_levels[$fk_price_level] = ProductCombinationLevel::createFromParent($this->db, $this, $fk_price_level); } else { - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $combination_price_levels[$i] = ProductCombinationLevel::createFromParent($this->db, $this, $i); } } @@ -783,16 +783,16 @@ class ProductCombination $newcomb->variation_weight = $weight_impact; // Init price level - if ($conf->global->PRODUIT_MULTIPRICES){ - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++){ + if ($conf->global->PRODUIT_MULTIPRICES) { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $productCombinationLevel = new ProductCombinationLevel($this->db); $productCombinationLevel->fk_product_attribute_combination = $newcomb->id; $productCombinationLevel->fk_price_level = $i; $productCombinationLevel->variation_price = $price_impact[$i]; - if (is_array($price_var_percent)){ + if (is_array($price_var_percent)) { $productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]); - }else { + } else { $productCombinationLevel->variation_price_percentage = $price_var_percent; } From ef0078cbb2a76197723bd647eb99d822b8b99b7f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Sep 2020 19:29:01 +0000 Subject: [PATCH 043/173] Fixing style errors. --- htdocs/debugbar/class/autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php index 721febdd13c..91606babb84 100644 --- a/htdocs/debugbar/class/autoloader.php +++ b/htdocs/debugbar/class/autoloader.php @@ -4,7 +4,7 @@ * Simple autoloader, so we don't need Composer just for this. */ -spl_autoload_register(function($class) { +spl_autoload_register(function ($class) { if (preg_match('/^DebugBar/', $class)) { $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; //var_dump($class.' - '.file_exists($file).' - '.$file); From 49d009502c0749f8fec26e04bf23dc19b5672996 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 9 Sep 2020 08:16:26 +0200 Subject: [PATCH 044/173] fix sticker CI --- htdocs/core/lib/functions.lib.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2bc5d8eea53..144a420a542 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8694,46 +8694,35 @@ function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows print $langs->trans($header); - if ($number > -1) - { - // extra space between the first header and the number + // extra space between the first header and the number + if ($number > -1) { print ' '; } - if (!empty($link)) - { - if (!empty($arguments)) - { + if (!empty($link)) { + if (!empty($arguments)) { print ''; - } - else - { + } else { print ''; } } - if ($number > -1) - { + if ($number > -1) { print ''.$number.''; } - if (!empty($link)) - { + if (!empty($link)) { print ''; } print ''; - if ($number < 0 && !empty($link)) - { + if ($number < 0 && !empty($link)) { print ''; - if (!empty($arguments)) - { + if (!empty($arguments)) { print ''; - } - else - { + } else { print ''; } From 37141b577a6b1508a607ec8368ddba7b981269d3 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 9 Sep 2020 08:34:13 +0200 Subject: [PATCH 045/173] fix sticker CI, better names, add missing comapres --- htdocs/admin/system/modules.php | 168 ++++++++++++++++---------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 7181b35f858..1b482e13238 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -25,8 +25,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("install", "other", "admin")); @@ -68,8 +69,7 @@ $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'); -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; } @@ -83,30 +83,23 @@ $modules_fullpath = array(); $modulesdir = dolGetModulesDirs(); $rights_ids = array(); -foreach ($modulesdir as $dir) -{ +foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { + if ($modName) { //print 'xx'.$dir.$file.'
'; - if (in_array($file, $modules_files)) - { + if (in_array($file, $modules_files)) { // File duplicate print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")
"; } else { // File to load $res = include_once $dir.$file; - if (class_exists($modName)) - { + if (class_exists($modName)) { try { $objMod = new $modName($db); @@ -114,8 +107,7 @@ foreach ($modulesdir as $dir) $modules_files[$objMod->numero] = $file; $modules_fullpath[$file] = $dir.$file; } - catch (Exception $e) - { + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } } @@ -131,8 +123,7 @@ foreach ($modulesdir as $dir) } // create pre-filtered list for modules -foreach ($modules as $key=>$module) -{ +foreach ($modules as $key=>$module) { $newModule = new stdClass(); $newModule->name = $module->getName(); @@ -141,8 +132,7 @@ foreach ($modules as $key=>$module) $alt = $module->name.' - '.$modules_files[$key]; - if (!empty($module->picto)) - { + if (!empty($module->picto)) { if (preg_match('/^\//', $module->picto)) $newModule->picto = img_picto($alt, $module->picto, 'width="14px"', 1); else $newModule->picto = img_object($alt, $module->picto, 'width="14px"'); } @@ -151,12 +141,9 @@ foreach ($modules as $key=>$module) } $permission = array(); - if ($module->rights) - { - foreach ($module->rights as $rights) - { - if (empty($rights[0])) - { + if ($module->rights) { + foreach ($module->rights as $rights) { + if (empty($rights[0])) { continue; } @@ -173,14 +160,11 @@ foreach ($modules as $key=>$module) if ($search_version && !stristr($newModule->version, $search_version)) continue; if ($search_id && !stristr($newModule->id, $search_id)) continue; - if ($search_permission) - { + if ($search_permission) { $found = false; - foreach ($newModule->permission as $permission) - { - if (stristr($permission, $search_permission)) - { + foreach ($newModule->permission as $permission) { + if (stristr($permission, $search_permission)) { $found = true; break; } @@ -224,26 +208,22 @@ print ''; // Lines with input filters print ''; -if ($arrayfields['name']['checked']) -{ +if ($arrayfields['name']['checked']) { print ''; } -if ($arrayfields['version']['checked']) -{ +if ($arrayfields['version']['checked']) { print ''; } -if ($arrayfields['id']['checked']) -{ +if ($arrayfields['id']['checked']) { print ''; } -if ($arrayfields['permission']['checked']) -{ +if ($arrayfields['permission']['checked']) { print ''; @@ -258,20 +238,16 @@ print ''; print ''; -if ($arrayfields['name']['checked']) -{ +if ($arrayfields['name']['checked']) { print_liste_field_titre($arrayfields['name']['label'], $_SERVER["PHP_SELF"], "name", "", "", "", $sortfield, $sortorder); } -if ($arrayfields['version']['checked']) -{ +if ($arrayfields['version']['checked']) { print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder); } -if ($arrayfields['id']['checked']) -{ +if ($arrayfields['id']['checked']) { print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder); } -if ($arrayfields['permission']['checked']) -{ +if ($arrayfields['permission']['checked']) { print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder); } @@ -292,43 +268,37 @@ if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function return strcasecmp($a->version, $b->version); }); if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); -if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "sortIdAsc"); -if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "sortIdDesc"); -if ($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "sortPermissionIdsAsc"); -if ($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "sortPermissionIdsDesc"); +if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); +if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); +if ($sortfield == "permission" && $sortorder == "asc") usort($moduleList, "comparePermissionIdsAsc"); +if ($sortfield == "permission" && $sortorder == "desc") usort($moduleList, "comparePermissionIdsDesc"); -foreach ($moduleList as $module) -{ +foreach ($moduleList as $module) { print ''; - if ($arrayfields['name']['checked']) - { + if ($arrayfields['name']['checked']) { print '"; } - if ($arrayfields['version']['checked']) - { + if ($arrayfields['version']['checked']) { print ''; } - if ($arrayfields['id']['checked']) - { + if ($arrayfields['id']['checked']) { print ''; } - if ($arrayfields['permission']['checked']) - { + if ($arrayfields['permission']['checked']) { $idperms = ''; - foreach ($module->permission as $permission) - { - $idperms .= ($idperms ? ", " : "").$permission; + foreach ($module->permission as $permission) { + $idperms .= ($idperms ? ", " : "").$permission; $translationKey = "Permission".$permission; - if (empty($langs->tab_translate[$translationKey])) - { + + if (empty($langs->tab_translate[$translationKey])) { $tooltip = 'Missing translation (key '.$translation.' not found in admin.lang)'; $idperms .= ' Warning'; } @@ -349,10 +319,8 @@ print '
'; sort($rights_ids); $old = ''; -foreach ($rights_ids as $right_id) -{ - if ($old == $right_id) - { +foreach ($rights_ids as $right_id) { + if ($old == $right_id) { print "Warning duplicate id on permission : ".$right_id."
"; } @@ -364,36 +332,68 @@ llxFooter(); $db->close(); -/* - * user-defined sort functions - */ - -function sortIdAsc(stdClass $a, stdClass $b) + /** + * Compare two modules by their ID for a ascending order + * + * @param stdClass $a First module + * @param stdClass $b Second module + * @return int Compare result (-1, 0, 1) + */ +function compareIdAsc(stdClass $a, stdClass $b) { + if ($a->id == $b->id) return 0; + return $a->id > $b->id ? -1 : 1; } -function sortIdDesc(stdClass $a, stdClass $b) + /** + * Compare two modules by their ID for a descending order + * + * @param stdClass $a First module + * @param stdClass $b Second module + * @return int Compare result (-1, 0, 1) + */ +function compareIdDesc(stdClass $a, stdClass $b) { + if ($a->id == $b->id) return 0; + return $b->id > $a->id ? -1 : 1; } -function sortPermissionIdsAsc(stdClass $a, stdClass $b) + /** + * Compare two modules by their ID for a ascending order + * + * @param stdClass $a First module + * @param stdClass $b Second module + * @return int Compare result (-1, 0, 1) + */ +function comparePermissionIdsAsc(stdClass $a, stdClass $b) { - if (empty($a->permission) && empty($b->permission)) return sortIdAsc($a, $b); + if (empty($a->permission) && empty($b->permission)) return compareIdAsc($a, $b); if (empty($a->permission)) return 1; if (empty($b->permission)) return -1; + if ($a->permission[0] == $b->permission[0]) return 0; + return $a->permission[0] > $b->permission[0] ? -1 : 1; } -function sortPermissionIdsDesc(stdClass $a, stdClass $b) + /** + * Compare two modules by their permissions for a descending order + * + * @param stdClass $a First module + * @param stdClass $b Second module + * @return int Compare result (-1, 0, 1) + */ +function comparePermissionIdsDesc(stdClass $a, stdClass $b) { - if (empty($a->permission) && empty($b->permission)) return sortIdDesc($a, $b); + if (empty($a->permission) && empty($b->permission)) return compareIdDesc($a, $b); if (empty($a->permission)) return -1; if (empty($b->permission)) return 1; + if ($a->permission[0] == $b->permission[0]) return 0; + return $a->permission[0] > $b->permission[0] ? 1 : -1; } From f08c91fcc6c7c603b05c1ff6b7b4a17270d4635d Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Wed, 9 Sep 2020 09:14:02 +0100 Subject: [PATCH 046/173] fix: replace values of __YEAR__, __MONTH__ and __DAY__ in member docs --- htdocs/core/modules/member/doc/pdf_standard.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 0051862d52e..bcab63940c0 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -267,9 +267,9 @@ class pdf_standard extends CommonStickerGenerator '__EMAIL__'=>$object->email, '__BIRTH__'=>dol_print_date($object->birth, 'day'), '__TYPE__'=>$object->type, - '__YEAR__'=>$year, - '__MONTH__'=>$month, - '__DAY__'=>$day, + '__YEAR__'=>date('Y', dol_now()), + '__MONTH__'=>date('m', dol_now()), + '__DAY__'=>date('d', dol_now()), '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" ); From 870443a09980f8be3e75edf76951c8594c093ebb Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 9 Sep 2020 11:34:47 +0200 Subject: [PATCH 047/173] Add selectable columns for extra payments --- htdocs/compta/bank/various_payment/list.php | 371 ++++++++++++++------ 1 file changed, 257 insertions(+), 114 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 09193b3ee91..9cda90f02b7 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "banks", "bills", "accountancy")); @@ -44,11 +46,14 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); $search_user = GETPOST('search_user', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); -$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_datep_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_datep_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_datev_start = dol_mktime(0, 0, 0, GETPOST('search_date_value_startmonth', 'int'), GETPOST('search_date_value_startday', 'int'), GETPOST('search_date_value_startyear', 'int')); +$search_datev_end = dol_mktime(23, 59, 59, GETPOST('search_date_value_endmonth', 'int'), GETPOST('search_date_value_endday', 'int'), GETPOST('search_date_value_endyear', 'int')); $search_amount_deb = GETPOST('search_amount_deb', 'alpha'); $search_amount_cred = GETPOST('search_amount_cred', 'alpha'); -$search_account = GETPOST('search_account', 'int'); +$search_bank_account = GETPOST('search_account', 'int'); +$search_bank_entry = GETPOST('search_bank_entry', 'int'); $search_accountancy_account = GETPOST("search_accountancy_account"); if ($search_accountancy_account == - 1) $search_accountancy_account = ''; $search_accountancy_subledger = GETPOST("search_accountancy_subledger"); @@ -81,18 +86,51 @@ if (!GETPOST('typeid')) if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref = ""; - $search_label = ""; - $search_date_start = ''; - $search_date_end = ''; - $search_amount_deb = ""; - $search_amount_cred = ""; - $search_account = ''; + $search_ref = ''; + $search_label = ''; + $search_datep_start = ''; + $search_datep_end = ''; + $search_datev_start = ''; + $search_datev_end = ''; + $search_amount_deb = ''; + $search_amount_cred = ''; + $search_bank_account = ''; + $search_bank_entry = ''; $search_accountancy_account = ''; $search_accountancy_subledger = ''; - $typeid = ""; + $typeid = ''; } +// Definition of fields for lists +$arrayfields = array( + 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), + 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), + 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), + 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), + 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), + 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), + 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), + 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), + 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), + 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)), + 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), + 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), +); + +$arrayfields = dol_sort_array($arrayfields, 'position'); + +/* + * Actions + */ + +$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'); + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +} /* * View @@ -101,11 +139,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' llxHeader(); $form = new Form($db); -$formaccounting = new FormAccounting($db); -$variousstatic = new PaymentVarious($db); -$accountstatic = new Account($db); +if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); +if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); +if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db); +if ($arrayfields['bank']['checked']) $accountstatic = new Account($db); +if ($arrayfields['project']['checked']) $proj = new Project($db); +if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); +if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db); -$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account,"; +$sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; $sql .= " pst.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; @@ -117,11 +159,14 @@ $sql .= " WHERE v.entity IN (".getEntity('payment_various').")"; // Search criteria if ($search_ref) $sql .= " AND v.rowid=".$db->escape($search_ref); if ($search_label) $sql .= natural_search(array('v.label'), $search_label); -if ($search_date_start) $sql .= " AND v.datep >= '".$db->idate($search_date_start)."'"; -if ($search_date_end) $sql .= " AND v.datep <= '".$db->idate($search_date_end)."'"; +if ($search_datep_start) $sql .= " AND v.datep >= '".$db->idate($search_datep_start)."'"; +if ($search_datep_end) $sql .= " AND v.datep <= '".$db->idate($search_datep_end)."'"; +if ($search_datev_start) $sql .= " AND v.datev >= '".$db->idate($search_datev_start)."'"; +if ($search_datev_end) $sql .= " AND v.datev <= '".$db->idate($search_datev_end)."'"; if ($search_amount_deb) $sql .= natural_search("v.amount", $search_amount_deb, 1); if ($search_amount_cred) $sql .= natural_search("v.amount", $search_amount_cred, 1); -if ($search_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_account); +if ($search_bank_account > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account); +if ($search_bank_entry > 0) $sql .= " AND b.fk_account=".$db->escape($search_bank_account); if ($search_accountancy_account > 0) $sql .= " AND v.accountancy_code=".$db->escape($search_accountancy_account); if ($search_accountancy_subledger > 0) $sql .= " AND v.subledger_account=".$db->escape($search_accountancy_subledger); if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid; @@ -154,10 +199,10 @@ if ($result) if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); - if ($typeid > 0) $param .= '&typeid='.urlencode($typeid); - if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb); - if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred); - if ($search_account > 0) $param .= '&search_amount='.urlencode($search_account); + if ($typeid > 0) $param .= '&typeid='.urlencode($typeid); + if ($search_amount_deb) $param .= '&search_amount_deb='.urlencode($search_amount_deb); + if ($search_amount_cred) $param .= '&search_amount_cred='.urlencode($search_amount_cred); + if ($search_bank_account > 0) $param .= '&search_amount='.urlencode($search_bank_account); if ($search_accountancy_account > 0) $param .= '&search_accountancy_account='.urlencode($search_accountancy_account); if ($search_accountancy_subledger > 0) $param .= '&search_accountancy_subledger='.urlencode($search_accountancy_subledger); @@ -170,66 +215,111 @@ if ($result) } print '
'; - + if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; - + print ''; + print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + print '
'; - print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print $module->picto; print ' '.$module->name; print "'.$module->version.''.$module->id.'
'."\n"; + print '
'; print ''; - // Ref - print ''; - - // Label - print ''; - - // Date - print ''; - - // Type - print ''; - - // Account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; } + // Ref + if ($arrayfields['ref']['checked']) { + print ''; + } + + // Label + if ($arrayfields['label']['checked']) { + print ''; + } + + // Payment date + if ($arrayfields['datep']['checked']) { + print ''; + } + + // Value date + if ($arrayfields['datev']['checked']) { + print ''; + } + + // Payment type + if ($arrayfields['type']['checked']) { + print ''; + } + + // Project + if ($arrayfields['project']['checked']) { + print ''; + } + + // Bank account + if ($arrayfields['bank']['checked']) { + print ''; + } + + // Bank entry + if ($arrayfields['entry']['checked']) { + print ''; + } + // Accounting account - if (!empty($conf->accounting->enabled)) - { - // Accounting account + if ($arrayfields['account']['checked']) { print ''; + } - // Subledger account + // Subledger account + if ($arrayfields['subledger']['checked']) { print ''; + if ($arrayfields['debit']['checked']) { + print ''; + } // Credit - print ''; + if ($arrayfields['credit']['checked']) { + print ''; + } print ''; - print "\n"; - + print ''; print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "v.rowid", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "v.label", "", $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "v.datep,v.rowid", "", $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left '); - if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - if (!empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccountingShort", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, '', $sortfield, $sortorder, 'left '); - if (!empty($conf->accounting->enabled)) print_liste_field_titre("SubledgerAccount", $_SERVER["PHP_SELF"], "v.subledger_account", "", $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; + + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + + if ($arrayfields['ref']['checked']) print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], 'v.rowid', '', $param, '', $sortfield, $sortorder); + if ($arrayfields['label']['checked']) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], 'v.label', '', $param, '', $sortfield, $sortorder, 'left '); + if ($arrayfields['datep']['checked']) print_liste_field_titre($arrayfields['datep']['label'], $_SERVER["PHP_SELF"], 'v.datep,v.rowid', '', $param, '', $sortfield, $sortorder, 'center '); + if ($arrayfields['datev']['checked']) print_liste_field_titre($arrayfields['datev']['label'], $_SERVER["PHP_SELF"], 'v.datev,v.rowid', '', $param, '', $sortfield, $sortorder, 'center '); + if ($arrayfields['type']['checked']) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], 'type', '', $param, '', $sortfield, $sortorder, 'left '); + if ($arrayfields['project']['checked']) print_liste_field_titre($arrayfields['project']['label'], $_SERVER["PHP_SELF"], 'fk_project', '', $param, '', $sortfield, $sortorder); + if ($arrayfields['bank']['checked']) print_liste_field_titre($arrayfields['bank']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); + if ($arrayfields['entry']['checked']) print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); + if ($arrayfields['account']['checked']) print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left '); + if ($arrayfields['subledger']['checked']) print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left '); + if ($arrayfields['debit']['checked']) print_liste_field_titre($arrayfields['debit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right '); + if ($arrayfields['credit']['checked']) print_liste_field_titre($arrayfields['credit']['label'], $_SERVER["PHP_SELF"], 'v.amount', '', $param, '', $sortfield, $sortorder, 'right '); + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print ''; $totalarray = array(); @@ -272,28 +381,53 @@ if ($result) print ''; - $variousstatic->id = $obj->rowid; - $variousstatic->ref = $obj->rowid; - + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + } + // Ref - print "\n"; - if (!$i) $totalarray['nbfield']++; + if ($arrayfields['ref']['checked']) { + $variousstatic->id = $obj->rowid; + $variousstatic->ref = $obj->rowid; + print ""; + if (!$i) $totalarray['nbfield']++; + } // Label payment - print "\n"; - if (!$i) $totalarray['nbfield']++; + if ($arrayfields['label']['checked']) { + print ""; + if (!$i) $totalarray['nbfield']++; + } // Date payment - print '\n"; - if (!$i) $totalarray['nbfield']++; + if ($arrayfields['datep']['checked']) { + print '"; + if (!$i) $totalarray['nbfield']++; + } + + + // Date value + if ($arrayfields['datev']['checked']) { + print '"; + if (!$i) $totalarray['nbfield']++; + } // Type - print ''; - if (!$i) $totalarray['nbfield']++; + if ($arrayfields['type']['checked']) { + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Account - if (!empty($conf->banque->enabled)) - { + // Project + if ($arrayfields['project']['checked']) { + $proj->fetch($obj->fk_project); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Bank account + if ($arrayfields['bank']['checked']) { print ''; - if (!$i) $totalarray['nbfield']++; + } else { + print ' '; + print ''; + if (!$i) $totalarray['nbfield']++; + } + } + + // Bank entry + if ($arrayfields['entry']['checked']) { + $bankline->fetch($obj->fk_bank); + print ''; } // Accounting account - if (!empty($conf->accounting->enabled)) { - $accountingaccount = new AccountingAccount($db); + if ($arrayfields['account']['checked']) { $accountingaccount->fetch('', $obj->accountancy_code, 1); print ''; @@ -326,38 +465,42 @@ if ($result) } // Accounting subledger account - if (!empty($conf->accounting->enabled)) - { + if ($arrayfields['subledger']['checked']) { print ''; if (!$i) $totalarray['nbfield']++; } // Debit - print ''; } - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; - print ''; // Credit - print ''; } - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; - print ''; + print ''; if (!$i) $totalarray['nbfield']++; - print "\n"; + print ""; $i++; } From 32d77cc143acf81463d77b4c95040066ac60096d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 9 Sep 2020 09:46:46 +0000 Subject: [PATCH 048/173] Fixing style errors. --- htdocs/compta/bank/various_payment/list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9cda90f02b7..67e39b069ab 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -215,7 +215,7 @@ if ($result) } print ''; - + if ($optioncss != '') print ''; print ''; print ''; @@ -223,7 +223,7 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; @@ -292,21 +292,21 @@ if ($result) if ($arrayfields['project']['checked']) { print ''; + print ''; } // Bank account if ($arrayfields['bank']['checked']) { print ''; + print ''; } // Bank entry if ($arrayfields['entry']['checked']) { print ''; + print ''; } // Accounting account @@ -385,7 +385,7 @@ if ($result) if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; } - + // Ref if ($arrayfields['ref']['checked']) { $variousstatic->id = $obj->rowid; @@ -406,7 +406,7 @@ if ($result) if (!$i) $totalarray['nbfield']++; } - + // Date value if ($arrayfields['datev']['checked']) { print '"; From 059624e9366f0832f25ec73496d426617bf4263a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 9 Sep 2020 11:46:56 +0200 Subject: [PATCH 049/173] NEW edit and update a ticket --- htdocs/ticket/card.php | 132 ++++++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 36 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 6c7a1278c99..0cb1673fa81 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -268,53 +268,55 @@ if (empty($reshook)) { } } - if ($action == 'edit' && $user->rights->ticket->write) { + if ($action == 'update' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { $error = 0; - if ($object->fetch(GETPOST('id', 'int')) < 0) { - $error++; - array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); - $_GET["action"] = $_POST["action"] = ''; - } - } - - if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) { - $error = 0; - - $ret = $object->fetch(GETPOST('id', 'int')); + $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha')); if ($ret < 0) { $error++; - array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); - $action = ''; - } elseif (!GETPOST("label")) { - $error++; - array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"))); - $action = 'edit'; - } elseif (!GETPOST("subject", 'alphanohtml')) { - $error++; - array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); - $action = 'edit'; + array_push($object->errors, $langs->trans('ErrorTicketIsNotValid')); + } + + // check fields + if (!$error) { + if (!GETPOST('subject' , 'alpha')) { + $error++; + array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); + } + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; } if (!$error) { $db->begin(); - $object->label = GETPOST("label", 'alphanohtml'); - $object->description = GETPOST("description", 'restricthtml'); + $object->subject = GETPOST('subject', 'alpha'); + $object->type_code = GETPOST('type_code', 'alpha'); + $object->category_code = GETPOST('category_code', 'alpha'); + $object->severity_code = GETPOST('severity_code', 'alpha'); - //... $ret = $object->update($user); - if ($ret <= 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; + if ($ret <= 0) $error++; + + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } else { + if (!empty($backtopage)) { + $url = $backtopage; + } else { + $url = 'card.php?track_id=' . $object->track_id; } - if (!$error && $ret > 0) { - $db->commit(); - } else { - $db->rollback(); - } + header('Location: ' . $url); + exit(); } } @@ -650,9 +652,63 @@ if ($action == 'create' || $action == 'presend') } $formticket->showForm(1, 'create'); -} +} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { + $formticket = new FormTicket($db); -if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' + $head = ticket_prepare_head($object); + + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'card', $langs->trans('ticket'), 0, 'ticket'); + + print '
'; + print '
'; - print ''; - print ''; - print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1); - - print '
'; - print '
'; - $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); - print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans('From').' '; + print $form->selectDate($search_datep_start ? $search_datep_start : -1, 'search_date_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to').' '; + print $form->selectDate($search_datep_end ? $search_datep_end : -1, 'search_date_end', 0, 0, 1); + print '
'; + print '
'; + print '
'; + print $langs->trans('From').' '; + print $form->selectDate($search_datev_start ? $search_datev_start : -1, 'search_date_value_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to').' '; + print $form->selectDate($search_datev_end ? $search_datev_end : -1, 'search_date_value_end', 0, 0, 1); + print '
'; + print '
'; + $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); + print ''; + // TODO + print ''; + $form->select_comptes($search_bank_account, 'search_account', 0, '', 1); + print ''; + print ''; + print ''; print '
'; print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200'); print '
'; print '
'; print '
'; print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200'); @@ -238,31 +328,50 @@ if ($result) } // Debit - print '
'; + print ''; + print ''; + print ''; + print ''; $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.(($offset * $limit) + $i).'".$variousstatic->getNomUrl(1)."".$variousstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($obj->datep, 'day')."'.dol_print_date($obj->datev, 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.$proj->getNomUrl(1).''; if ($obj->bid > 0) { @@ -303,22 +437,27 @@ if ($result) if (!empty($conf->accounting->enabled)) { $accountstatic->account_number = $obj->bank_account_number; - - $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($obj->accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } else print ' '; - print ''.$bankline->getNomUrl(1).''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.length_accounta($obj->subledger_account).''; - if ($obj->sens == 0) - { - print price($obj->amount); - $totalarray['val']['total_deb'] += $obj->amount; + if ($arrayfields['debit']['checked']) { + print ''; + if ($obj->sens == 0) + { + print price($obj->amount); + $totalarray['val']['total_deb'] += $obj->amount; + } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; + print ''; - if ($obj->sens == 1) - { - print price($obj->amount); - $totalarray['val']['total_cred'] += $obj->amount; + if ($arrayfields['credit']['checked']) { + print ''; + if ($obj->sens == 1) + { + print price($obj->amount); + $totalarray['val']['total_cred'] += $obj->amount; + } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; + print '
'; // TODO - print ''; $form->select_comptes($search_bank_account, 'search_account', 0, '', 1); - print ''; print ''; - print ''.(($offset * $limit) + $i).''.dol_print_date($obj->datev, 'day')."
'; + + // Type + print ''; + + // Severity + print ''; + + // Group + print ''; + + // Subject + print ''; + + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { + print $object->showOptionals($extrafields, 'edit'); + } + + print '
'; + $formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); + print '
'; + $formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); + print '
'; + $formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); + print '
'; + print ''; + print '
'; + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; +} +elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { if ($res > 0) @@ -1193,6 +1249,10 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print '
'; } + if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { + print ''; + } + // Close ticket if statut is read if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { print ''; From be2fa82396ec650572819981c23c50c8ec91e3bc Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 9 Sep 2020 11:54:50 +0200 Subject: [PATCH 050/173] FIX stickler error comma in argument list --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 0cb1673fa81..ba1edf1e11a 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -279,7 +279,7 @@ if (empty($reshook)) { // check fields if (!$error) { - if (!GETPOST('subject' , 'alpha')) { + if (!GETPOST('subject', 'alpha')) { $error++; array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); } From 0c5bf5012e16da29dd4f722c7826d0a9289bb31f Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 9 Sep 2020 12:09:17 +0200 Subject: [PATCH 051/173] NEW Ticket title --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ba1edf1e11a..ea27fc98f44 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -662,7 +662,7 @@ if ($action == 'create' || $action == 'presend') print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans('ticket'), 0, 'ticket'); + dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); print '
'; print ''; From 05912b3b559a329984d739410e786ed2c1c8918c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 12:50:07 +0200 Subject: [PATCH 052/173] Fix sql error --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 20f705a8ed9..b6ce513e8c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5160,7 +5160,7 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql .= " description='".$this->db->escape($this->desc)."'"; - $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; + $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", remise_percent=".price2num($this->remise_percent).""; From 8fa001d98da9171669872e4ad6772c1289fae699 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Wed, 9 Sep 2020 13:27:41 +0200 Subject: [PATCH 053/173] Fix to short summary line --- htdocs/compta/bank/various_payment/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9cda90f02b7..8918d7cdf5f 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -454,6 +454,7 @@ if ($result) if ($arrayfields['entry']['checked']) { $bankline->fetch($obj->fk_bank); print ''; + if (!$i) $totalarray['nbfield']++; } // Accounting account From 1d894f4b7c2caf767909ddc0250407d9f957fd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Wed, 9 Sep 2020 13:38:42 +0200 Subject: [PATCH 054/173] FIX ref_ext for invoice lines from API Add and update ref_ext in invoice lines --- htdocs/compta/facture/class/api_invoices.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index c1ed5b809da..53603415d7f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -415,7 +415,9 @@ class Invoices extends DolibarrApi $request_data->array_options, $request_data->situation_percent, $request_data->fk_unit, - $request_data->multicurrency_subprice + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext ); if ($updateRes > 0) { @@ -704,7 +706,9 @@ class Invoices extends DolibarrApi $request_data->array_options, $request_data->situation_percent, $request_data->fk_prev_id, - $request_data->fk_unit + $request_data->fk_unit, + 0, + $request_data->ref_ext ); if ($updateRes < 0) { From 5c34b26f39b691debc92c947aa52118b2ad185d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 13:57:35 +0200 Subject: [PATCH 055/173] FIX Look and feel v12: First tab must be name of object --- htdocs/core/lib/fourn.lib.php | 4 ++-- htdocs/core/lib/invoice.lib.php | 2 +- htdocs/core/lib/order.lib.php | 2 +- htdocs/core/lib/project.lib.php | 2 +- htdocs/core/lib/propal.lib.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 201d74a9ff9..8b0e71a2a46 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -39,7 +39,7 @@ function facturefourn_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Card'); + $head[$h][1] = $langs->trans('SupplierInvoice'); $head[$h][2] = 'card'; $h++; @@ -129,7 +129,7 @@ function ordersupplier_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("OrderCard"); + $head[$h][1] = $langs->trans("SupplierOrder"); $head[$h][2] = 'card'; $h++; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 077176c6ff9..cbaf97611fd 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -41,7 +41,7 @@ function facture_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Card'); + $head[$h][1] = $langs->trans('CustomerInvoice'); $head[$h][2] = 'compta'; $h++; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 96d66c3272a..939b731f135 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -43,7 +43,7 @@ function commande_prepare_head(Commande $object) if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("OrderCard"); + $head[$h][1] = $langs->trans("CustomerOrder"); $head[$h][2] = 'order'; $h++; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index b451d2f4939..ac8530b4aa5 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -168,7 +168,7 @@ function task_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); - $head[$h][1] = $langs->trans("Project"); + $head[$h][1] = $langs->trans("Task"); $head[$h][2] = 'task_task'; $h++; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index fcdf4bbb79d..a1dab5cd6cb 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -38,7 +38,7 @@ function propal_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; - $head[$h][1] = $langs->trans('ProposalCard'); + $head[$h][1] = $langs->trans('Proposal'); $head[$h][2] = 'comm'; $h++; From 097c5ffaf5a9333ff4dddf251bfe8fe402cc993a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 14:41:04 +0200 Subject: [PATCH 056/173] Test --- test/phpunit/FilesLibTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index e8bbc664619..669f739646e 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -1,4 +1,6 @@ * Copyright (C) 2012 Regis Houssin * @@ -359,14 +361,17 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $this->assertTrue($result, 'move with default mask'); // To test a move that should work with forced mask - $result=dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file shoutld be rwxr-wr-- + $result=dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file should be rwxr-wr-- print __METHOD__." result=".$result."\n"; $this->assertTrue($result, 'move with forced mask'); + $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; + $conf->logbuffer=array(); + // To test a delete that should success $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv'); - print __METHOD__." result=".$result."\n"; - $this->assertTrue($result, 'delete file'); + print __METHOD__." result delete=".var_export($result, true)."\n"; + $this->assertTrue($result, 'delete file '.join("\n", $conf->logbuffer)); // Again to test there is error when deleting a non existing file with option disableglob $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1); From 229aa14a9731b5543b767f807e9b8d6ae296a85a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 14:43:24 +0200 Subject: [PATCH 057/173] Update pdf_standard.class.php --- htdocs/core/modules/member/doc/pdf_standard.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index bcab63940c0..590bd72f5c5 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -251,6 +251,10 @@ class pdf_standard extends CommonStickerGenerator { if ($object->country == '-') $object->country = ''; + $year = date('Y', dol_now()) + $month = date('m', dol_now()) + $day = date('d', dol_now()) + // List of values to scan for a replacement $substitutionarray = array( '__ID__' => $object->id, @@ -267,9 +271,9 @@ class pdf_standard extends CommonStickerGenerator '__EMAIL__'=>$object->email, '__BIRTH__'=>dol_print_date($object->birth, 'day'), '__TYPE__'=>$object->type, - '__YEAR__'=>date('Y', dol_now()), - '__MONTH__'=>date('m', dol_now()), - '__DAY__'=>date('d', dol_now()), + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" ); From 4b783d203e58a52a4f3a8c6fa3a172fc3aa93767 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 14:44:09 +0200 Subject: [PATCH 058/173] Update pdf_standard.class.php --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 590bd72f5c5..d6d60d7b149 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -271,7 +271,7 @@ class pdf_standard extends CommonStickerGenerator '__EMAIL__'=>$object->email, '__BIRTH__'=>dol_print_date($object->birth, 'day'), '__TYPE__'=>$object->type, - '__YEAR__'=>$year, + '__YEAR__'=>$year, '__MONTH__'=>$month, '__DAY__'=>$day, '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, From 221c54c16f4d8133358e03fafb8894abe7f276f7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 9 Sep 2020 12:46:25 +0000 Subject: [PATCH 059/173] Fixing style errors. --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index d6d60d7b149..37a9a924548 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -254,7 +254,7 @@ class pdf_standard extends CommonStickerGenerator $year = date('Y', dol_now()) $month = date('m', dol_now()) $day = date('d', dol_now()) - + // List of values to scan for a replacement $substitutionarray = array( '__ID__' => $object->id, From b99192bdb28e6a6f91ccf9e6a854db52785c02a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 14:46:42 +0200 Subject: [PATCH 060/173] Update pdf_standard.class.php --- htdocs/core/modules/member/doc/pdf_standard.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 37a9a924548..23e25c92590 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -251,10 +251,11 @@ class pdf_standard extends CommonStickerGenerator { if ($object->country == '-') $object->country = ''; - $year = date('Y', dol_now()) - $month = date('m', dol_now()) - $day = date('d', dol_now()) - + $now = dol_now(); + $year = dol_print_date($now, '%Y'); + $month = dol_print_date($now, '%m'); + $day = dol_print_date($now, '%d'); + // List of values to scan for a replacement $substitutionarray = array( '__ID__' => $object->id, From 230b6cdfd421b6ad165d10cf3626e6d7fffadca4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 15:14:52 +0200 Subject: [PATCH 061/173] Add method isLoaded($domain) --- htdocs/core/class/translate.class.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 549c82a9033..e711fc528a7 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -517,12 +517,21 @@ class Translate if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded - if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language) + if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Mark this case as not found (no lines found for language) return 1; } - + /** + * Get information with result of loading data for domain + * + * @param string $domain Domain to check + * @return int True if loaded + */ + public function isLoaded($domain) + { + return $this->_tab_loaded[$domain]; + } /** * Return translated value of key for special keys ("Currency...", "Civility...", ...). From 1c8e02df3b55d67954b03cb77ae0dc57abc5bfcf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 15:16:03 +0200 Subject: [PATCH 062/173] Doc --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index e711fc528a7..cf9683b4556 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -526,7 +526,7 @@ class Translate * Get information with result of loading data for domain * * @param string $domain Domain to check - * @return int True if loaded + * @return int 0, 1, 2... */ public function isLoaded($domain) { From 12fba9e6795e4ec5091bba6a4fdfebc77cb2cc69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 15:19:12 +0200 Subject: [PATCH 063/173] Fix label --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2396ecb808e..e0a2d278654 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3893,6 +3893,7 @@ abstract class CommonObject { // phpcs:enable $out = ''; + $this->label_incoterms = ''; if (!empty($this->fk_incoterms)) { @@ -3905,7 +3906,7 @@ abstract class CommonObject } } - $out .= (($res->code && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms; + $out .= (($out && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms; return $out; } From 803efa7acc4404f1325fabd90b9b3afa6becba98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 15:39:47 +0200 Subject: [PATCH 064/173] Add hidden constant until feature is reliable --- htdocs/admin/system/modules.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 1b482e13238..34b89e911f6 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -298,9 +298,11 @@ foreach ($moduleList as $module) { $idperms .= ($idperms ? ", " : "").$permission; $translationKey = "Permission".$permission; - if (empty($langs->tab_translate[$translationKey])) { - $tooltip = 'Missing translation (key '.$translation.' not found in admin.lang)'; - $idperms .= ' Warning'; + if (! empty($conf->global->MAIN_SHOW_PERMISSION)) { + if (empty($langs->tab_translate[$translationKey])) { + $tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)'; + $idperms .= ' Warning'; + } } } From 476cb642f4c38a2f5db29ad678fbfe4f125acb18 Mon Sep 17 00:00:00 2001 From: Romain DESCHAMPS Date: Wed, 9 Sep 2020 19:01:45 +0200 Subject: [PATCH 065/173] Fix ToSell/ToBuy tag in supplier products list #14691 --- htdocs/fourn/product/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 91cd3636bbe..53ef035c151 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -127,7 +127,7 @@ if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; +$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity, tosell, tobuy,"; $sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql .= " s.rowid as socid, s.nom as name"; // Add fields to SELECT from hooks @@ -296,6 +296,8 @@ if ($resql) $productstatic->ref = $objp->ref; $productstatic->type = $objp->fk_product_type; $productstatic->entity = $objp->entity; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; print $productstatic->getNomUrl(1, 'supplier'); print ''; From 177ec5eb391a68474ca75aa72aa39fe82f9d499f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 19:25:16 +0200 Subject: [PATCH 066/173] Fix mandatory field --- htdocs/install/mysql/tables/llx_product_attribute.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product_attribute.sql b/htdocs/install/mysql/tables/llx_product_attribute.sql index c81d122d9bb..362c104b95c 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute.sql @@ -23,7 +23,7 @@ CREATE TABLE llx_product_attribute ( rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, ref VARCHAR(255) NOT NULL, - ref_ext VARCHAR(255) NOT NULL, + ref_ext VARCHAR(255) NULL, label VARCHAR(255) NOT NULL, rang INT DEFAULT 0 NOT NULL, entity INT DEFAULT 1 NOT NULL From 069242e7bce0da97bb96be7023ac27970d7e10ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 9 Sep 2020 19:38:48 +0200 Subject: [PATCH 067/173] Update index.php --- htdocs/expedition/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index e2742f078bb..6f21683cc69 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -204,10 +204,10 @@ if ($resql) print ''; $i++; } - print "
'.$bankline->getNomUrl(1).'

"; } else { print ''.$langs->trans("None").''; } + print "

"; $db->free($resql); } else dol_print_error($db); From e322bc5194b63993377e6e3adab545f4eb97a19b Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Thu, 10 Sep 2020 00:05:52 +0100 Subject: [PATCH 068/173] fix: name mismatch --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 439854229e0..c3c14171386 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1738,7 +1738,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $genallowed = $user->rights->adherent->lire; $delallowed = $user->rights->adherent->creer; - print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); + print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; // Show links to link elements From b8fe2188a66aa3535e804ae832ad2e9a2352e34b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 01:49:09 +0200 Subject: [PATCH 069/173] Standardize code around model_pdf --- htdocs/adherents/card.php | 2 +- htdocs/adherents/class/adherent.class.php | 6 ++-- .../class/api_memberstypes.class.php | 2 +- htdocs/adherents/subscription/card.php | 2 +- htdocs/admin/emailcollector_card.php | 2 +- htdocs/api/class/api_documents.class.php | 6 ++-- htdocs/asset/card.php | 2 +- htdocs/blockedlog/class/blockedlog.class.php | 2 +- htdocs/bom/bom_card.php | 2 +- htdocs/bom/class/bom.class.php | 4 +-- htdocs/comm/propal/card.php | 18 ++++++------ htdocs/comm/propal/class/propal.class.php | 14 +++++----- htdocs/commande/card.php | 16 +++++------ htdocs/commande/class/commande.class.php | 6 ++-- htdocs/commande/orderstoinvoice.php | 2 +- htdocs/compta/facture/card-rec.php | 10 +++---- htdocs/compta/facture/card.php | 28 +++++++++---------- htdocs/compta/facture/class/facture.class.php | 4 +-- htdocs/contrat/card.php | 6 ++-- htdocs/core/actions_addupdatedelete.inc.php | 8 +++--- htdocs/core/actions_builddoc.inc.php | 2 +- htdocs/core/actions_lineupdown.inc.php | 4 +-- htdocs/core/actions_setnotes.inc.php | 2 +- htdocs/core/tpl/card_presend.tpl.php | 2 +- htdocs/don/card.php | 4 +-- htdocs/don/class/don.class.php | 6 ++-- htdocs/don/payment/card.php | 2 +- htdocs/expedition/card.php | 6 ++-- htdocs/expedition/class/expedition.class.php | 2 +- htdocs/expensereport/card.php | 24 ++++++++-------- htdocs/expensereport/payment/card.php | 2 +- htdocs/fichinter/card.php | 18 ++++++------ htdocs/fichinter/class/fichinter.class.php | 4 +-- htdocs/fichinter/class/fichinterrec.class.php | 2 +- .../class/fournisseur.commande.class.php | 6 ++-- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/fourn/commande/card.php | 14 +++++----- htdocs/fourn/facture/card.php | 16 +++++------ htdocs/fourn/paiement/card.php | 2 +- htdocs/livraison/card.php | 4 +-- htdocs/livraison/class/livraison.class.php | 6 ++-- htdocs/loan/payment/card.php | 2 +- .../template/class/myobject.class.php | 4 +-- htdocs/mrp/class/mo.class.php | 4 +-- htdocs/mrp/mo_card.php | 4 +-- htdocs/mrp/mo_production.php | 2 +- .../stock/class/api_stockmovements.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 4 +-- .../stock/class/mouvementstock.class.php | 4 +-- htdocs/projet/card.php | 4 +-- htdocs/projet/class/project.class.php | 6 ++-- htdocs/projet/tasks/task.php | 4 +-- htdocs/reception/card.php | 12 ++++---- htdocs/reception/class/reception.class.php | 8 +++--- .../class/recruitmentjobposition.class.php | 10 +++---- htdocs/societe/card.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/supplier_proposal/card.php | 18 ++++++------ .../class/supplier_proposal.class.php | 8 +++--- htdocs/ticket/card.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/class/api_users.class.php | 2 +- htdocs/user/group/card.php | 2 +- htdocs/webservices/server_invoice.php | 2 +- htdocs/webservices/server_order.php | 4 +-- htdocs/website/websiteaccount_card.php | 17 +---------- htdocs/zapier/hook_card.php | 10 ------- 69 files changed, 196 insertions(+), 221 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 439854229e0..c3c14171386 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1738,7 +1738,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $genallowed = $user->rights->adherent->lire; $delallowed = $user->rights->adherent->creer; - print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); + print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; // Show links to link elements diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 82cdf7794a4..8b643dcbe92 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1724,7 +1724,7 @@ class Adherent extends CommonObject // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - $invoice->generateDocument($invoice->modelpdf, $outputlangs); + $invoice->generateDocument($invoice->model_pdf, $outputlangs); } } @@ -2257,8 +2257,8 @@ class Adherent extends CommonObject if (!dol_strlen($modele)) { $modele = 'standard'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) { $modele = $conf->global->ADHERENT_ADDON_PDF; } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 6930b96e656..a5923914187 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -293,7 +293,7 @@ class MembersTypes extends DolibarrApi unset($object->cond_reglement); unset($object->fk_delivery_address); unset($object->shipping_method_id); - unset($object->modelpdf); + unset($object->model_pdf); unset($object->fk_account); unset($object->note_public); unset($object->note_private); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index b7e54238c4c..3fad8c9db14 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -370,7 +370,7 @@ if ($rowid && $action != 'edit') { $genallowed = $user->rights->facture->lire; $delallowed = $user->rights->facture->creer; - print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); $somethingshown = $formfile->numoffiles; */ // Show links to link elements diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 3044aa3ab6f..f8129a887a8 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -705,7 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->emailcollector->read; // If you can read, you can build the PDF to read content $delallowed = $user->rights->emailcollector->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('emailcollector', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ /* // Show links to link elements diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 69fef80fd6b..9605f46f219 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -196,7 +196,7 @@ class Documents extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - $templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->invoice->model_pdf; $result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { throw new RestException(500, 'Error generating document'); @@ -210,7 +210,7 @@ class Documents extends DolibarrApi if (!$result) { throw new RestException(404, 'Order not found'); } - $templateused = $doctemplate ? $doctemplate : $this->order->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->order->model_pdf; $result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { throw new RestException(500, 'Error generating document'); @@ -224,7 +224,7 @@ class Documents extends DolibarrApi if (!$result) { throw new RestException(404, 'Proposal not found'); } - $templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->propal->model_pdf; $result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { throw new RestException(500, 'Error generating document'); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 8606751ba85..8a6cb9b5e94 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -346,7 +346,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content $delallowed = $user->rights->asset->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ // Show links to link elements diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 44311f1a580..a9864e34c0d 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -368,7 +368,7 @@ class BlockedLog $this->object_data = new stdClass(); // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id', + 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'model_pdf', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id', 'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged', 'linkedObjectsIds', 'linkedObjects', diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 079fcb608ab..1230a0e3269 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -707,7 +707,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom')); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index d180c00426f..b5c0f9e8310 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -934,8 +934,8 @@ class BOM extends CommonObject if (!dol_strlen($modele)) { $modele = 'standard'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->BOM_ADDON_PDF)) { $modele = $conf->global->BOM_ADDON_PDF; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 90ab0605c68..5c53f6715a2 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -231,7 +231,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records if ($ret > 0) $object->fetch_thirdparty(); - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -252,7 +252,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records if ($ret > 0) { $object->fetch_thirdparty(); @@ -353,7 +353,7 @@ if (empty($reshook)) $object->socid = GETPOST('socid', 'int'); $object->contact_id = GETPOST('contactid', 'int'); $object->fk_project = GETPOST('projectid', 'int'); - $object->modelpdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note_private = GETPOST('note_private', 'none'); $object->note_public = GETPOST('note_public', 'none'); @@ -381,7 +381,7 @@ if (empty($reshook)) $object->fk_account = GETPOST('fk_account', 'int'); $object->contact_id = GETPOST('contactid', 'int'); $object->fk_project = GETPOST('projectid', 'int'); - $object->modelpdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note_private = GETPOST('note_private', 'none'); $object->note_public = GETPOST('note_public', 'none'); @@ -578,7 +578,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -769,7 +769,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records if ($ret > 0) $object->fetch_thirdparty(); - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } elseif ($action == "setabsolutediscount" && $usercancreate) { if ($_POST["remise_id"]) { @@ -1101,7 +1101,7 @@ if (empty($reshook)) if ($ret > 0) { $object->fetch_thirdparty(); } - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['prod_entry_mode']); @@ -1243,7 +1243,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records if ($ret > 0) $object->fetch_thirdparty(); - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -2521,7 +2521,7 @@ if ($action == 'create') $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); + print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('propal')); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e0b645f6faf..f844189fac9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1061,7 +1061,7 @@ class Propal extends CommonObject $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "NULL"); $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; - $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->fin_validite != '' ? "'".$this->db->idate($this->fin_validite)."'" : "NULL"); $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); @@ -1494,7 +1494,7 @@ class Propal extends CommonObject $this->project = null; // Clear if another value was already set by fetch_projet $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; @@ -1599,7 +1599,7 @@ class Propal extends CommonObject if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); if (!empty($this->duree_validite)) $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); @@ -2527,13 +2527,13 @@ class Propal extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf; + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf; $triggerName = 'PROPAL_CLOSE_REFUSED'; if ($status == self::STATUS_SIGNED) { $triggerName = 'PROPAL_CLOSE_SIGNED'; - $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf; + $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf; // The connected company is classified as a client $soc = new Societe($this->db); @@ -3671,8 +3671,8 @@ class Propal extends CommonObject if (!dol_strlen($modele)) { $modele = 'azur'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->PROPALE_ADDON_PDF)) { $modele = $conf->global->PROPALE_ADDON_PDF; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8cc3fd48aca..c2536ee59d6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -221,7 +221,7 @@ if (empty($reshook)) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -268,7 +268,7 @@ if (empty($reshook)) $object->source = GETPOST('source_id'); $object->fk_project = GETPOST('projectid', 'int'); $object->ref_client = GETPOST('ref_client', 'alpha'); - $object->modelpdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); @@ -584,7 +584,7 @@ if (empty($reshook)) } $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -940,7 +940,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['prod_entry_mode']); @@ -1084,7 +1084,7 @@ if (empty($reshook)) } $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1158,7 +1158,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1207,7 +1207,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2627,7 +2627,7 @@ if ($action == 'create' && $usercancreate) $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); + print $formfile->showdocuments('commande', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); // Show links to link elements diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7119e85b473..3e027cef919 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -943,7 +943,7 @@ class Commande extends CommonOrder $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); - $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : "null"); $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "null"); $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); @@ -1843,7 +1843,7 @@ class Commande extends CommonOrder $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; @@ -3211,7 +3211,7 @@ class Commande extends CommonOrder if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); // Check parameters diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index c3d82821249..7b8e31ce7a4 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -167,7 +167,7 @@ if (($action == 'create' || $action == 'add') && !$error) $object->note_public = trim($_POST['note_public']); $object->note = trim($_POST['note']); $object->ref_client = $_POST['ref_client']; - $object->modelpdf = $_POST['model']; + $object->model_pdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index cc3a0769e70..0074fcc8ba9 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -192,7 +192,7 @@ if (empty($reshook)) $object->title = GETPOST('titre', 'nohtml'); $object->note_private = GETPOST('note_private', 'none'); $object->note_public = GETPOST('note_public', 'none'); - $object->modelpdf = GETPOST('modelpdf', 'alpha'); + $object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); $object->frequency = $frequency; @@ -650,7 +650,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model=$object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -861,7 +861,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ $object->fetch($object->id); // Reload lines @@ -1425,9 +1425,9 @@ if ($action == 'create') $list[] = str_replace(':', '|', $k).':'.$model; } $select = 'select;'.implode(',', $list); - print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); + print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); } else { - print $object->modelpdf; + print $object->model_pdf; } print ""; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 460e40a1de4..ed77c0e8a56 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -251,7 +251,7 @@ if (empty($reshook)) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } if ($result >= 0) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); @@ -458,7 +458,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -530,7 +530,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setref' && $usercancreate) @@ -644,7 +644,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -728,7 +728,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -991,7 +991,7 @@ if (empty($reshook)) // We do not copy the private note $object->ref_client = $_POST['ref_client']; $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->model_pdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = $_POST['cond_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id']; @@ -1048,7 +1048,7 @@ if (empty($reshook)) // We do not copy the private note $object->ref_client = $_POST['ref_client']; $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->model_pdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = 0; $object->mode_reglement_id = $_POST['mode_reglement_id']; @@ -1264,7 +1264,7 @@ if (empty($reshook)) $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->model_pdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; @@ -1316,7 +1316,7 @@ if (empty($reshook)) $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->model_pdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; @@ -1806,7 +1806,7 @@ if (empty($reshook)) $object->note_private = trim(GETPOST('note', 'none')); $object->ref_client = GETPOST('ref_client', 'alpha'); $object->ref_int = GETPOST('ref_int', 'alpha'); - $object->modelpdf = GETPOST('model', 'alpha'); + $object->model_pdf = GETPOST('model', 'alpha'); $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); @@ -1851,7 +1851,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2145,7 +2145,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2356,7 +2356,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -5311,7 +5311,7 @@ if ($action == 'create') print $formfile->showdocuments( 'facture', $filename, $filedir, $urlsource, $genallowed, - $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', + $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object, 0, 'remove_file_comfirm'); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4146657d71b..cb86caa91a9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1591,7 +1591,7 @@ class Facture extends CommonInvoice $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; @@ -1837,7 +1837,7 @@ class Facture extends CommonInvoice if (isset($this->note) || isset($this->note_private)) $this->note = (isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated if (isset($this->note) || isset($this->note_private)) $this->note_private = (isset($this->note_private) ? trim($this->note_private) : trim($this->note)); if (isset($this->note_public)) $this->note_public = trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index f703ccd4b65..cd622b38c28 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -568,7 +568,7 @@ if (empty($reshook)) $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['prod_entry_mode']); @@ -743,7 +743,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2126,7 +2126,7 @@ if ($action == 'create') $delallowed = $user->rights->contrat->creer; - print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); // Show links to link elements diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ba1d296ac44..09f1c7cf314 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -270,7 +270,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (method_exists($object, 'generateDocument')) { $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -299,7 +299,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -327,7 +327,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -367,7 +367,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index eb51796eccd..20bd19625cc 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -82,7 +82,7 @@ if ($action == 'builddoc' && $permissiontoadd) if (empty($hideref)) $hideref = 0; if (empty($moreparams)) $moreparams = null; - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php index b0556d6399f..e5507eeafc0 100644 --- a/htdocs/core/actions_lineupdown.inc.php +++ b/htdocs/core/actions_lineupdown.inc.php @@ -43,7 +43,7 @@ if ($action == 'up' && $permissiontoedit) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); @@ -64,7 +64,7 @@ if ($action == 'down' && $permissiontoedit) $outputlangs->setDefaultLang($newlang); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 3bbba0204f5..7ea3dd5016f 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -49,7 +49,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 3695ec31d37..9ce7d8bfaff 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -93,7 +93,7 @@ if ($action == 'presend') { if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) { - $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { dol_print_error($db, $object->error, $object->errors); exit(); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 059b95b7acb..9f3f5c56daf 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -288,7 +288,7 @@ if ($action == 'builddoc') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=don_create($db, $object->id, '', $object->modelpdf, $outputlangs); + $result=don_create($db, $object->id, '', $object->model_pdf, $outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -839,7 +839,7 @@ if (!empty($id) && $action != 'edit') $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); $delallowed = $user->rights->don->creer; - print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); + print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('don')); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 915876a3abb..d4f0871b94c 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -687,7 +687,7 @@ class Don extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated // Retreive all extrafield // fetch optionals attributes and labels @@ -985,8 +985,8 @@ class Don extends CommonObject if (!dol_strlen($modele)) { $modele = 'html_cerfafr'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->DON_ADDON_MODEL)) { $modele = $conf->global->DON_ADDON_MODEL; } diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 6d1285b5f17..29c59dc87d1 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -93,7 +93,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->cree $outputlangs->setDefaultLang($_REQUEST['lang_id']); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $fac->generateDocument($fac->modelpdf, $outputlangs); + $fac->generateDocument($fac->model_pdf, $outputlangs); } } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d44a8324995..dce279a32e5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -434,7 +434,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -798,7 +798,7 @@ if (empty($reshook)) } $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To redisplay the form being edited @@ -2523,7 +2523,7 @@ if ($action == 'create') $genallowed = $user->rights->expedition->lire; $delallowed = $user->rights->expedition->creer; - print $formfile->showdocuments('expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 46d964756ff..6d9b409b41d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1067,7 +1067,7 @@ class Expedition extends CommonObject if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); if (isset($this->note_private)) $this->note = trim($this->note_private); if (isset($this->note_public)) $this->note = trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 9aeec476e24..c3883ee6b3d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -341,7 +341,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -454,7 +454,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -566,7 +566,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -680,7 +680,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -798,7 +798,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -913,7 +913,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -952,7 +952,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -980,7 +980,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1008,7 +1008,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1176,7 +1176,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($qty); @@ -1222,7 +1222,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1314,7 +1314,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 3e8da949bff..fd1453b8ae5 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -94,7 +94,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere $outputlangs->setDefaultLang($_REQUEST['lang_id']); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $fac->generateDocument($fac->modelpdf, $outputlangs); + $fac->generateDocument($fac->model_pdf, $outputlangs); } } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index f8e34cc5b55..612529b6cc1 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -167,7 +167,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->modelpdf : GETPOST('model', 'alpha'), $outputlangs); + $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -192,7 +192,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->modelpdf : GETPOST('model', 'alpha'), $outputlangs); + $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -209,7 +209,7 @@ if (empty($reshook)) $object->author = $user->id; $object->description = GETPOST('description', 'none'); $object->ref = $ref; - $object->modelpdf = GETPOST('model', 'alpha'); + $object->model_pdf = GETPOST('model', 'alpha'); $object->note_private = GETPOST('note_private', 'none'); $object->note_public = GETPOST('note_public', 'none'); @@ -506,7 +506,7 @@ if (empty($reshook)) { $db->commit(); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { @@ -603,7 +603,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; @@ -638,7 +638,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); } /* @@ -658,7 +658,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; @@ -676,7 +676,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->model_pdf, $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; @@ -1653,7 +1653,7 @@ if ($action == 'create') $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->ficheinter->lire; $delallowed = $user->rights->ficheinter->creer; - print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter')); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index c6c5fd587e6..6ac136c5b4d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -279,7 +279,7 @@ class Fichinter extends CommonObject $sql .= ", ".$user->id; $sql .= ", ".$user->id; $sql .= ", ".($this->description ? "'".$this->db->escape($this->description)."'" : "null"); - $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->fk_project ? $this->fk_project : 0); $sql .= ", ".($this->fk_contrat ? $this->fk_contrat : 0); $sql .= ", ".$this->statut; @@ -449,7 +449,7 @@ class Fichinter extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_contrat = $obj->fk_contrat; $this->user_creation = $obj->fk_user_author; diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index b9e43dae5e0..51bc9e53ff2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -177,7 +177,7 @@ class FichinterRec extends Fichinter $sql .= ", null, null"; } - $sql .= ", ".(!empty($fichintsrc->modelpdf) ? "'".$this->db->escape($fichintsrc->modelpdf)."'" : "''"); + $sql .= ", ".(!empty($fichintsrc->model_pdf) ? "'".$this->db->escape($fichintsrc->model_pdf)."'" : "''"); // récurrence $sql .= ", ".(!empty($this->frequency) ? $this->frequency : "null"); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f28491c6f5b..61b523767b0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -393,7 +393,7 @@ class CommandeFournisseur extends CommonOrder $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -2972,8 +2972,8 @@ class CommandeFournisseur extends CommonOrder if (!dol_strlen($modele)) { $modele = 'muscadet'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) { $modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e77f283a652..a078b2df022 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -710,7 +710,7 @@ class FactureFournisseur extends CommonInvoice $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->import_key = $obj->import_key; //Incoterms diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 6222329af16..404566b5392 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -256,7 +256,7 @@ class PaiementFourn extends Paiement $outputlangs->setDefaultLang($newlang); } $ret = $invoice->fetch($facid); // Reload to get new records - $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs); + $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs); if ($result < 0) { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 9cfb16c40e4..137ddafc79d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -601,7 +601,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -776,7 +776,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -813,7 +813,7 @@ if (empty($reshook)) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { $error++; @@ -852,7 +852,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -918,7 +918,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { $error++; @@ -975,7 +975,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } $action = ''; } else { @@ -2615,7 +2615,7 @@ if ($action == 'create') $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); + print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); $somethingshown = $formfile->numoffiles; // Show links to link elements diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 707e84cf87c..d53a554f9d8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -212,7 +212,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -259,7 +259,7 @@ if (empty($reshook)) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -309,7 +309,7 @@ if (empty($reshook)) } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -440,7 +440,7 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1020,7 +1020,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { dol_print_error($db, $object->error, $object->errors); @@ -1366,7 +1366,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1470,7 +1470,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -3196,7 +3196,7 @@ if ($action == 'create') $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - $modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF)); + $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF)); print $formfile->showdocuments('facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 28020e40811..56a007ccbeb 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -367,7 +367,7 @@ if ($result > 0) $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed = $user->rights->fournisseur->facture->lire; $delallowed = $user->rights->fournisseur->facture->creer; - $modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ? '' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF)); + $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ? '' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF)); print $formfile->showdocuments('supplier_payment', $ref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 544593dc16c..51351605494 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -143,7 +143,7 @@ if ($action == 'add') $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -681,7 +681,7 @@ if ($action == 'create') // Create. Seems to no be used $genallowed = $user->rights->expedition->livraison->lire; $delallowed = $user->rights->expedition->livraison->creer; - print $formfile->showdocuments('livraison', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('livraison', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); /* * Linked object block (of linked shipment) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 7baf41ee51e..16ddf710d6e 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -315,7 +315,7 @@ class Livraison extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->origin = $obj->origin; // May be 'shipping' $this->origin_id = $obj->origin_id; // May be id of shipping @@ -1043,8 +1043,8 @@ class Livraison extends CommonObject if (!dol_strlen($modele)) { $modele = 'typhon'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->LIVRAISON_ADDON_PDF)) { $modele = $conf->global->LIVRAISON_ADDON_PDF; } diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 4001037f887..9b4da35e5d1 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -95,7 +95,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->wri $outputlangs->setDefaultLang($_REQUEST['lang_id']); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $fac->generateDocument($fac->modelpdf, $outputlangs); + $fac->generateDocument($fac->model_pdf, $outputlangs); } } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 89b4b4bd5ea..95672655825 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1020,8 +1020,8 @@ class MyObject extends CommonObject if (!dol_strlen($modele)) { $modele = 'standard_myobject'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) { $modele = $conf->global->MYOBJECT_ADDON_PDF; } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 404a3329133..67f21e8f617 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1191,8 +1191,8 @@ class Mo extends CommonObject //$modele = 'standard'; $modele = ''; // Remove this once a pdf_standard.php exists. - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->MO_ADDON_PDF)) { $modele = $conf->global->MO_ADDON_PDF; } diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 19ec10daf3b..62a78ac9899 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -187,7 +187,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, 0, 0, 0); @@ -694,7 +694,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content $delallowed = $user->rights->mrp->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); + print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index a5503147f0c..75e198c7f54 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -400,7 +400,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, 0, 0, 0); diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index a8e15f8f28e..1efa81bc0a8 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -303,7 +303,7 @@ class StockMovements extends DolibarrApi unset($object->note_public); unset($object->shipping_method_id); unset($object->fk_account); - unset($object->modelpdf); + unset($object->model_pdf); unset($object->fk_delivery_address); unset($object->cond_reglement); unset($object->cond_reglement_id); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index d63469308b3..3dc8693897a 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -867,8 +867,8 @@ class Entrepot extends CommonObject if (!dol_strlen($modele)) { $modele = 'standard'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->STOCK_ADDON_PDF)) { $modele = $conf->global->STOCK_ADDON_PDF; } diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index d1c703924d4..bfdfb14f6e8 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -1172,8 +1172,8 @@ class MouvementStock extends CommonObject if (!dol_strlen($modele)) { $modele = 'stdmovement'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->MOUVEMENT_ADDON_PDF)) { $modele = $conf->global->MOUVEMENT_ADDON_PDF; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index e3331fcec74..e7054f21a3c 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -344,7 +344,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result = $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->model_pdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1352,7 +1352,7 @@ if ($action == 'create' && $user->rights->projet->creer) $genallowed = ($user->rights->projet->lire && $userAccess > 0); $delallowed = ($user->rights->projet->creer && $userWrite > 0); - print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); + print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); print '
'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 539617f55aa..28a342e7439 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -535,7 +535,7 @@ class Project extends CommonObject $this->opp_percent = $obj->opp_percent; $this->budget_amount = $obj->budget_amount; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->usage_opportunity = (int) $obj->usage_opportunity; $this->usage_task = (int) $obj->usage_task; $this->usage_bill_time = (int) $obj->usage_bill_time; @@ -1689,8 +1689,8 @@ class Project extends CommonObject if (!dol_strlen($modele)) { $modele = 'baleine'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->PROJECT_ADDON_PDF)) { $modele = $conf->global->PROJECT_ADDON_PDF; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 7a109eb1f50..0a432351f60 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -165,7 +165,7 @@ if ($action == 'builddoc' && $user->rights->projet->creer) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); } - $result = $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->model_pdf, $outputlangs); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -627,7 +627,7 @@ if ($id > 0 || !empty($ref)) $genallowed = ($user->rights->projet->lire); $delallowed = ($user->rights->projet->creer); - print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); + print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); print '
'; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 27722c29ed4..98d35d1e14e 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -154,7 +154,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } @@ -392,7 +392,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -486,7 +486,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -644,7 +644,7 @@ if (empty($reshook)) } $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition @@ -2060,7 +2060,7 @@ if ($action == 'create') $genallowed = $user->rights->reception->lire; $delallowed = $user->rights->reception->creer; - print $formfile->showdocuments('reception', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('reception', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); @@ -2091,7 +2091,7 @@ if ($action == 'create') // Build document if it not exists if (!$file || !is_readable($file)) { - $result = $object->generateDocument(GETPOST('model') ?GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument(GETPOST('model') ?GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db, $object->error, $object->errors); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 826c61de815..2673c7a0da4 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -401,7 +401,7 @@ class Reception extends CommonObject $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->shipping_method_id = $obj->fk_shipping_method; $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility @@ -784,7 +784,7 @@ class Reception extends CommonObject if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); if (isset($this->note_private)) $this->note = trim($this->note_private); if (isset($this->note_public)) $this->note = trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); + if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf); // Check parameters @@ -1877,8 +1877,8 @@ class Reception extends CommonObject { $modele = 'squille'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->RECEPTION_ADDON_PDF)) { $modele = $conf->global->RECEPTION_ADDON_PDF; } diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 7bc5d507f42..81defec97e9 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -690,13 +690,13 @@ class RecruitmentJobPosition extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $modelpdf = $this->modelpdf; - $triggerName = 'PROPAL_CLOSE_REFUSED'; + $modelpdf = $this->model_pdf; + $triggerName = 'RECRUITMENTJOB_CLOSE_REFUSED'; if ($status == self::STATUS_RECRUITED) { $triggerName = 'RECRUITMENTJOB_CLOSE_RECRUITED'; - $modelpdf = $this->modelpdf; + $modelpdf = $this->model_pdf; if ($result < 0) { @@ -1076,8 +1076,8 @@ class RecruitmentJobPosition extends CommonObject if (!dol_strlen($modele)) { $modele = 'standard_recruitmentjobposition'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->RECRUITMENTJOBPOSITION_ADDON_PDF)) { $modele = $conf->global->RECRUITMENTJOBPOSITION_ADDON_PDF; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 4b07247281b..4218dcd7872 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2687,7 +2687,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $genallowed = $user->rights->societe->lire; $delallowed = $user->rights->societe->creer; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); } // Subsidiaries list diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b208135121b..b6d57191dce 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4155,7 +4155,7 @@ class Societe extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example. + * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example. * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 16b29836a60..739c4456a78 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1530,7 +1530,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $genallowed = $user->rights->societe->lire; $delallowed = $user->rights->societe->creer; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 9e776f94371..0c4e53da2b9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -191,7 +191,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -217,7 +217,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -266,7 +266,7 @@ if (empty($reshook)) $object->remise_absolue = GETPOST('remise_absolue'); $object->socid = GETPOST('socid'); $object->fk_project = GETPOST('projectid', 'int'); - $object->modelpdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note', 'none'); $object->statut = SupplierProposal::STATUS_DRAFT; @@ -284,7 +284,7 @@ if (empty($reshook)) $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = GETPOST('projectid', 'int'); - $object->modelpdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note', 'none'); @@ -436,7 +436,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -517,7 +517,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } elseif ($action == "setabsolutediscount" && $usercancreate) { if ($_POST["remise_id"]) { @@ -780,7 +780,7 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model = $object->modelpdf; + $model = $object->model_pdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -963,7 +963,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1922,7 +1922,7 @@ if ($action == 'create') $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); // Show links to link elements diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d2f1ef2011e..4c02eec9508 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -918,7 +918,7 @@ class SupplierProposal extends CommonObject $sql .= ", ".($user->id > 0 ? "'".$user->id."'" : "null"); $sql .= ", '".$this->db->escape($this->note_private)."'"; $sql .= ", '".$this->db->escape($this->note_public)."'"; - $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", '".$this->db->escape($this->model_pdf)."'"; $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); @@ -1245,7 +1245,7 @@ class SupplierProposal extends CommonObject $this->socid = $obj->fk_soc; $this->fk_project = $obj->fk_project; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; @@ -2638,8 +2638,8 @@ class SupplierProposal extends CommonObject if (!dol_strlen($modele)) { $modele = 'aurore'; - if ($this->modelpdf) { - $modele = $this->modelpdf; + if ($this->model_pdf) { + $modele = $this->model_pdf; } elseif (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ea27fc98f44..2e2f6f46f73 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -227,7 +227,7 @@ if (empty($reshook)) { $fichinter->fk_project = GETPOST('projectid', 'int'); $fichinter->fk_contrat = $contractid; $fichinter->author = $user->id; - $fichinter->modelpdf = 'soleil'; + $fichinter->model_pdf = 'soleil'; $fichinter->origin = $object->element; $fichinter->origin_id = $object->id; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9108fce983f..94f801fed6d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2719,7 +2719,7 @@ if ($action == 'create' || $action == 'adduserldap') $genallowed = $user->rights->user->user->lire; $delallowed = $user->rights->user->user->creer; - print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); $somethingshown = $formfile->numoffiles; // Show links to link elements diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index c878d7dd376..cab2b56f5d9 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -627,7 +627,7 @@ class Users extends DolibarrApi unset($object->openid); unset($object->lines); - unset($object->modelpdf); + unset($object->model_pdf); unset($object->skype); unset($object->twitter); unset($object->facebook); diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 102fc61d5c1..462ba32e7ba 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -493,7 +493,7 @@ else { $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; - $somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + $somethingshown = $formfile->showdocuments('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, null); diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 8b15ade0a6a..194a2331b2c 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -778,7 +778,7 @@ function updateInvoice($authentication, $invoice) { // Define output language $outputlangs = $langs; - $object->generateDocument($object->modelpdf, $outputlangs); + $object->generateDocument($object->model_pdf, $outputlangs); } } if ($invoice['status'] == Facture::STATUS_CLOSED) diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 7018f5fb5c8..98c9be86cfc 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -842,7 +842,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) { // Define output language $outputlangs = $langs; - $order->generateDocument($order->modelpdf, $outputlangs); + $order->generateDocument($order->model_pdf, $outputlangs); } else { $db->rollback(); @@ -929,7 +929,7 @@ function updateOrder($authentication, $order) { // Define output language $outputlangs = $langs; - $object->generateDocument($order->modelpdf, $outputlangs); + $object->generateDocument($order->model_pdf, $outputlangs); } } if ($order['status'] == 0) $result = $object->set_reopen($fuser); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 8494cfb9ae7..d2b592477fd 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -348,27 +348,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; // ancre - // Documents - /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref . '/' . $objref . '.pdf'; - $filedir = $conf->website->dir_output . '/' . $objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->website->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->website->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('website', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - */ - - // Show links to link elements - /*$linktoelem = $form->showLinkToObjectBlock($object, null, array('websiteaccount')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - */ - print '
'; + /* $MAXEVENT = 10; // List of actions on element - /* include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT); diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index 6c098999d58..9d33a9801b0 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -371,16 +371,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; // ancre - // Documents - /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->mymodule->dir_output . '/' . $objref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - */ - // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); From b3fe61e77b0019d5c608a14c4eaf4bd44be0045a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 03:28:41 +0200 Subject: [PATCH 070/173] Start fix for #14689 --- htdocs/core/js/timesheet.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index aea8f9a1318..0c8c9ff3245 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -91,6 +91,7 @@ function pad(n) { /* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */ /* timeStr must be a duration with format XX:YY (AM/PM not supported) */ +/* return: nbofextradays (0, 1, ...) */ function parseTime(timeStr, dt) { if (!dt) { @@ -103,14 +104,14 @@ function parseTime(timeStr, dt) return -1; } var hours = parseInt(time[1], 10); - dt.setHours(hours); dt.setMinutes(parseInt(time[2], 10) || 0); dt.setSeconds(0, 0); - return 0; + //console.log("hours="+hours+" => return nbofextradays="+Math.floor(hours / 24)+" hours="+dt.getHours()); + return Math.floor(hours / 24); } -/* Update total. days = column nb staring from 0 */ +/* Update total. days = column nb starting from 0 */ function updateTotal(days,mode) { console.log('updateTotal days='+days+' mode='+mode); @@ -124,12 +125,15 @@ function updateTotal(days,mode) if (document.getElementById('numberOfFirstLine')) { startline = parseInt(document.getElementById('numberOfFirstLine').value); } + var nbextradays = 0; for (var i=-1; i < nbline; i++) { + /* get value into timespent cell */ + var id='timespent['+i+']['+days+']'; - var taskTime= new Date(0); - var element=document.getElementById(id); - if(element) + var taskTime = new Date(0); + var element = document.getElementById(id); + if (element) { /* alert(element.value);*/ if (element.value) @@ -142,11 +146,16 @@ function updateTotal(days,mode) } if (result >= 0) { - total.setHours(total.getHours()+taskTime.getHours()); + nbextradays = nbextradays + Math.floor((total.getHours()+taskTime.getHours() + result*24) / 24); + //console.log("i="+i+" result="+result); + total.setHours(total.getHours()+taskTime.getHours()); total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + //console.log("i="+i+" nbextradays cumul="+nbextradays+" h="+total.getHours()+" "+taskTime.getHours()); } } - + + /* get value into timeadded cell */ + var id='timeadded['+i+']['+days+']'; var taskTime= new Date(0); var element=document.getElementById(id); @@ -163,8 +172,11 @@ function updateTotal(days,mode) } if (result >= 0) { + nbextradays = nbextradays + Math.floor((total.getHours()+taskTime.getHours() + result*24) / 24); + //console.log("i="+i+" result="+result); total.setHours(total.getHours()+taskTime.getHours()); total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + //console.log("i="+i+" nbextradays cumul="+nbextradays+" h="+total.getHours()+" "+taskTime.getHours()); } } } @@ -223,10 +235,15 @@ function updateTotal(days,mode) stringdays = '0'+stringdays; } + /* Output total in top of column */ + if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+stringdays).addClass("bold"); else jQuery('.totalDay'+stringdays).removeClass("bold"); - jQuery('.totalDay'+stringdays).text(pad(total.getHours())+':'+pad(total.getMinutes())); + var texttoshow = pad(nbextradays * 24 + total.getHours())+':'+pad(total.getMinutes()); + jQuery('.totalDay'+stringdays).text(texttoshow); + /* Output total of all total */ + var totalhour = 0; var totalmin = 0; for (var i=0; i<7; i++) From 6ec89afe8b308928d972267245549c438cf85566 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 03:30:24 +0200 Subject: [PATCH 071/173] Fix phpcs --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 23e25c92590..1d391846339 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -255,7 +255,7 @@ class pdf_standard extends CommonStickerGenerator $year = dol_print_date($now, '%Y'); $month = dol_print_date($now, '%m'); $day = dol_print_date($now, '%d'); - + // List of values to scan for a replacement $substitutionarray = array( '__ID__' => $object->id, From 59d5391c2a4f830ad623eec9740648ed2fa7c720 Mon Sep 17 00:00:00 2001 From: John Botella Date: Thu, 10 Sep 2020 10:41:16 +0200 Subject: [PATCH 072/173] Add force reload param to load method --- htdocs/core/class/translate.class.php | 73 +++++---------------------- htdocs/cron/class/cronjob.class.php | 4 +- 2 files changed, 14 insertions(+), 63 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ad243db872e..06d8432f3e1 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -163,18 +163,19 @@ class Translate * * Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache * - * @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files: - * If $domain is "file@module" instead of "file" then we look for module lang file - * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang - * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang - * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) - * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) - * @param int $forcelangdir To force a different lang directory - * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf. - * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK + * @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files: + * If $domain is "file@module" instead of "file" then we look for module lang file + * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang + * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang + * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) + * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) + * @param int $forcelangdir To force a different lang directory + * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf. + * @param int $forceloadifalreadynotfound Force attempt to reload lang file if it was previously not found + * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK * @see loadLangs() */ - public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) + public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0, $forceloadifalreadynotfound = 0) { global $conf,$db; @@ -205,7 +206,8 @@ class Translate } // Check cache - if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain + if (! empty($this->_tab_loaded[$newdomain]) + && ($this->_tab_loaded[$newdomain] != 2 || empty($forceloadifalreadynotfound)) ) // File already loaded and found and not forced for this domain { //dol_syslog("Translate::Load already loaded for newdomain=".$newdomain); return 0; @@ -388,55 +390,6 @@ class Translate return 1; } - - - /** - * re-load translation key-value for a particular file, into a memory array. - * If data for file already loaded, do nothing. - * All data in translation array are stored in UTF-8 format. - * tab_loaded is completed with $domain key. - * rule "we keep first entry found with we keep last entry found" so it is probably not what you want to do. - * - * Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache - * - * @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files: - * If $domain is "file@module" instead of "file" then we look for module lang file - * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang - * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang - * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) - * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) - * @param int $forcelangdir To force a different lang directory - * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf. - * @return int <0 if KO, 0 if loading not required, >0 if OK - * @see loadLangs() - */ - public function reload($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) - { - // Check parameters - if (empty($domain)) { - dol_print_error('', get_class($this) . "::Load ErrorWrongParameters"); - return -1; - } - - if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys - - $newdomain = $domain; - - // Search if a module directory name is provided into lang file name - $regs = array(); - if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs)) { - $newdomain = $regs[1]; - } - - // Check cache and remove it - if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain - { - unset($this->_tab_loaded[$newdomain]); - } - - return $this->load($domain, $alt, $stopafterdirection, $forcelangdir, $loadfromfileonly); - } - /** * Load translation key-value from database into a memory array. * If data already loaded, do nothing. diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index cb4ef824690..f0cee68a01f 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1057,9 +1057,7 @@ class Cronjob extends CommonObject if (!$error) { $result = $langs->load($this->module_name); - if($result<0){ - $result = $langs->reload($this->module_name.'@'.$this->module_name); - } + $result = $langs->load($this->module_name.'@'.$this->module_name, 0, 0, '', 0, 1); if ($result < 0) // If technical error { From d2903c5de6a48868b7f7ff814725809b2885b392 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:04:41 +0200 Subject: [PATCH 073/173] adress feedback + massive cleanup --- htdocs/comm/index.php | 868 +++++++++++++----------------- htdocs/core/lib/functions.lib.php | 74 ++- 2 files changed, 455 insertions(+), 487 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index e28f0c397e7..dcb6b3b92b5 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -53,8 +53,7 @@ $bid = GETPOST('bid', 'int'); // Securite acces client $socid = GETPOST('socid', 'int'); -if (isset($user->socid) && $user->socid > 0) -{ +if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -85,75 +84,65 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - // Search proposal - if (!empty($conf->propal->enabled) && $user->rights->propal->lire) - { - $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); - } - // Search customer order - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) - { - $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); - } - // Search supplier proposal - if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) - { - $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); - } - // Search supplier order - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) - { - $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); - } - // Search intervention - if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) - { - $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); - } - // Search contract - if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) - { - $listofsearchfields['search_contract'] = array('text'=>'Contract'); - } +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo + // Search proposal + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { + $listofsearchfields['search_proposal'] = array('text'=>'Proposal'); + } + // Search customer order + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { + $listofsearchfields['search_customer_order'] = array('text'=>'CustomerOrder'); + } + // Search supplier proposal + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $listofsearchfields['search_supplier_proposal'] = array('text'=>'SupplierProposalShort'); + } + // Search supplier order + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $listofsearchfields['search_supplier_order'] = array('text'=>'SupplierOrder'); + } + // Search intervention + if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { + $listofsearchfields['search_intervention'] = array('text'=>'Intervention'); + } + // Search contract + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { + $listofsearchfields['search_contract'] = array('text'=>'Contract'); + } - if (count($listofsearchfields)) - { - print '
'; - print ''; - print '
'; - print ''; - $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
'; - print '
'; - print '
'; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
'; + print '
'; + print '
'; + print '
'; + } } /* * Draft customer proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -164,58 +153,48 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); - - StartSimpleTableHeader("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); - - if ($num > 0) - { + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); + + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; $propalstatic->id = $obj->rowid; $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print $propalstatic->getNomUrl(1); - print ''; - print ''; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - $companystatic->code_compta = $obj->code_compta; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''; - print ''.price($obj->total_ht).''; + $companystatic->email = $obj->email; + $companystatic->code_compta = $obj->code_compta; + + print ''; + print ''.$propalstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'customer', 16).''; + print ''.price($obj->total_ht).''; + print ''; + $i++; $total += $obj->total_ht; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoProposal").''; } - print "

"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -223,98 +202,85 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) } - /* * Draft supplier proposals */ -if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) -{ - $langs->load("supplier_proposal"); +if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { + $langs->load("supplier_proposal"); - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_statut = 0"; - $sql .= " AND p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND s.rowid = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_statut = 0"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND s.rowid = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=0", 2, $num); + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); - print ''; - $supplierproposalstatic->id = $obj->rowid; - $supplierproposalstatic->ref = $obj->ref; - $supplierproposalstatic->total_ht = $obj->total_ht; - $supplierproposalstatic->total_tva = $obj->total_tva; - $supplierproposalstatic->total_ttc = $obj->total_ttc; - print $supplierproposalstatic->getNomUrl(1); - print ''; - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + $supplierproposalstatic->id = $obj->rowid; + $supplierproposalstatic->ref = $obj->ref; + $supplierproposalstatic->total_ht = $obj->total_ht; + $supplierproposalstatic->total_tva = $obj->total_tva; + $supplierproposalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''; - print ''.price($obj->total_ht).''; - $i++; - $total += $obj->total_ht; - } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoProposal").''; - } - print "

"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierproposalstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price($obj->total_ht).''; + print ''; + + $i++; + $total += $obj->total_ht; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } /* * Draft customer orders */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.email"; - $sql .= ", s.entity"; - $sql .= ", s.code_compta"; + $sql .= ", s.entity"; + $sql .= ", s.code_compta"; $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -325,61 +291,47 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND c.fk_soc = ".$socid; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $total = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftOrders", "commande/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("DraftOrders", "commande/list.php", "search_status=0", 2, $num); - - if ($num > 0) - { + if ($num > 0) { $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { + + while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - print ''; - $orderstatic->id = $obj->rowid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print $orderstatic->getNomUrl(1); - print ''; - print ''; + + $orderstatic->id = $obj->rowid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->email = $obj->email; - $companystatic->entity = $obj->entity; - print $companystatic->getNomUrl(1, 'customer', 16); - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->email = $obj->email; + $companystatic->entity = $obj->entity; + + print ''; + print ''.$orderstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'customer', 16).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoOrder").''; } - print ""; - print "

"; + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); $db->free($resql); } else { dol_print_error($db); @@ -390,105 +342,86 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) /* * Draft suppliers orders */ -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) -{ - $langs->load("orders"); +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { + $langs->load("orders"); - $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; - $sql .= ", s.code_client"; - $sql .= ", s.code_fournisseur"; + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql .= ", s.code_client"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cf.fk_soc = s.rowid"; - $sql .= " AND cf.fk_statut = 0"; - $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($socid) $sql .= " AND cf.fk_soc = ".$socid; + $sql .= ", s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + $sql .= " AND cf.fk_statut = 0"; + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND cf.fk_soc = ".$socid; - $resql = $db->query($sql); - if ($resql) - { - $total = 0; - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) { + $total = 0; + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); - StartSimpleTableHeader("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=0", 2, $num); + if ($num > 0) { + $i = 0; - if ($num > 0) - { - $i = 0; - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($resql); - print ''; - $supplierorderstatic->id = $obj->rowid; - $supplierorderstatic->ref = $obj->ref; - $supplierorderstatic->ref_supplier = $obj->ref_suppliert; - $supplierorderstatic->total_ht = $obj->total_ht; - $supplierorderstatic->total_tva = $obj->total_tva; - $supplierorderstatic->total_ttc = $obj->total_ttc; - print $supplierorderstatic->getNomUrl(1); - print ''; - print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $supplierorderstatic->id = $obj->rowid; + $supplierorderstatic->ref = $obj->ref; + $supplierorderstatic->ref_supplier = $obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'supplier', 16); - print ''; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - $i++; - $total += $obj->total_ttc; - } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total").''.price($total).""; - } - } else { - print ''.$langs->trans("NoSupplierOrder").''; - } - print ""; - print "

"; + $companystatic->email = $obj->email; - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''.$supplierorderstatic->getNomUrl(1).''; + print ''.$companystatic->getNomUrl(1, 'supplier', 16).''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''; + + $i++; + $total += $obj->total_ttc; + } + } + + addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal"); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); + } } - print '
'; - $max = 3; - /* * Last modified customers or prospects */ -if (!empty($conf->societe->enabled) && $user->rights->societe->lire) -{ +if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.code_compta"; - $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.entity"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 2, 3)"; @@ -499,65 +432,65 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) $sql .= $db->plimit($max, 0); $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - StartSimpleTableHeader($langs->trans("BoxTitleLastCustomersOrProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + if ($resql) { + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastCustomersOrProspects"; } - elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedProspects", min($max, $num)), "societe/list.php", "type=p,c", 1); + elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $header = "BoxTitleLastModifiedProspects"; } else { - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedCustomers", min($max, $num)), "societe/list.php", "type=p,c", 1); + $header = "BoxTitleLastModifiedCustomers"; } - if ($num) - { - while ($i < $num) - { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1); + + if ($num) { + $i = 0; + + while ($i < $num && $i < $max) { $objp = $db->fetch_object($resql); + $companystatic->id = $objp->rowid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->code_compta = $objp->code_compta; - $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; + $companystatic->entity = $objp->entity; + $companystatic->email = $objp->email; + print ''; print ''.$companystatic->getNomUrl(1, 'customer', 48).''; - print ''; - print $companystatic->getLibCustProspStatut(); - print ""; - print ''.dol_print_date($db->jdate($objp->tms), 'day').""; + print ''.$companystatic->getLibCustProspStatut().''; + print ''.dol_print_date($db->jdate($objp->tms), 'day').''; print ''; + $i++; } - - $db->free($resql); - } else { - print ''.$langs->trans("None").''; } - print ""; - print "

"; + + addSummaryTableLine(3, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } -// Last suppliers -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) -{ + +/* + * Last suppliers + */ +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { $langs->load("boxes"); $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm"; - $sql .= ", s.code_fournisseur"; + $sql .= ", s.code_fournisseur"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.fournisseur = 1"; @@ -567,38 +500,38 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); - StartSimpleTableHeader($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + if ($num) { + $i = 0; + while ($i < $num && $i < $max) { + $objp = $db->fetch_object($resql); - if ($num) - { - while ($i < $num && $i < $max) - { - $objp = $db->fetch_object($result); $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print ''; + $companystatic->email = $objp->email; + + print ''; print ''.$companystatic->getNomUrl(1, 'supplier', 44).''; print ''.dol_print_date($db->jdate($objp->dm), 'day').''; print ''; $i++; } - } else { - print ''.$langs->trans("None").''; } - print ''; - print '

'; + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); + } else { + dol_print_error($db); } } @@ -606,8 +539,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU /* * Last actions */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_last_actions_done($max); } @@ -615,8 +547,7 @@ if ($user->rights->agenda->myactions->read) /* * Actions to do */ -if ($user->rights->agenda->myactions->read) -{ +if ($user->rights->agenda->myactions->read) { show_array_actions_to_do(10); } @@ -624,15 +555,14 @@ if ($user->rights->agenda->myactions->read) /* * Latest contracts */ -if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT -{ +if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT $langs->load("contracts"); $sql = "SELECT s.nom as name, s.rowid, s.canvas, "; - $sql .= ", s.code_client"; - $sql .= ", s.entity"; - $sql .= ", s.email"; - $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; + $sql .= ", s.code_client"; + $sql .= ", s.entity"; + $sql .= ", s.email"; + $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; @@ -646,54 +576,53 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TOD $sql .= $db->plimit(5, 0); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); + startSimpleTable($langs->trans("LastContracts", 5), "", "", 2); - if ($num > 0) - { - StartSimpleTableHeader($langs->trans("LastContracts", 5), "", "", 2); - + if ($num > 0) { $i = 0; - $staticcontrat = new Contrat($db); - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); - print 'contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; - print ''; - $companystatic->id = $objp->rowid; - $companystatic->name = $objp->name; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->canvas = $objp->canvas; + + $companystatic->id = $objp->rowid; + $companystatic->name = $objp->name; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; - $companystatic->email = $objp->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''."\n"; - print "".$staticcontrat->LibStatut($obj->statut, 3)."\n"; + $companystatic->email = $objp->email; + + print ''; + print 'contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.$staticcontrat->LibStatut($obj->statut, 3).''; + print ''; $i++; } - print ""; - print "

"; } + + addSummaryTableLine(2, $num); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened proposals */ -if (!empty($conf->propal->enabled) && $user->rights->propal->lire) -{ +if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $langs->load("propal"); $sql = "SELECT s.nom as name, s.rowid, s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= ", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; @@ -705,33 +634,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY p.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - StartSimpleTableHeader("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $propalstatic->id = $obj->propalid; + $propalstatic->ref = $obj->ref; + $propalstatic->ref_client = $obj->ref_client; + $propalstatic->total_ht = $obj->total_ht; + $propalstatic->total_tva = $obj->total_tva; + $propalstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print ''; - - $propalstatic->id = $obj->propalid; - $propalstatic->ref = $obj->ref; - $propalstatic->ref_client = $obj->ref_client; - $propalstatic->total_ht = $obj->total_ht; - $propalstatic->total_tva = $obj->total_tva; - $propalstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $propalstatic->getNomUrl(1); @@ -745,58 +680,39 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); print '
'; - print ""; - print ''; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''."\n"; - print ''."\n"; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''; + + print ''; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total")."".price($total)." "; - } - print ""; - print "

"; } + + addSummaryTableLine(5, $num, $nbofloop, $total, "NoProposal", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } + /* * Opened Order */ -if (!empty($conf->commande->enabled) && $user->rights->commande->lire) -{ +if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $langs->load("orders"); $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; - $sql .= ", s.code_client"; + $sql .= ", s.code_client"; $sql .= ", s.entity"; - $sql .= ", s.email"; + $sql .= ", s.email"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -807,33 +723,39 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) if ($socid) $sql .= " AND s.rowid = ".$socid; $sql .= " ORDER BY c.rowid DESC"; - $result = $db->query($sql); - if ($result) - { + $resql = $db->query($sql); + if ($resql) { $total = 0; - $num = $db->num_rows($result); - $i = 0; - if ($num > 0) - { - StartSimpleTableHeader("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); + $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); + startSimpleTable("OrdersOpened", "commande/list.php", "search_status=1", 4, $num); - $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); - while ($i < $nbofloop) - { - $obj = $db->fetch_object($result); + if ($num > 0) { + $i = 0; + + while ($i < $nbofloop) { + $obj = $db->fetch_object($resql); + + $orderstatic->id = $obj->commandeid; + $orderstatic->ref = $obj->ref; + $orderstatic->ref_client = $obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; + $companystatic->entity = $obj->entity; + $companystatic->email = $obj->email; print ''; // Ref print ''; - - $orderstatic->id = $obj->commandeid; - $orderstatic->ref = $obj->ref; - $orderstatic->ref_client = $obj->ref_client; - $orderstatic->total_ht = $obj->total_ht; - $orderstatic->total_tva = $obj->total_tva; - $orderstatic->total_ttc = $obj->total_ttc; - print ''; print '
'; print $orderstatic->getNomUrl(1); @@ -847,49 +769,27 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid; print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); print '
'; - print ""; - print ''; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->canvas = $obj->canvas; - $companystatic->entity = $obj->entity; - $companystatic->email = $obj->email; - print $companystatic->getNomUrl(1, 'customer', 44); - print ''; - print ''; - print dol_print_date($db->jdate($obj->dp), 'day').''."\n"; - if (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; - } else { - print ''.price($obj->total_ttc).''; - } - print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''."\n"; + print ''.$companystatic->getNomUrl(1, 'customer', 44).''; + print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; + print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''; print ''."\n"; + $i++; $total += $obj->total_ttc; } - if ($num > $nbofloop) - { - print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).""; - } elseif ($total > 0) - { - print ''.$langs->trans("Total")."".price($total)." "; - } - print ""; - print "

"; } + + addSummaryTableLine(5, $num, $nbofloop, $num, $total, "None", true); + finishSimpleTable(true); + $db->free($resql); } else { dol_print_error($db); } } - - print '
'; $parameters = array('user' => $user); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 144a420a542..d7bf227a304 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8673,8 +8673,10 @@ function currentToken() /** * Start a table with headers and a optinal clickable number - * (don't forget to close the table with a HTML TABLE and a HTML DIV element) - * + * (don't forget to use "finishSimpleTable()" after the last table row) + * + * @see finishSimpleTable + * * @param string $header The first left header of the table (automatic translated) * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") @@ -8682,7 +8684,7 @@ function currentToken() * @param integer $number (optional) The number that is shown right after the first header, when not set the link is shown on the right side of the header as "FullList" * @return void */ -function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) +function startSimpleTable($header, $link = "", $arguments = "", $emptyRows = 0, $number = -1) { global $langs; @@ -8733,3 +8735,69 @@ function StartSimpleTableHeader($header, $link = "", $arguments = "", $emptyRows print ''; } + +/** + * Add the correct HTML close tags for "startSimpleTable(...)" + * (use after the last table line) + * + * @see startSimpleTable + * + * @param bool $addLineBreak (optional) Add a extra line break after the complete table (\) + * + * @return void + */ +function finishSimpleTable($addLineBreak = false) +{ + print ''; + print '
'; + + if($addLineBreak) { + print '
'; + } +} + +function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false) +{ + global $langs; + + if($num === 0) { + print ''; + print ''.$langs->trans($noneWord ).''; + print ''; + return; + } + + if($nbofloop === 0) + { + // don't show a summary line + return; + } + + if ($num === 0) { + $colspan = $tableColumnCount; + } + elseif ($num > $nbofloop) { + $colspan = $tableColumnCount; + } else { + $colspan = $tableColumnCount - 1; + } + + if($extraRightColumn) { + $colspan--; + } + + print ''; + + if($nbofloop > 0 && $num > $nbofloop) { + print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; + } else { + print ' '.$langs->trans("Total").''; + print ''.price($total).''; + } + + if($extraRightColumn) { + print ''; + } + + print ''; +} From be32a24eed2ac536376d88d8522ab73d72eb7c71 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 10 Sep 2020 09:07:10 +0000 Subject: [PATCH 074/173] Fixing style errors. --- htdocs/comm/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index dcb6b3b92b5..555b5895fac 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -158,7 +158,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $num = $db->num_rows($resql); $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=0", 2, $num); - + if ($num > 0) { $i = 0; @@ -171,7 +171,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; @@ -309,7 +309,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; @@ -653,7 +653,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; - + $companystatic->id = $obj->rowid; $companystatic->name = $obj->name; $companystatic->client = $obj->client; From 6a9cadd9d4d753fbac4617e0366cabb98acc16a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 11:09:20 +0200 Subject: [PATCH 075/173] Removed warning --- htdocs/filefunc.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index d9f3d3a14c3..8912fd2a299 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -276,8 +276,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; //print memory_get_usage(); -// If password is encoded, we decode it -if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) +// If password is encoded, we decode it. Note: When page is called for install, $dolibarr_main_db_pass may not be defined yet. +if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { From 912999a6b6b82c6d18db32416aae4ccc0eda9921 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 27 Aug 2020 11:11:53 +0200 Subject: [PATCH 076/173] Creation box --- htdocs/core/boxes/box_validated_projects.php | 205 +++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 htdocs/core/boxes/box_validated_projects.php diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php new file mode 100644 index 00000000000..9fffc92963f --- /dev/null +++ b/htdocs/core/boxes/box_validated_projects.php @@ -0,0 +1,205 @@ + + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_project.php + * \ingroup projet + * \brief Module to show Projet activity of the current Year + */ +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box to show last projet + */ +class box_project extends ModeleBoxes +{ + public $boxcode="project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + $this->boxlabel = "OpenedProjects"; + + $this->hidden = ! ($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max=$max; + + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; + + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); + + $socid=0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " AND p.fk_statut = 1"; // Only open projects + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + + $sql.= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); + + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; + + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); + + $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; + $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; + $sql.=" AND p.rowid = ".$objp->rowid; + $resultTask = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", + ); + else + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } + + + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} From c9833c501d38dab811c61320de0de6f8621765db Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 27 Aug 2020 17:23:53 +0200 Subject: [PATCH 077/173] SQL + insertion champs dans box --- htdocs/core/boxes/box_validated_projects.php | 105 ++++++------------- htdocs/core/modules/modProjet.class.php | 2 + 2 files changed, 35 insertions(+), 72 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 9fffc92963f..02121612aea 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -20,18 +20,18 @@ */ /** - * \file htdocs/core/boxes/box_project.php + * \file htdocs/core/boxes/box_validated_projects.php * \ingroup projet - * \brief Module to show Projet activity of the current Year + * \brief Module to show validated projects whose tasks are assigned to the connected person, without any time entered by the connected person */ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box to show last projet */ -class box_project extends ModeleBoxes +class box_validated_projects extends ModeleBoxes { - public $boxcode="project"; + public $boxcode="validated_project"; public $boximg="object_projectpub"; public $boxlabel; //var $depends = array("projet"); @@ -60,7 +60,7 @@ class box_project extends ModeleBoxes $langs->loadLangs(array('boxes', 'projects')); $this->db = $db; - $this->boxlabel = "OpenedProjects"; + $this->boxlabel = "ValidatedProjects"; $this->hidden = ! ($user->rights->projet->lire); } @@ -81,11 +81,12 @@ class box_project extends ModeleBoxes $totalnb = 0; $totalnbTask=0; - $textHead = $langs->trans("OpenedProjects"); + $textHead = $langs->trans("ValidatedProjects"); $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); // list the summary of the orders if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); @@ -96,17 +97,20 @@ class box_project extends ModeleBoxes $projectsListId=''; if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok - $sql.= " AND p.fk_statut = 1"; // Only open projects - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - - $sql.= " ORDER BY p.datec DESC"; - //$sql.= $this->db->plimit($max, 0); - + $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; + $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)"; + $sql.= " AND c.fk_socpeople = ".$user->id; + $sql.= " GROUP BY p.ref"; + $sql.= " ORDER BY p.dateo ASC"; +var_dump($user->id); $result = $this->db->query($sql); - if ($result) { $num = $this->db->num_rows($result); $i = 0; @@ -114,10 +118,10 @@ class box_project extends ModeleBoxes $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; + $projectstatic->ref = $objp->Ref; + $projectstatic->customer = $objp->Client; + $projectstatic->startDate = $objp->startDate; + $projectstatic->taskNumber = $objp->taskNumber; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', @@ -127,67 +131,24 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, + 'text' => $objp->Client, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; - $resultTask = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", - ); - else - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->startDate, + ); - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), + ); $i++; } } } - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); } /** diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 77d339da035..ad77f85dfb5 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -144,6 +144,8 @@ class modProjet extends DolibarrModules $r++; $this->boxes[$r][1] = "box_task.php"; $r++; + $this->boxes[$r][1] = "box_validated_projects.php"; + $r++; // Permissions $this->rights = array(); From 76d5ce18caa83f375561ead51f1300ac178c04f6 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 14:07:35 +0200 Subject: [PATCH 078/173] Titres + lien cliquable client + traductions --- htdocs/core/boxes/box_validated_projects.php | 54 ++++++++++++++++---- htdocs/langs/fr_FR/boxes.lang | 1 + 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 02121612aea..e06da942b8a 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -100,7 +100,7 @@ class box_validated_projects extends ModeleBoxes $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; - $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; @@ -109,12 +109,30 @@ class box_validated_projects extends ModeleBoxes $sql.= " AND c.fk_socpeople = ".$user->id; $sql.= " GROUP BY p.ref"; $sql.= " ORDER BY p.dateo ASC"; -var_dump($user->id); + $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; - while ($i < min($num, $max)) { + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => "Reference projet", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Client', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Date debut de projet', + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => 'Nombre de mes tâches sans temps saisi', + ); + $i++; + + while ($i < min($num+1, $max+1)) { $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; @@ -122,30 +140,44 @@ var_dump($user->id); $projectstatic->customer = $objp->Client; $projectstatic->startDate = $objp->startDate; $projectstatic->taskNumber = $objp->taskNumber; - +//var_dump($projectstatic->getNomUrl(1)); $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => $projectstatic->getNomUrl(1), 'asis' => 1 ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->Client, - ); + $sql = 'SELECT nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; + $resql = $this->db->query($sql); + if ($resql){ + $socstatic = new Societe($this->db); + $obj = $this->db->fetch_object($resql); + $socstatic->nom = $obj->nom; + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $socstatic->getNomUrl(1), + 'asis' => 1 + ); + } + else { + dol_print_error($this->db); + } $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'td' => 'class="center"', 'text' => $objp->startDate, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', + 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), + 'asis' => 1 ); $i++; } - } + }else { + dol_print_error($this->db); + } } diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index e2964afd6a3..7b633336c34 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -104,3 +104,4 @@ BoxTitleLastCustomerShipments=Les %s dernières expéditions clients NoRecordedShipments=Aucune expédition client # Pages AccountancyHome=Comptabilité +ValidatedProjects = Projets ouverts dont les tâches me sont affectées et n'ont pas de temps saisi From 281b52db752fc9664cc68043192754b66d3fbbd3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 15:45:10 +0200 Subject: [PATCH 079/173] =?UTF-8?q?lien=20cliquable=20nbTache=20vers=20lis?= =?UTF-8?q?te=20tache=20filtr=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index e06da942b8a..bd76fc9c4c9 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -140,7 +140,7 @@ class box_validated_projects extends ModeleBoxes $projectstatic->customer = $objp->Client; $projectstatic->startDate = $objp->startDate; $projectstatic->taskNumber = $objp->taskNumber; -//var_dump($projectstatic->getNomUrl(1)); + $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => $projectstatic->getNomUrl(1), @@ -171,7 +171,8 @@ class box_validated_projects extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), - 'asis' => 1 + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_progresscalc=0%&search_user_id='.$user->id, ); $i++; } From 343b39e31ff8868a5b6e1a906858242240b16850 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 28 Aug 2020 16:59:50 +0200 Subject: [PATCH 080/173] FIX : lien cliquable tiers --- htdocs/core/boxes/box_validated_projects.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index bd76fc9c4c9..0683b771a9b 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -147,16 +147,16 @@ class box_validated_projects extends ModeleBoxes 'asis' => 1 ); - $sql = 'SELECT nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; + $sql = 'SELECT rowid, nom FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->Client; $resql = $this->db->query($sql); if ($resql){ $socstatic = new Societe($this->db); $obj = $this->db->fetch_object($resql); - $socstatic->nom = $obj->nom; $this->info_box_contents[$i][] = array( 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $socstatic->getNomUrl(1), - 'asis' => 1 + 'text' => $obj->nom, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj->rowid ); } else { From 5a3016594752b80422597a24b2b8d81f9b13a5ff Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 31 Aug 2020 10:21:10 +0200 Subject: [PATCH 081/173] FIX : correction redirection pour nbTache --- htdocs/core/boxes/box_validated_projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 0683b771a9b..f1e7fda8a2e 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -172,7 +172,7 @@ class box_validated_projects extends ModeleBoxes 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), 'asis' => 1, - 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_progresscalc=0%&search_user_id='.$user->id, + 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_timespend==0&search_user_id='.$user->id, ); $i++; } From acfae190c381170499ce2fa9dbdf0b46e4860e93 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 2 Sep 2020 09:15:15 +0200 Subject: [PATCH 082/173] =?UTF-8?q?FIX=20:=20suppression=20lien=20nbT?= =?UTF-8?q?=C3=A2che?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index f1e7fda8a2e..fc190b9d5d3 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -172,7 +172,6 @@ class box_validated_projects extends ModeleBoxes 'td' => 'class="center"', 'text' => $objp->taskNumber." ".$langs->trans("Tasks"), 'asis' => 1, - 'url' => DOL_URL_ROOT.'/custom/cligp/tasks/projettasks.php?id='.$objp->rowid.'&search_timespend==0&search_user_id='.$user->id, ); $i++; } From 419b2b71a924142de3053b3950cae35468617ee2 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 2 Sep 2020 10:52:30 +0200 Subject: [PATCH 083/173] =?UTF-8?q?FIX=20:=20modif=20requete=20SQL,=20pris?= =?UTF-8?q?e=20en=20compte=20user=20connect=C3=A9=20pour=20saisie=20des=20?= =?UTF-8?q?temps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/boxes/box_validated_projects.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index fc190b9d5d3..2bf303d9254 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -100,12 +100,12 @@ class box_validated_projects extends ModeleBoxes $sql = "SELECT p.rowid, p.ref as Ref, p.fk_soc as Client, p.dateo as startDate,"; $sql.= " (SELECT COUNT(t.rowid) FROM ".MAIN_DB_PREFIX."projet_task AS t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; - $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)) AS 'taskNumber'"; + $sql.= " WHERE t.fk_projet = p.rowid AND c.fk_c_type_contact != 160 AND c.fk_socpeople = ".$user->id." AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")) AS 'taskNumber'"; $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact AS c ON t.rowid = c.element_id"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects - $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time)"; + $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; $sql.= " AND c.fk_socpeople = ".$user->id; $sql.= " GROUP BY p.ref"; $sql.= " ORDER BY p.dateo ASC"; From b4942707bbb4cc719df7f22ac29a0523d0a67059 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 10 Sep 2020 11:23:45 +0200 Subject: [PATCH 084/173] EN_US Traductions --- htdocs/langs/en_US/boxes.lang | 1 + htdocs/langs/fr_FR/boxes.lang | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index ab89bc10c4b..14db79809bc 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -104,3 +104,4 @@ BoxTitleLastCustomerShipments=Latest %s customer shipments NoRecordedShipments=No recorded customer shipment # Pages AccountancyHome=Accountancy +ValidatedProjects=Validated projects diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 7b633336c34..e2964afd6a3 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -104,4 +104,3 @@ BoxTitleLastCustomerShipments=Les %s dernières expéditions clients NoRecordedShipments=Aucune expédition client # Pages AccountancyHome=Comptabilité -ValidatedProjects = Projets ouverts dont les tâches me sont affectées et n'ont pas de temps saisi From 3f8b2153ea18b34e41b792a9f52eab4179460d4c Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:25:35 +0200 Subject: [PATCH 085/173] fix sticker Ci and add missing doc --- htdocs/core/lib/functions.lib.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d7bf227a304..4b65f3eedf3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8751,23 +8751,34 @@ function finishSimpleTable($addLineBreak = false) print ''; print ''; - if($addLineBreak) { + if ($addLineBreak) { print '
'; } } +/** + * Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") + * + * @param integer $tableColumnCount The complete count columns of the table + * @param integer $num The count of the rows of the table, when it is zero (0) the "$noneWord" is shown instead + * @param integer $nbofloop (optional) The maximum count of rows thaht the table show (when it is zero (0) no summary line will show, expect "$noneWord" when $num === 0) + * @param integer $total (optional) The total value thaht is shown after when the table has minimum of one entire + * @param string $noneWord (optional) The word that is shown when the table has no entires ($num === 0) + * @param boolean $extraRightColumn (optional) Add a addtional column after the summary word and total number + * @return void + */ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false) { global $langs; - if($num === 0) { + if ($num === 0) { print ''; print ''.$langs->trans($noneWord ).''; print ''; return; } - if($nbofloop === 0) + if ($nbofloop === 0) { // don't show a summary line return; @@ -8782,20 +8793,20 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $colspan = $tableColumnCount - 1; } - if($extraRightColumn) { + if ($extraRightColumn) { $colspan--; } print ''; - if($nbofloop > 0 && $num > $nbofloop) { + if ($nbofloop > 0 && $num > $nbofloop) { print ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; } else { print ' '.$langs->trans("Total").''; print ''.price($total).''; } - if($extraRightColumn) { + if ($extraRightColumn) { print ''; } From 2292f83258e91d41b867af7930734c77d2a8c1f9 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 11:26:17 +0200 Subject: [PATCH 086/173] fix sticker ci --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4b65f3eedf3..db261bcf8d2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8674,9 +8674,9 @@ function currentToken() /** * Start a table with headers and a optinal clickable number * (don't forget to use "finishSimpleTable()" after the last table row) - * + * * @see finishSimpleTable - * + * * @param string $header The first left header of the table (automatic translated) * @param string $link (optional) The link to a internal dolibarr page, when click on the number (without the first "/") * @param string $arguments (optional) Additional arguments for the link (e.g. "search_status=0") @@ -8739,11 +8739,11 @@ function startSimpleTable($header, $link = "", $arguments = "", $emptyRows = 0, /** * Add the correct HTML close tags for "startSimpleTable(...)" * (use after the last table line) - * + * * @see startSimpleTable * * @param bool $addLineBreak (optional) Add a extra line break after the complete table (\) - * + * * @return void */ function finishSimpleTable($addLineBreak = false) From 0fc24366e12bcd97354f52bf582ddca60d3d8579 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 10 Sep 2020 09:28:05 +0000 Subject: [PATCH 087/173] Fixing style errors. --- htdocs/core/boxes/box_validated_projects.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index 2bf303d9254..378aea61df5 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -86,7 +86,6 @@ class box_validated_projects extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($this->db); @@ -179,8 +178,6 @@ class box_validated_projects extends ModeleBoxes dol_print_error($this->db); } } - - } /** From 747d8c32e2aa8012f0678f749d8d63ee3bd3ae55 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 10 Sep 2020 12:29:01 +0200 Subject: [PATCH 088/173] Fix Sticker CI (again :'-( ) --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index db261bcf8d2..430ca76ddb0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8759,7 +8759,7 @@ function finishSimpleTable($addLineBreak = false) /** * Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") * - * @param integer $tableColumnCount The complete count columns of the table + * @param integer $tableColumnCount The complete count columns of the table * @param integer $num The count of the rows of the table, when it is zero (0) the "$noneWord" is shown instead * @param integer $nbofloop (optional) The maximum count of rows thaht the table show (when it is zero (0) no summary line will show, expect "$noneWord" when $num === 0) * @param integer $total (optional) The total value thaht is shown after when the table has minimum of one entire @@ -8773,7 +8773,7 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, if ($num === 0) { print ''; - print ''.$langs->trans($noneWord ).''; + print ''.$langs->trans($noneWord).''; print ''; return; } From 7944c21fe549edb84ba2b8234b5bca538fb88f3f Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Thu, 10 Sep 2020 12:32:12 +0200 Subject: [PATCH 089/173] FIX : Wrong redirection --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 36c06cd97f2..c7b651cb93d 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -381,7 +381,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && { $obj = $db->fetch_object($resql); $id = $obj->id; - header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); + header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withproject=1'); exit; } From 9f475a3f93ae9d8cfaa64a899443c8b7ba5fb3df Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 10 Sep 2020 14:01:00 +0200 Subject: [PATCH 090/173] FIX API variable error return Some modules, when there is no value, delete the variables so don't find variable can be normal. Error 404 is better than 500 with error servor (same as other object when not found) ie thirdparties, contacts invoices...) --- htdocs/api/class/api_setup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 5dade088fd0..58b8954762c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1413,7 +1413,7 @@ class Setup extends DolibarrApi * @url GET conf/{constantname} * * @throws RestException 403 Forbidden - * @throws RestException 500 Error Bad or unknown value for constantname + * @throws RestException 404 Error Bad or unknown value for constantname */ public function getConf($constantname) { @@ -1425,7 +1425,7 @@ class Setup extends DolibarrApi } if (!preg_match('/^[a-zA-Z0-9_]+$/', $constantname) || !isset($conf->global->$constantname)) { - throw new RestException(500, 'Error Bad or unknown value for constantname'); + throw new RestException(404, 'Error Bad or unknown value for constantname'); } if (preg_match('/(_pass|_pw|password|secret|_key|key$)/i', $constantname)) { throw new RestException(403, 'Forbidden'); From 753330e499dab9d87b3d7466b5a2c1685c205dc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 15:43:50 +0200 Subject: [PATCH 091/173] Fix sort order of import profiles. --- htdocs/imports/class/import.class.php | 2 +- htdocs/imports/import.php | 28 +++++++------- htdocs/imports/index.php | 53 --------------------------- 3 files changed, 15 insertions(+), 68 deletions(-) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 12dfc5d19e9..72d1eb16f66 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -171,7 +171,7 @@ class Import // Sql request to run after import $this->array_import_run_sql_after[$i] = (isset($module->import_run_sql_after_array[$r]) ? $module->import_run_sql_after_array[$r] : ''); // Module - $this->array_import_module[$i] = $module; + $this->array_import_module[$i] = array('position_of_profile'=>($module->module_position.'-'.$module->import_code[$r]), 'module'=>$module); dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".count($module->import_fields_array[$r])); $i++; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 1ca191f5124..d886796f7b0 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -346,17 +346,17 @@ if ($step == 1 || !$datatoimport) if (count($objimport->array_import_module)) { - $sortedarrayofmodules = dol_sort_array($objimport->array_import_module, 'module_position', 'asc', 0, 0, 1); + $sortedarrayofmodules = dol_sort_array($objimport->array_import_module, 'position_of_profile', 'asc', 0, 0, 1); foreach ($sortedarrayofmodules as $key => $value) { - //var_dump($objimport->array_import_code[$key]); + //var_dump($key.' '.$value['position_of_profile'].' '.$value['import_code'].' '.$objimport->array_import_module[$key]['module']->getName().' '.$objimport->array_import_code[$key]); print ''; - $titleofmodule = $objimport->array_import_module[$key]->getName(); + $titleofmodule = $objimport->array_import_module[$key]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; print ''; - print img_object($objimport->array_import_module[$key]->getName(), $objimport->array_import_icon[$key]).' '; + print img_object($objimport->array_import_module[$key]['module']->getName(), $objimport->array_import_icon[$key]).' '; print $objimport->array_import_label[$key]; print ''; if ($objimport->array_import_perms[$key]) @@ -400,7 +400,7 @@ if ($step == 2 && $datatoimport) // Module print ''.$langs->trans("Module").''; print ''; - $titleofmodule = $objimport->array_import_module[0]->getName(); + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; @@ -409,7 +409,7 @@ if ($step == 2 && $datatoimport) // Lot de donnees a importer print ''.$langs->trans("DatasetToImport").''; print ''; - print img_object($objimport->array_import_module[0]->getName(), $objimport->array_import_icon[0]).' '; + print img_object($objimport->array_import_module[0]['module']->getName(), $objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print ''; @@ -490,7 +490,7 @@ if ($step == 3 && $datatoimport) // Module print ''.$langs->trans("Module").''; print ''; - $titleofmodule = $objimport->array_import_module[0]->getName(); + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; @@ -499,7 +499,7 @@ if ($step == 3 && $datatoimport) // Lot de donnees a importer print ''.$langs->trans("DatasetToImport").''; print ''; - print img_object($objimport->array_import_module[0]->getName(), $objimport->array_import_icon[0]).' '; + print img_object($objimport->array_import_module[0]['module']->getName(), $objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print ''; @@ -773,7 +773,7 @@ if ($step == 4 && $datatoimport) // Module print ''.$langs->trans("Module").''; print ''; - $titleofmodule = $objimport->array_import_module[0]->getName(); + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; @@ -782,7 +782,7 @@ if ($step == 4 && $datatoimport) // Lot de donnees a importer print ''.$langs->trans("DatasetToImport").''; print ''; - print img_object($objimport->array_import_module[0]->getName(), $objimport->array_import_icon[0]).' '; + print img_object($objimport->array_import_module[0]['module']->getName(), $objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print ''; @@ -1239,7 +1239,7 @@ if ($step == 5 && $datatoimport) // Module print ''.$langs->trans("Module").''; print ''; - $titleofmodule = $objimport->array_import_module[0]->getName(); + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; @@ -1248,7 +1248,7 @@ if ($step == 5 && $datatoimport) // Lot de donnees a importer print ''.$langs->trans("DatasetToImport").''; print ''; - print img_object($objimport->array_import_module[0]->getName(), $objimport->array_import_icon[0]).' '; + print img_object($objimport->array_import_module[0]['module']->getName(), $objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print ''; @@ -1662,7 +1662,7 @@ if ($step == 6 && $datatoimport) // Module print ''.$langs->trans("Module").''; print ''; - $titleofmodule = $objimport->array_import_module[0]->getName(); + $titleofmodule = $objimport->array_import_module[0]['module']->getName(); // Special cas for import common to module/services if (in_array($objimport->array_import_code[0], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) $titleofmodule = $langs->trans("ProductOrService"); print $titleofmodule; @@ -1671,7 +1671,7 @@ if ($step == 6 && $datatoimport) // Lot de donnees a importer print ''.$langs->trans("DatasetToImport").''; print ''; - print img_object($objimport->array_import_module[0]->getName(), $objimport->array_import_icon[0]).' '; + print img_object($objimport->array_import_module[0]['module']->getName(), $objimport->array_import_icon[0]).' '; print $objimport->array_import_label[0]; print ''; diff --git a/htdocs/imports/index.php b/htdocs/imports/index.php index 365df6086f4..bc68b53cfd0 100644 --- a/htdocs/imports/index.php +++ b/htdocs/imports/index.php @@ -45,69 +45,18 @@ llxHeader('', $langs->trans("ImportArea"), 'EN:Module_Imports_En|FR:Module_Impor print load_fiche_titre($langs->trans("ImportArea")); print $langs->trans("FormatedImportDesc1").'
'; -//print $langs->trans("FormatedImportDesc2").'
'; print '
'; -//print '
'; - - -// List of import set -/* -print '
'; -print ''; -print ''; -print ''; -print ''; -//print ''; -print ''; - -if (count($import->array_import_code)) -{ - foreach ($import->array_import_code as $key => $value) - { - print ''; - // print ''; - print ''; - - } -} -else -{ - print ''; -} -print '
'.$langs->trans("Module").''.$langs->trans("ImportableDatas").' 
'; - print img_object($import->array_import_module[$key]->getName(),$import->array_import_module[$key]->picto).' '; - print $import->array_import_module[$key]->getName(); - print ''; - $string=$langs->trans($import->array_import_label[$key]); - print ($string!=$import->array_import_label[$key]?$string:$import->array_import_label[$key]); - print ''; - // print ''.img_picto($langs->trans("NewImport"),'filenew').''; - // print '
'.$langs->trans("NoImportableData").'
'; -print '
'; -print '
'; -*/ - print '
'; if (count($import->array_import_code)) { - //if ($user->rights->import->run) - //{ print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import'); - //} - //else - //{ - // print ''.$langs->trans("NewImport").''; - //} } print '
'; print '
'; -//print '
'; - - // List of available import format print '
'; print ''; @@ -136,8 +85,6 @@ print '
'; print '
'; -//print '
'; - // End of page llxFooter(); $db->close(); From 1da99a8fcd9419f422acac1464c44106a8bf998e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 15:49:13 +0200 Subject: [PATCH 092/173] Add log to debug travis error --- htdocs/core/lib/files.lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index fb6f25eee4b..0296aa7acbe 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1168,18 +1168,20 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $reshook = $hookmanager->executeHooks('deleteFile', $parameters, $object); } - if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko + if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok and replace, -1 = ko { if ($reshook < 0) return false; return true; } else { //print "x".$file." ".$disableglob;exit; + dol_syslog("reshook=".$reshook); $file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && !empty($file_osencoded)) { $ok = true; $globencoded = str_replace('[', '\[', $file_osencoded); $globencoded = str_replace(']', '\]', $globencoded); + dol_syslog("globencoded=".$globencoded); $listofdir = glob($globencoded); if (!empty($listofdir) && is_array($listofdir)) { @@ -1220,7 +1222,9 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, // If error because it does not exists, we should return true, and we should return false if this is a permission problem } } - } else dol_syslog("No files to delete found", LOG_DEBUG); + } else { + dol_syslog("No files to delete found", LOG_DEBUG); + } } else { $ok = false; if ($nophperrors) $ok = @unlink($file_osencoded); From ed3f1c29ef17a40fe6d041e1795ac731d059f8ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 15:52:09 +0200 Subject: [PATCH 093/173] more log --- htdocs/core/lib/files.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0296aa7acbe..c10edc58b78 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1183,6 +1183,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $globencoded = str_replace(']', '\]', $globencoded); dol_syslog("globencoded=".$globencoded); $listofdir = glob($globencoded); + dol_syslog("listofdir=".joint(', ', $listofdir)); if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename) From bcab13c39587946c6d25728153b79a5d56265039 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 15:52:47 +0200 Subject: [PATCH 094/173] Fix typo --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index c10edc58b78..50550e3feb6 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1183,7 +1183,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, $globencoded = str_replace(']', '\]', $globencoded); dol_syslog("globencoded=".$globencoded); $listofdir = glob($globencoded); - dol_syslog("listofdir=".joint(', ', $listofdir)); + dol_syslog("listofdir=".join(', ', $listofdir)); if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename) From f06737097f1add3673b3e1ada92545ab91b03724 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 16:37:42 +0200 Subject: [PATCH 095/173] Look and feel v13 --- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/societe/class/societe.class.php | 18 +++++++++--------- htdocs/theme/eldy/global.inc.php | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ac5f8146a8d..b555917e2f3 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1968,7 +1968,7 @@ class Contrat extends CommonObject $label = ''; if ($user->rights->contrat->lire) { - $label = ''.$langs->trans("ShowContract").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1753cf7e8df..436dc185479 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4280,9 +4280,9 @@ class Product extends CommonObject if ($maxlength) { $newref = dol_trunc($newref, $maxlength, 'middle'); } - if ($this->type == Product::TYPE_PRODUCT) { $label = ''.$langs->trans("Product").''; + if ($this->type == Product::TYPE_PRODUCT) { $label = img_picto('', 'product').' '.$langs->trans("Product").''; } - if ($this->type == Product::TYPE_SERVICE) { $label = ''.$langs->trans("Service").''; + if ($this->type == Product::TYPE_SERVICE) { $label = img_picto('', 'service').' '.$langs->trans("Service").''; } if (!empty($this->ref)) { $label .= '
'.$langs->trans('ProductRef').': '.$this->ref; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b6d57191dce..5a4b7c77448 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2360,42 +2360,42 @@ class Societe extends CommonObject if ($option == 'customer' || $option == 'compta' || $option == 'category') { - $label .= ''.$langs->trans("Customer").''; + $label .= img_picto('', $this->picto).' '.$langs->trans("Customer").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("Prospect").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("Supplier").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ''; + $label .= img_picto('', $this->picto).' '.$langs->trans("ThirdParty").''; $linkstart = ' Date: Thu, 10 Sep 2020 17:08:51 +0200 Subject: [PATCH 096/173] Fix trans, add log --- htdocs/core/lib/files.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 50550e3feb6..708bb9d7987 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1170,6 +1170,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok and replace, -1 = ko { + dol_syslog("reshook=".$reshook); if ($reshook < 0) return false; return true; } else { From 3eba707e0f30aef98e525d5c9ba8cb1bf18e4ab3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 17:09:32 +0200 Subject: [PATCH 097/173] Trans --- htdocs/langs/en_US/projects.lang | 8 ++++---- htdocs/theme/eldy/global.inc.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 670fff06f03..f5f6bf3dd9d 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -76,12 +76,12 @@ MyActivities=My tasks/activities MyProjects=My projects MyProjectsArea=My projects Area DurationEffective=Effective duration -ProgressDeclared=Declared progress +ProgressDeclared=Declared real progress TaskProgressSummary=Task progress CurentlyOpenedTasks=Curently open tasks -TheReportedProgressIsLessThanTheCalculatedProgressionByX=The declared progress is less %s than the calculated progression -TheReportedProgressIsMoreThanTheCalculatedProgressionByX=The declared progress is more %s than the calculated progression -ProgressCalculated=Calculated progress +TheReportedProgressIsLessThanTheCalculatedProgressionByX=The declared real progress is less %s than the progress on consumption +TheReportedProgressIsMoreThanTheCalculatedProgressionByX=The declared real progress is more %s than the progress on consumption +ProgressCalculated=Progress on consumption WhichIamLinkedTo=which I'm linked to WhichIamLinkedToProject=which I'm linked to project Time=Time diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 9883bb93435..ad52b6d3472 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3632,8 +3632,8 @@ ul.noborder li:nth-child(even):not(.liste_titre) { /* padding: 3px; */ } .boxstats { - padding-left: 3px; - padding-right: 3px; + padding-left: 6px; + padding-right: 6px; padding-top: 2px; padding-bottom: 2px; width: 118px; From ed6a16a3c7d480205ad5ab7a02e742b067300c36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 17:17:31 +0200 Subject: [PATCH 098/173] FIX look and feel v12 --- htdocs/compta/tva/document.php | 2 +- htdocs/core/lib/vat.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index cb26304cde5..830dfb78d3a 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -106,7 +106,7 @@ if ($object->id) $head = vat_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill'); + dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
'; // Label of social contribution diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php index 0bc3bb66e90..68e52a142a3 100644 --- a/htdocs/core/lib/vat.lib.php +++ b/htdocs/core/lib/vat.lib.php @@ -37,7 +37,7 @@ function vat_prepare_head($object) $head = array(); $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id; - $head[$tab][1] = $langs->trans('Card'); + $head[$tab][1] = $langs->trans('VATPayment'); $head[$tab][2] = 'card'; $tab++; From bd540339750541d71718080a37063f1e3a3d6050 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 17:35:18 +0200 Subject: [PATCH 099/173] Look and feel v13 --- htdocs/main.inc.php | 3 ++- htdocs/theme/eldy/dropdown.inc.php | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0e656c7514b..ed5aedd67ce 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1800,7 +1800,8 @@ function top_menu_user($hideloginname = 0, $urllogout = '') if ($user->datepreviouslogin) { $btnUser .= ' '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser').'
'; } - $btnUser .= ' '.$langs->trans("Version").' '.$appli.' + //$btnUser .= ' '.$langs->trans("Version").' '.$appli.''; + $btnUser .= '

diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 3665f43d9c4..12f34ed50ac 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -217,6 +217,7 @@ a.top-menu-dropdown-link { } .dropdown-menu > .user-footer { + border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; } @@ -225,8 +226,9 @@ a.top-menu-dropdown-link { clear: both; } - .dropdown-menu > .bookmark-footer{ + border-top: 1px solid #f0f0f0; + background-color: #f9f9f9; padding: 10px; } @@ -239,7 +241,6 @@ a.top-menu-dropdown-link { } .dropdown-menu > .bookmark-body, .dropdown-body{ - padding: 10px 0; overflow-y: auto; max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 110px) ; @@ -333,7 +334,7 @@ a.top-menu-dropdown-link { display: block !important; box-sizing: border-box; width: 100%; - padding: .25rem 1.5rem .25rem 1rem; + padding: .3em 1.5em .4em 1em; clear: both; font-weight: 400; color: #212529 !important; From 8d93b762581a93d02f372ff8a6db4ab9c76aac2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 17:49:05 +0200 Subject: [PATCH 100/173] Clean code --- htdocs/core/class/hookmanager.class.php | 10 +++++----- htdocs/core/lib/files.lib.php | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 089e9fb6717..c1d11c9290b 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (!is_array($this->hooks) || empty($this->hooks)) return ''; + if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); @@ -225,14 +225,14 @@ class HookManager // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted = array(); - $resaction = 0; $error = 0; $result = ''; + $resaction = 0; $error = 0; foreach ($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context { if (!empty($modules)) { foreach ($modules as $module => $actionclassinstance) { - //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."
\n"; + //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
\n"; // test to avoid running twice a hook, when a module implements several active contexts if (in_array($module, $modulealreadyexecuted)) continue; @@ -290,7 +290,7 @@ class HookManager } } - //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."
\n"; + //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
\n"; unset($actionclassinstance->results); unset($actionclassinstance->resprints); @@ -298,6 +298,6 @@ class HookManager } } - return ($error ?-1 : $resaction); + return ($error ? -1 : $resaction); } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 708bb9d7987..ba96efbfd62 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1155,6 +1155,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, return false; } + $reshook = 0; if (empty($nohook)) { $hookmanager->initHooks(array('fileslib')); @@ -1174,17 +1175,13 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, if ($reshook < 0) return false; return true; } else { - //print "x".$file." ".$disableglob;exit; - dol_syslog("reshook=".$reshook); $file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && !empty($file_osencoded)) { $ok = true; $globencoded = str_replace('[', '\[', $file_osencoded); $globencoded = str_replace(']', '\]', $globencoded); - dol_syslog("globencoded=".$globencoded); $listofdir = glob($globencoded); - dol_syslog("listofdir=".join(', ', $listofdir)); if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename) From 7e7dec93060ffebb915258babd6a2c6acfa014f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 18:02:06 +0200 Subject: [PATCH 101/173] FIX Look and feel v12 --- htdocs/core/lib/propal.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index fcdf4bbb79d..a1dab5cd6cb 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -38,7 +38,7 @@ function propal_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; - $head[$h][1] = $langs->trans('ProposalCard'); + $head[$h][1] = $langs->trans('Proposal'); $head[$h][2] = 'comm'; $h++; From 0cccaa72714675b2ebe09a24bd2bceb0fb7e409f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 17:17:31 +0200 Subject: [PATCH 102/173] FIX look and feel v12 --- htdocs/compta/tva/document.php | 2 +- htdocs/core/lib/vat.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index fabaf1ee705..0a464c47b54 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -106,7 +106,7 @@ if ($object->id) $head = vat_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill'); + dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
'; // Label of social contribution diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php index 0bc3bb66e90..68e52a142a3 100644 --- a/htdocs/core/lib/vat.lib.php +++ b/htdocs/core/lib/vat.lib.php @@ -37,7 +37,7 @@ function vat_prepare_head($object) $head = array(); $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id; - $head[$tab][1] = $langs->trans('Card'); + $head[$tab][1] = $langs->trans('VATPayment'); $head[$tab][2] = 'card'; $tab++; From 358f8357f95f6d8c8f663f51ead8bc7e0edad6bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 18:25:38 +0200 Subject: [PATCH 103/173] FIX #14703 --- htdocs/compta/bank/class/account.class.php | 5 ++++- htdocs/compta/tva/card.php | 10 +++++----- htdocs/compta/tva/class/tva.class.php | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 07e4abb0197..31d7749a430 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -476,7 +476,7 @@ class Account extends CommonObject * @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'... * @param string $label Descripton * @param float $amount Amount - * @param string $num_chq Numero cheque ou virement + * @param string $num_chq Numero cheque or transfer * @param int $categorie Category id (optionnal) * @param User $user User that create * @param string $emetteur Name of cheque writer @@ -572,15 +572,18 @@ class Account extends CommonObject if (!$result) { $this->error = $this->db->lasterror(); $this->db->rollback(); + return -3; } } $this->db->commit(); + return $accline->id; } else { $this->error = $this->db->lasterror(); $this->db->rollback(); + return -2; } } diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 658c9353a00..6d7c5935418 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -100,16 +100,16 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->label = GETPOST("label", 'alpha'); $object->note = GETPOST("note", 'none'); - if (empty($object->datev)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateValue")), null, 'errors'); - $error++; - } if (empty($object->datep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors'); $error++; } + if (empty($object->datev)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors'); + $error++; + } if (empty($object->type_payment) || $object->type_payment < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c01408f3c9a..668a58c4f77 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -519,6 +519,7 @@ class Tva extends CommonObject $this->amount = price2num(trim($this->amount)); $this->label = trim($this->label); $this->note = trim($this->note); + $this->num_payment = trim($this->num_payment); $this->fk_bank = (int) $this->fk_bank; $this->fk_user_creat = (int) $this->fk_user_creat; $this->fk_user_modif = (int) $this->fk_user_modif; @@ -603,9 +604,9 @@ class Tva extends CommonObject if ($result <= 0) dol_print_error($this->db); if ($this->amount > 0) { - $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), '', '', $user); + $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user); } else { - $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), '', '', $user); + $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user); } // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction From 05a2fc618622e0ec7e2ef4f8450ac2e8190a076d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Sep 2020 19:40:03 +0200 Subject: [PATCH 104/173] Fix rate for tunisia --- htdocs/install/mysql/data/llx_c_tva.sql | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index afd3a762ccc..8138711e8a0 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -295,13 +295,14 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (21 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2132, 213, '5','0','VAT 5%',1); -- TUNISIA (id country=10) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '0','0','VAT Rate 0', 1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0, 0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '6','0','VAT 6%', 1, 1, '4', 0, 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (101,10, '0','0','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (102,10, '12','0','VAT 12%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (103,10, '18','0','VAT 18%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (107,10, '6','0','VAT 6%', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10,'18.18','0','VAT 18%+FODEC', 1, 1, '4', 0, 0); -- UKRAINE (id country=226) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '0','0','VAT Rate 0',1); From 5b364fc5faa44f7bee78f4e3d8d5ecc0b0508625 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 10 Sep 2020 21:56:55 +0200 Subject: [PATCH 105/173] New Accountancy - Add default account for customer deposit --- htdocs/accountancy/admin/defaultaccounts.php | 5 ++++- htdocs/accountancy/class/accountingaccount.class.php | 2 +- htdocs/accountancy/customer/list.php | 8 ++++++++ htdocs/langs/en_US/accountancy.lang | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 96303f36b1d..84ea304a74d 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -75,7 +75,7 @@ if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'; -$list_account[] = '---Other---'; +$list_account[] = '---Others---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; @@ -94,6 +94,9 @@ if ($conf->loan->enabled) { $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; } +if ($conf->societe->enabled) { + $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; +} /* * Actions diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 6936d7499fa..24f14d2ebd2 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -448,7 +448,7 @@ class AccountingAccount extends CommonObject * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) - * @param int $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard' + * @param string $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard' * @return string String with URL */ public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 7790271f842..96750389cc0 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -535,6 +535,14 @@ if ($result) { } } + // Manage Deposit + if ($objp->description == "(DEPOSIT)") { + $accountdeposittoventilated = new AccountingAccount($db); + $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + $objp->code_sell_l = $accountdeposittoventilated->ref; + $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + } + if (!empty($objp->code_sell_p)) { // Value was defined previously } else { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 9b3c9727620..f661ab07fe1 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -172,6 +172,8 @@ ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions +ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Accounting account to register customer deposit + ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for the bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT=Accounting account by default for the bought products in EEC (used if not defined in the product sheet) ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT=Accounting account by default for the bought products and imported out of EEC (used if not defined in the product sheet) From 04329c38b317d0ecf4a7829ca423206b0590dda0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 11 Sep 2020 06:42:22 +0200 Subject: [PATCH 106/173] FIX - Accountancy balance Error SQL on entity --- htdocs/accountancy/bookkeeping/balance.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 456da29d954..ee51560818f 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -267,8 +267,12 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; - $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; - $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; + $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; + $sql .= " WHERE t.entity IN (".getEntity('accountancy').")"; + $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; + $sql .= " GROUP BY t.numero_compte"; + $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); @@ -289,10 +293,10 @@ if ($action != 'export_csv') } print ''; - // Permet d'afficher le compte comptable + // Display the accounting account if (empty($displayed_account) || $root_account_description != $displayed_account) { - // Affiche un Sous-Total par compte comptable + // Display a sub-total per account if ($displayed_account != "") { print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; print " \n"; @@ -321,7 +325,7 @@ if ($action != 'export_csv') print ''; print "\n"; - // Comptabilise le sous-total + // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; } From 8fc9b78b4762e2cf4d957d9c6bd592de57a27b6e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 11 Sep 2020 06:55:03 +0200 Subject: [PATCH 107/173] FIX Problems on FEC format --- .../accountancy/class/accountancyexport.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index bfb08746c16..b3a4430db36 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -689,8 +689,8 @@ class AccountancyExport foreach ($objectLines as $line) { $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); - $date_doc = dol_print_date($line->doc_date, '%Y%m%d'); - $date_valid = dol_print_date($line->date_validated, '%Y%m%d'); + $date_document = dol_print_date($line->doc_date, '%Y%m%d'); + $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal . $separator; @@ -702,25 +702,25 @@ class AccountancyExport print $line->piece_num . $separator; // FEC:EcritureDate - print $date_creation . $separator; + print $date_document . $separator; // FEC:CompteNum print $line->numero_compte . $separator; // FEC:CompteLib - print $line->label_compte . $separator; + print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum print $line->subledger_account . $separator; // FEC:CompAuxLib - print $line->subledger_label . $separator; + print dol_string_unaccent($line->subledger_label) . $separator; // FEC:PieceRef print $line->doc_ref . $separator; // FEC:PieceDate - print $date_doc . $separator; + print dol_string_unaccent($date_creation) . $separator; // FEC:EcritureLib print $line->label_operation . $separator; @@ -738,7 +738,7 @@ class AccountancyExport print $line->date_lettering . $separator; // FEC:ValidDate - print $date_valid . $separator; + print $date_validation . $separator; // FEC:Montantdevise print $line->multicurrency_amount . $separator; From 25d6af2b862b8ebec03cefa2439c60c00d07d786 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 09:55:34 +0200 Subject: [PATCH 108/173] Add global search for misc payments +TODO --- .../bank/class/paymentvarious.class.php | 31 +++++++++++ htdocs/compta/bank/various_payment/list.php | 53 ++++++++++++++++++- htdocs/core/ajax/selectsearchbox.php | 12 +++++ htdocs/langs/en_US/main.lang | 3 +- 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index d33523863a3..bfb522b6e3a 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -95,6 +95,37 @@ class PaymentVarious extends CommonObject public $fk_user_modif; + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + public $fields = array( + // TODO: fill this array + ); + // END MODULEBUILDER PROPERTIES + /** * Constructor * diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9241608db8b..70963e29f6d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -101,6 +101,37 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $typeid = ''; } +$search_all = GETPOSTISSET("search_all") ? trim(GETPOSTISSET("search_all", 'alpha')) : trim(GETPOST('sall')); + +/* +* TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use +* +* +* $object = new PaymentVarious($db); +* +* $search = array(); +* foreach ($object->fields as $key => $val) +* { +* if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); +* } + +* $fieldstosearchall = array(); +* foreach ($object->fields as $key => $val) +* { +* if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +* } +* +*/ + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'v.rowid'=>"Ref", + 'v.label'=>"Label", + 'v.datep'=>"DatePayment", + 'v.datev'=>"DateValue", + 'v.amount'=>$langs->trans("Debit").", ".$langs->trans("Credit"), +); + // Definition of fields for lists $arrayfields = array( 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), @@ -136,8 +167,6 @@ if (empty($reshook)) { * View */ -llxHeader(); - $form = new Form($db); if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); @@ -174,6 +203,7 @@ if ($filtre) { $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); $sql .= $db->order($sortfield, $sortorder); @@ -189,6 +219,19 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + + // Direct jump if only one record found + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) + { + $obj = $db->fetch_object($result); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); + exit; + } + + // must be place behind the last "header(...)" call + llxHeader(); + $i = 0; $total = 0; @@ -226,6 +269,12 @@ if ($result) print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + if ($search_all) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + } + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index bdd4eacc976..160a613bf7c 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -119,6 +119,17 @@ if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFOR $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } +// Miscellaneous payments +if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) +{ + $arrayresult['searchintomiscpayments'] = array( + 'position'=>180, + 'img'=>'object_payment', + 'label'=>$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'text'=>img_picto('', 'object_payment').' '.$langs->trans("SearchIntoMiscPayments", $search_boxvalue), + 'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); +} + if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); @@ -132,6 +143,7 @@ if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKE $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } + // HR if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 2bdb3d2b6f6..911f0b3464c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1010,6 +1010,7 @@ SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leave SearchIntoTickets=Tickets +SearchIntoMiscPayments=Miscellaneous payments CommentLink=Comments NbComments=Number of comments CommentPage=Comments space @@ -1085,4 +1086,4 @@ MODIFYInDolibarr=Record %s modified DELETEInDolibarr=Record %s deleted VALIDATEInDolibarr=Record %s validated APPROVEDInDolibarr=Record %s approved -DefaultMailModel=Default Mail Model \ No newline at end of file +DefaultMailModel=Default Mail Model From 8a6c6c933303eac1762ddd6779b6a15250401297 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 10:01:25 +0200 Subject: [PATCH 109/173] removeempty line --- htdocs/core/ajax/selectsearchbox.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 160a613bf7c..00b66ced374 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -143,7 +143,6 @@ if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKE $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } - // HR if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { From 5ab54193497a3d48b5aa7c0ca328c8513eb9f11b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 11:18:01 +0200 Subject: [PATCH 110/173] Doc --- SECURITY.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index d0ab526b012..59311cf71ba 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -65,9 +65,9 @@ No vulnerability disclosure, including partial is allowed for the moment. ONLY vulnerabilities discovered, when the following setup on tested platform is used, are accepted: * $dolibarr_main_prod must be set to 1 into conf.php -* $dolibarr_nocsrfcheck must be kept to the default value 1 into conf.php +* $dolibarr_nocsrfcheck must be kept to the value 1 into conf.php (this is the default value) * The module DebugBar must NOT be enabled (by default, this module is not enabled) -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this value should be switched soon to 1 by default) +* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be enabled soon by default) * ONLY security reports on "stable" modules are allowed (troubles into "experimental" and "developement" modules are not accepted). Scope is the web application (back office) and the APIs. @@ -93,11 +93,9 @@ Scope is the web application (back office) and the APIs. * "Self" XSS * Missing cookie flags * SSL/TLS best practices -* Mixed content warnings * Denial of Service attacks * Clickjacking/UI redressing * Physical or social engineering attempts -* Recently disclosed 0-day vulnerabilities * Presence of autocomplete attribute on web forms * Vulnerabilities affecting outdated browsers or platforms * Issues that require physical access to a victim’s computer/device From 3b7b7b8ed3686bddabf2a0a16a5f1025df2b2ae5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 11:58:16 +0200 Subject: [PATCH 111/173] css --- htdocs/theme/eldy/info-box.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 63f42cdfad8..6288bdcd18e 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -17,7 +17,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> min-height: 90px; /* background: #fff; */ width: 100%; - box-shadow: 1px 1px 2px rgba(128, 128, 128, 0.2); + box-shadow: 1px 1px 25px rgba(192, 192, 192, 0.2); border-radius: 2px; border: 1px solid #e9e9e9; margin-bottom: 15px; From 7cd437b2d7bee90ff7917f7bf6524699d5ee5410 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 12:16:54 +0200 Subject: [PATCH 112/173] CSS --- .../boxes/box_graph_product_distribution.php | 151 +++++++++--------- htdocs/theme/eldy/info-box.inc.php | 2 +- 2 files changed, 77 insertions(+), 76 deletions(-) diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index fbf1874a132..957277005e7 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -133,66 +133,6 @@ class box_graph_product_distribution extends ModeleBoxes $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320'; $HEIGHT = '192'; - if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) - { - // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) - if ($showinvoicenb) - { - $langs->load("bills"); - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - - $showpointvalue = 1; $nocolor = 0; - $mode = 'customer'; - $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); - $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); - - if (empty($data1)) - { - $showpointvalue = 0; - $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); - } - $filenamenb = $dir."/prodserforinvoice-".$year.".png"; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; - - $px1 = new DolGraph(); - $mesg = $px1->isGraphKo(); - if (!$mesg) - { - $i = 0; $legend = array(); - - foreach ($data1 as $key => $val) - { - $data1[$key][0] = dol_trunc($data1[$key][0], 32); - $legend[] = $data1[$key][0]; - $i++; - } - - $px1->SetData($data1); - unset($data1); - - if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); - $px1->SetLegend($legend); - $px1->setShowLegend(2); - $px1->setShowPointValue($showpointvalue); - $px1->setShowPercent(0); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - //$px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - //$px1->SetYLabel($langs->trans("NumberOfBills")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->SetCssPrefix("cssboxes"); - //$px1->mode='depth'; - $px1->SetType(array('pie')); - $px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices"))); - $px1->combine = 0.05; - - $px1->draw($filenamenb, $fileurlnb); - } - } - } - if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) @@ -312,6 +252,67 @@ class box_graph_product_distribution extends ModeleBoxes } } + + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + { + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) + if ($showinvoicenb) + { + $langs->load("bills"); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; + + $showpointvalue = 1; $nocolor = 0; + $mode = 'customer'; + $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); + $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); + + if (empty($data1)) + { + $showpointvalue = 0; + $nocolor = 1; + $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + } + $filenamenb = $dir."/prodserforinvoice-".$year.".png"; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; + + $px1 = new DolGraph(); + $mesg = $px1->isGraphKo(); + if (!$mesg) + { + $i = 0; $legend = array(); + + foreach ($data1 as $key => $val) + { + $data1[$key][0] = dol_trunc($data1[$key][0], 32); + $legend[] = $data1[$key][0]; + $i++; + } + + $px1->SetData($data1); + unset($data1); + + if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); + $px1->SetLegend($legend); + $px1->setShowLegend(2); + $px1->setShowPointValue($showpointvalue); + $px1->setShowPercent(0); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + //$px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + //$px1->SetYLabel($langs->trans("NumberOfBills")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->SetCssPrefix("cssboxes"); + //$px1->mode='depth'; + $px1->SetType(array('pie')); + $px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices"))); + $px1->combine = 0.05; + + $px1->draw($filenamenb, $fileurlnb); + } + } + } + if (empty($nbofgraph)) { $langs->load("errors"); @@ -339,11 +340,6 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; - if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) - { - $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); - $stringtoshow .= '   '; - } if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) { $stringtoshow .= ' '.$langs->trans("ForProposals"); @@ -353,6 +349,11 @@ class box_graph_product_distribution extends ModeleBoxes { $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); } + if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) + { + $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); + $stringtoshow .= '   '; + } $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; $stringtoshow .= ''; @@ -361,29 +362,29 @@ class box_graph_product_distribution extends ModeleBoxes if ($nbofgraph == 1) { - if ($showinvoicenb) $stringtoshow .= $px1->show(); - elseif ($showpropalnb) $stringtoshow .= $px2->show(); - else $stringtoshow .= $px3->show(); + if ($showpropalnb) $stringtoshow .= $px2->show(); + elseif ($showordernb) $stringtoshow .= $px3->show(); + else $stringtoshow .= $px1->show(); } if ($nbofgraph == 2) { $stringtoshow .= '
'; - if ($showinvoicenb) $stringtoshow .= $px1->show(); - elseif ($showpropalnb) $stringtoshow .= $px2->show(); + if ($showpropalnb) $stringtoshow .= $px2->show(); + elseif ($showordernb) $stringtoshow .= $px3->show(); $stringtoshow .= '
'; - if ($showordernb) $stringtoshow .= $px3->show(); - elseif ($showpropalnb) $stringtoshow .= $px2->show(); + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showordernb) $stringtoshow .= $px3->show(); $stringtoshow .= '
'; } if ($nbofgraph == 3) { $stringtoshow .= '
'; - $stringtoshow .= $px1->show(); - $stringtoshow .= '
'; $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; + $stringtoshow .= $px3->show(); $stringtoshow .= '
'; $stringtoshow .= '
'; - $stringtoshow .= $px3->show(); + $stringtoshow .= $px1->show(); $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 6288bdcd18e..8146bb2c563 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -17,7 +17,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> min-height: 90px; /* background: #fff; */ width: 100%; - box-shadow: 1px 1px 25px rgba(192, 192, 192, 0.2); + box-shadow: 1px 1px 15px rgba(192, 192, 192, 0.2); border-radius: 2px; border: 1px solid #e9e9e9; margin-bottom: 15px; From 753396ec20190fde9037d30733b2a57a52c25e55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 12:19:40 +0200 Subject: [PATCH 113/173] Look and feel v13 --- htdocs/core/boxes/box_task.php | 2 +- htdocs/core/lib/project.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 55557cd355a..9c6020bebdc 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -189,7 +189,7 @@ class box_task extends ModeleBoxes $projectstatic->ref = $objp->project_ref; $projectstatic->title = $objp->project_title; - $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); + $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 37e4e443554..782e18151b2 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2430,7 +2430,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide $out .= ''; $out .= '
'; - $out .= '/'; + $out .= ' / '; $out .= ''; $out .= ''; From 7e989c8902e5e0dee1ce91102df37cfbe1d344c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 12:36:31 +0200 Subject: [PATCH 114/173] Remove TODO: Button Close possible only if production has started. --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/mrp.lang | 4 +++- htdocs/mrp/class/mo.class.php | 2 +- htdocs/mrp/mo_card.php | 34 +++++++++++----------------------- htdocs/mrp/mo_list.php | 19 ------------------- htdocs/mrp/mo_movements.php | 20 -------------------- htdocs/mrp/mo_production.php | 32 ++++++++++---------------------- 7 files changed, 26 insertions(+), 86 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 2bdb3d2b6f6..304c75601f1 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -511,6 +511,7 @@ Draft=Draft Drafts=Drafts StatusInterInvoiced=Invoiced Validated=Validated +ValidatedToProduce=Validated (To produce) Opened=Open OpenAll=Open (All) ClosedAll=Closed (All) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 74877a97297..f4c6eb9246a 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -75,4 +75,6 @@ ProductsToConsume=Products to consume ProductsToProduce=Products to produce UnitCost=Unit cost TotalCost=Total cost -BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price) \ No newline at end of file +BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price) +GoOnTabProductionToProduceFirst=You must first have started the production to close a Manufacturing Order (See tab '%s'). But you can Cancel it. + \ No newline at end of file diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 67f21e8f617..0b7150f7f9e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1064,7 +1064,7 @@ class Mo extends CommonObject global $langs; //$langs->load("mrp"); $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans("ToProduce").')'; + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('ValidatedToProduce'); $this->labelStatus[self::STATUS_INPROGRESS] = $langs->trans('InProgress'); $this->labelStatus[self::STATUS_PRODUCED] = $langs->trans('StatusMOProduced'); $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 62a78ac9899..49b29b7048b 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2020 Laurent Destailleur * * 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 @@ -21,26 +21,6 @@ * \brief Page to create/edit/view mo */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies - - // Load Dolibarr environment require '../main.inc.php'; @@ -653,8 +633,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { - // TODO If production is already > 1, show only close, else show cancel - print ''.$langs->trans("Close").''."\n"; + $arrayproduced = $object->fetchLinesLinked('produced', 0); + $nbProduced = 0; + foreach ($arrayproduced as $lineproduced) { + $nbProduced += $lineproduced['qty']; + } + if ($nbProduced > 0) { // If production has started, we can close it + print ''.$langs->trans("Close").''."\n"; + } else { + print 'transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").''."\n"; + } print ''.$langs->trans("Cancel").''."\n"; } diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 14d5c673f1a..57efff54bc0 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -21,25 +21,6 @@ * \brief List page for mo */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' - // Load Dolibarr environment require '../main.inc.php'; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index e281d45ee74..754a83c4770 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -21,26 +21,6 @@ * \brief Page to show tock movements of a MO */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies - - // Load Dolibarr environment require '../main.inc.php'; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 75e198c7f54..f6791c83e85 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -21,26 +21,6 @@ * \brief Page to make production on a MO */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies - - // Load Dolibarr environment require '../main.inc.php'; @@ -623,8 +603,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS) { - // TODO If production is already > 1, show only close, else show cancel - print ''.$langs->trans("Close").''."\n"; + $arrayproduced = $object->fetchLinesLinked('produced', 0); + $nbProduced = 0; + foreach ($arrayproduced as $lineproduced) { + $nbProduced += $lineproduced['qty']; + } + if ($nbProduced > 0) { // If production has started, we can close it + print ''.$langs->trans("Close").''."\n"; + } else { + print 'transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").''."\n"; + } print ''.$langs->trans("Cancel").''."\n"; } From 64b28020c8ee5633c321251951dcb83e855f1e98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 13:14:14 +0200 Subject: [PATCH 115/173] Look and feel v13 --- htdocs/bom/class/bom.class.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/core/lib/functions.lib.php | 3 +- htdocs/don/class/don.class.php | 2 +- .../class/expensereport.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 20 +++++---- htdocs/holiday/list.php | 41 ++++++++++--------- .../template/class/myobject.class.php | 2 +- htdocs/mrp/class/mo.class.php | 2 +- htdocs/mrp/mo_production.php | 14 ++++--- htdocs/product/stock/class/entrepot.class.php | 2 +- 15 files changed, 56 insertions(+), 44 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b5c0f9e8310..bd67f311d19 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -745,7 +745,7 @@ class BOM extends CommonObject $result = ''; - $label = ''.$langs->trans("BillOfMaterials").''; + $label = img_picto('', $this->picto).' '.$langs->trans("BillOfMaterials").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f844189fac9..f806a786b73 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3541,7 +3541,7 @@ class Propal extends CommonObject if ($user->rights->propal->lire) { - $label = ''.$langs->trans("Proposal").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Proposal").''; if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->ref_client)) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3e027cef919..45523fab1e2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3605,7 +3605,7 @@ class Commande extends CommonOrder $label = ''; if ($user->rights->commande->lire) { - $label = ''.$langs->trans("Order").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Order").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); if (!empty($this->total_ht)) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cb86caa91a9..a6bb6a12cec 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1411,7 +1411,7 @@ class Facture extends CommonInvoice $label = ''; if ($user->rights->facture->lire) { - $label = ''.$langs->trans("Invoice").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Invoice").''; if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index c475c1b439d..3922dc9069f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1284,7 +1284,7 @@ class Contact extends CommonObject $label .= '
'; } - $label .= ''.$langs->trans("Contact").''; + $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 71d5cbe3fa6..37bbfc9f3f4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3014,7 +3014,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'accountancy', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', 'delete', 'dolly', 'dollyrevert', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', - 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'help', + 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', + 'help', 'holiday', 'intervention', 'label', 'language', 'list', 'listlight', 'lot', 'map-marker-alt', 'money-bill-alt', 'mrp', 'note', 'object_accounting', 'object_action', 'object_account', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index d4f0871b94c..3ccaa573e8c 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -899,7 +899,7 @@ class Don extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = ''.$langs->trans("Donation").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Donation").''; if (!empty($this->id)) { $label .= '
'.$langs->trans('Ref').': '.$this->id; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e6834244810..1cfeba0d33e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1556,7 +1556,7 @@ class ExpenseReport extends CommonObject if ($short) return $url; - $label = ''.$langs->trans("ShowExpenseReport").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ShowExpenseReport").''; if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->total_ht)) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6ac136c5b4d..5c73985cbf8 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -765,7 +765,7 @@ class Fichinter extends CommonObject $result = ''; - $label = ''.$langs->trans("ShowIntervention").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Intervention").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index ce4c74d786a..d2aa54664cc 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1178,7 +1178,11 @@ class Holiday extends CommonObject $result = ''; - $label = $langs->trans("Show").': '.$this->ref; + $label = img_picto('', $this->picto).' '.$langs->trans("Holiday").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (isset($this->statut)) { + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); + } $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; @@ -1269,20 +1273,22 @@ class Holiday extends CommonObject $nb = count($name) + 1; // Select HTML - $statut = ''."\n"; + $out .= ''."\n"; // Boucle des statuts for ($i = 1; $i < $nb; $i++) { if ($i == $selected) { - $statut .= ''."\n"; + $out .= ''."\n"; } else { - $statut .= ''."\n"; + $out .= ''."\n"; } } - $statut .= ''."\n"; - print $statut; + $out .= ''."\n"; + $out .= ajax_combobox($htmlname); + + print $out; } /** diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 5a4f782deac..e5d20b9f12f 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -106,7 +106,7 @@ $search_month_end = GETPOST('search_month_end', 'int'); $search_year_end = GETPOST('search_year_end', 'int'); $search_employee = GETPOST('search_employee', 'int'); $search_valideur = GETPOST('search_valideur', 'int'); -$search_statut = GETPOST('search_statut', 'int'); +$search_status = GETPOST('search_status', 'int'); $search_type = GETPOST('search_type', 'int'); // Initialize technical objects @@ -182,7 +182,7 @@ if (empty($reshook)) $search_year_end = ""; $search_employee = ""; $search_valideur = ""; - $search_statut = ""; + $search_status = ""; $search_type = ''; $toselect = ''; $search_array_options = array(); @@ -253,7 +253,7 @@ $sql .= " cp.description,"; $sql .= " cp.date_debut,"; $sql .= " cp.date_fin,"; $sql .= " cp.halfday,"; -$sql .= " cp.statut,"; +$sql .= " cp.statut as status,"; $sql .= " cp.fk_validator,"; $sql .= " cp.date_valid,"; $sql .= " cp.fk_user_valid,"; @@ -268,7 +268,7 @@ $sql .= " uu.firstname as user_firstname,"; $sql .= " uu.admin as user_admin,"; $sql .= " uu.email as user_email,"; $sql .= " uu.login as user_login,"; -$sql .= " uu.statut as user_statut,"; +$sql .= " uu.statut as user_status,"; $sql .= " uu.photo as user_photo,"; $sql .= " ua.lastname as validator_lastname,"; @@ -276,7 +276,7 @@ $sql .= " ua.firstname as validator_firstname,"; $sql .= " ua.admin as validator_admin,"; $sql .= " ua.email as validator_email,"; $sql .= " ua.login as validator_login,"; -$sql .= " ua.statut as validator_statut,"; +$sql .= " ua.statut as validator_status,"; $sql .= " ua.photo as validator_photo"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -314,8 +314,8 @@ if (!empty($search_type) && $search_type != -1) { $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; } // Status -if (!empty($search_statut) && $search_statut != -1) { - $sql .= " AND cp.statut = '".$db->escape($search_statut)."'\n"; +if (!empty($search_status) && $search_status != -1) { + $sql .= " AND cp.statut = '".$db->escape($search_status)."'\n"; } if (empty($user->rights->holiday->read_all)) $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')'; @@ -371,7 +371,7 @@ if ($resql) if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee); if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur); if ($search_type > 0) $param .= '&search_type='.urlencode($search_type); - if ($search_statut > 0) $param .= '&search_statut='.urlencode($search_statut); + if ($search_status > 0) $param .= '&search_status='.urlencode($search_status); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -504,7 +504,7 @@ if ($resql) } print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150'); print ''; } @@ -519,7 +519,7 @@ if ($resql) $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id; - print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150'); print ''; } else { print ' '; @@ -541,7 +541,7 @@ if ($resql) //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1); } print ''; } @@ -599,7 +599,7 @@ if ($resql) if (!empty($arrayfields['cp.statut']['checked'])) { print ''; - $object->selectStatutCP($search_statut, 'search_statut'); + $object->selectStatutCP($search_status, 'search_status'); print ''; } @@ -616,7 +616,7 @@ if ($resql) if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100'); if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields @@ -656,6 +656,7 @@ if ($resql) // Leave request $holidaystatic->id = $obj->rowid; $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); + $holidaystatic->statut = $obj->status; // User $userstatic->id = $obj->fk_user; @@ -664,7 +665,7 @@ if ($resql) $userstatic->admin = $obj->user_admin; $userstatic->email = $obj->user_email; $userstatic->login = $obj->user_login; - $userstatic->statut = $obj->user_statut; + $userstatic->statut = $obj->user_status; $userstatic->photo = $obj->user_photo; // Validator @@ -674,7 +675,7 @@ if ($resql) $approbatorstatic->admin = $obj->validator_admin; $approbatorstatic->email = $obj->validator_email; $approbatorstatic->login = $obj->validator_login; - $approbatorstatic->statut = $obj->validator_statut; + $approbatorstatic->statut = $obj->validator_status; $approbatorstatic->photo = $obj->validator_photo; $date = $obj->date_create; @@ -694,12 +695,12 @@ if ($resql) } if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''.$userstatic->getNomUrl(-1, 'leave').''; + print ''.$userstatic->getNomUrl(-1, 'leave').''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print ''.$approbatorstatic->getNomUrl(-1).''; + print ''.$approbatorstatic->getNomUrl(-1).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cp.fk_type']['checked'])) @@ -722,7 +723,7 @@ if ($resql) { print ''; print dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; print ''; if (!$i) $totalarray['nbfield']++; } @@ -730,7 +731,7 @@ if ($resql) { print ''; print dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; print ''; if (!$i) $totalarray['nbfield']++; } @@ -755,7 +756,7 @@ if ($resql) } if (!empty($arrayfields['cp.statut']['checked'])) { - print ''.$holidaystatic->LibStatut($obj->statut, 5).''; + print ''.$holidaystatic->getLibStatut(5).''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 95672655825..681133ea064 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -735,7 +735,7 @@ class MyObject extends CommonObject $result = ''; - $label = ''.$langs->trans("MyObject").''; + $label = img_picto('', $this->picto).' '.$langs->trans("MyObject").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 0b7150f7f9e..c0d6658cab7 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -987,7 +987,7 @@ class Mo extends CommonObject $result = ''; - $label = ''.$langs->trans("MO").''; + $label = img_picto('', $this->picto).' '.$langs->trans("MO").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index f6791c83e85..e86fdc8348d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2019-2020 Laurent Destailleur * * 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 @@ -254,7 +254,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors'); $error++; } - if ($tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { + if (!empty($conf->productbatch->enabled) && $tmpproduct->status_batch && (!GETPOST('batchtoproduce-'.$line->id.'-'.$i))) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors'); $error++; @@ -681,7 +681,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; + $newlinetext = ''; + if ($action != 'consumeorproduce' && $action != 'consumeandproduceall') { + $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; + } print load_fiche_titre($langs->trans('Consumption'), '', '', 0, '', '', $newlinetext); print '
'; @@ -812,7 +815,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $i = 1; print ''."\n"; print ''; - print ''.$langs->trans("ToConsume").''; + print ''.$langs->trans("ToConsume").''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) $preselected = 0; print ''; @@ -960,8 +963,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { + print ''."\n"; print ''; - print ''.$langs->trans("ToProduce").''; + print ''.$langs->trans("ToProduce").''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) $preselected = 0; print ''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3dc8693897a..a16b1ee189c 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -707,7 +707,7 @@ class Entrepot extends CommonObject $result = ''; - $label = ''.$langs->trans("Warehouse").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Warehouse").''; $label .= '
'.$langs->trans('Ref').': '.(empty($this->ref) ? (empty($this->label) ? $this->libelle : $this->label) : $this->ref); if (!empty($this->lieu)) { $label .= '
'.$langs->trans('LocationSummary').': '.$this->lieu; From c4383747a12b3412395dbb0ccaa7ab49654418c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 13:32:40 +0200 Subject: [PATCH 116/173] Look and feel v13 --- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 ++++-- htdocs/expensereport/class/expensereport.class.php | 2 +- htdocs/livraison/class/livraison.class.php | 3 ++- htdocs/opensurvey/class/opensurveysondage.class.php | 3 +-- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 2 +- htdocs/reception/class/reception.class.php | 2 +- htdocs/recruitment/class/recruitmentcandidature.class.php | 2 +- htdocs/recruitment/class/recruitmentjobposition.class.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- .../supplier_proposal/class/supplier_proposal.class.php | 2 +- htdocs/ticket/class/ticket.class.php | 3 +-- htdocs/user/class/user.class.php | 2 +- test/phpunit/FilesLibTest.php | 8 ++------ 17 files changed, 22 insertions(+), 25 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 908044433e7..dcbf0075007 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1390,7 +1390,7 @@ class ActionComm extends CommonObject if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - $tooltip = ''.$langs->trans('Action').''; + $tooltip = img_picto('', $this->picto).' '.$langs->trans('Action').''; if (!empty($this->ref)) $tooltip .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($label)) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index ded439748e5..e4058a873d3 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1353,7 +1353,7 @@ class Account extends CommonObject global $conf, $langs, $user; $result = ''; - $label = ''.$langs->trans("BankAccount").''; + $label = img_picto('', $this->picto).' '.$langs->trans("BankAccount").''; $label .= '
'.$langs->trans('Label').': '.$this->label; $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; $label .= '
'.$langs->trans('IBAN').': '.$this->iban; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 567a1ab8951..fa2ef4e1387 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1303,7 +1303,7 @@ class BonPrelevement extends CommonObject $result = ''; - $labeltoshow = 'Withdraw'; + $labeltoshow = 'PaymentByDirectDebit'; if ($this->type == 'bank-transfer') { $labeltoshow = 'PaymentByBankTransfer'; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 37bbfc9f3f4..afa4c89460e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3011,7 +3011,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', - 'accountancy', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', + 'accountancy', 'account', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', 'delete', 'dolly', 'dollyrevert', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', @@ -3036,7 +3036,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'home', 'hrm', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'members', 'ticket', 'generic', - 'error', 'warning', 'supplier_proposal', 'supplier_order', 'supplier_invoice', + 'error', 'warning', + 'recruitmentcandidature', 'recruitmentjobposition', + 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' ) )) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 1cfeba0d33e..8770a0ab1a2 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1556,7 +1556,7 @@ class ExpenseReport extends CommonObject if ($short) return $url; - $label = img_picto('', $this->picto).' '.$langs->trans("ShowExpenseReport").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ExpenseReport").''; if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->total_ht)) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 16ddf710d6e..9910855f463 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -718,7 +718,8 @@ class Livraison extends CommonObject $result = ''; $picto = 'sending'; - $label = $langs->trans("ShowReceiving").': '.$this->ref; + $label = img_picto('', $this->picto).' '.$langs->trans("ShowReceiving").':
'; + $label .= ''.$langs->trans("Status").': '.$this->ref; $url = DOL_URL_ROOT.'/livraison/card.php?id='.$this->id; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 71288266b45..f8f6cb0f885 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -418,9 +418,8 @@ class Opensurveysondage extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $companylink = ''; - $label = ''.$langs->trans("ShowSurvey").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ShowSurvey").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; $label .= ''.$langs->trans('Title').': '.$this->title.'
'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 28a342e7439..30a2a0c242b 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1021,7 +1021,7 @@ class Project extends CommonObject } $label = ''; - if ($option != 'nolink') $label = ''.$langs->trans("Project").''; + if ($option != 'nolink') $label = img_picto('', $this->picto).' '.$langs->trans("Project").''; $label .= ($label ? '
' : '').''.$langs->trans('Ref').': '.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto $label .= ($label ? '
' : '').''.$langs->trans('Label').': '.$this->title; // The space must be after the : to not being explode when showing the title in img_picto if (isset($this->public)) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index abbb918132a..8020477702a 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -648,7 +648,7 @@ class Task extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = ''.$langs->trans("ShowTask").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ShowTask").''; if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->label)) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 2673c7a0da4..7b2f4927a22 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1071,7 +1071,7 @@ class Reception extends CommonObject { global $conf, $langs; $result = ''; - $label = ''.$langs->trans("Reception").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Reception").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 4ceea690f06..036d6bb1610 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -710,7 +710,7 @@ class RecruitmentCandidature extends CommonObject $result = ''; - $label = ''.$langs->trans("RecruitmentCandidature").''; + $label = img_picto('', $this->picto).' '.$langs->trans("RecruitmentCandidature").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; $label .= '
'.$langs->trans('Email').': '.$this->email; diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 81defec97e9..0f28b34be6a 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -798,7 +798,7 @@ class RecruitmentJobPosition extends CommonObject $result = ''; - $label = ''.$langs->trans("PositionToBeFilled").''; + $label = img_picto('', $this->picto).' '.$langs->trans("PositionToBeFilled").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; $label .= '
'.$langs->trans('Label').': '.$this->label; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 294f36e5589..0fc5d256541 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -922,7 +922,7 @@ class Dolresource extends CommonObject global $conf, $langs; $result = ''; - $label = ''.$langs->trans("ShowResource").''; + $label = img_picto('', $this->picto).' '.$langs->trans("ShowResource").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; /*if (isset($this->status)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 4c02eec9508..e9e0a35e623 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2468,7 +2468,7 @@ class SupplierProposal extends CommonObject $url = ''; $result = ''; - $label = ''.$langs->trans("SupplierProposal").''; + $label = img_picto('', $this->picto).' '.$langs->trans("SupplierProposal").''; if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->ref_fourn)) $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_fourn; if (!empty($this->total_ht)) $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index bf24fa83626..6096e1d2d59 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1268,9 +1268,8 @@ class Ticket extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $companylink = ''; - $label = ''.$langs->trans("Ticket").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Ticket").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; $label .= ''.$langs->trans('TicketTrackId').': '.$this->track_id.'
'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1dfd090eb5c..3672462fe0f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2244,7 +2244,7 @@ class User extends CommonObject // Info Login $label .= '
'; - $label .= ''.$langs->trans("User").'
'; + $label .= img_picto('', $this->picto).' '.$langs->trans("User").'
'; $label .= ''.$langs->trans('Name').': '.$this->getFullName($langs, ''); if (!empty($this->login)) $label .= '
'.$langs->trans('Login').': '.$this->login; if (!empty($this->job)) $label .= '
'.$langs->trans("Job").': '.$this->job; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 669f739646e..7c8ab5f3cc0 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -365,13 +365,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; $this->assertTrue($result, 'move with forced mask'); - $conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1; - $conf->logbuffer=array(); - // To test a delete that should success $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv'); - print __METHOD__." result delete=".var_export($result, true)."\n"; - $this->assertTrue($result, 'delete file '.join("\n", $conf->logbuffer)); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'delete file'); // Again to test there is error when deleting a non existing file with option disableglob $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1); @@ -398,7 +395,6 @@ class FilesLibTest extends PHPUnit\Framework\TestCase * testDolCompressUnCompress * * @return void - * @depends testDolCopyMoveDelete */ public function testDolCompressUnCompress() { From 58e0dd0d058905be0820263d99de43c64e7ddc7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 14:08:41 +0200 Subject: [PATCH 117/173] Look and feel v13 --- htdocs/theme/eldy/global.inc.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ad52b6d3472..f4c319623eb 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -534,6 +534,17 @@ div.floatright .largenumber { font-size: 1.4em; } +button[name='button_search_x'] span.fa.fa-search { + font-size: 1.3em; +} +button[name='button_removefilter_x'] span.fa.fa-remove { + opacity: 0.5; + font-size: 1.3em; +} +button:focus { + outline: none; +} + th .button { -webkit-box-shadow: none !important; From 0a0eed289eab96541347cf89da96b11b84850d7f Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 11 Sep 2020 14:15:10 +0200 Subject: [PATCH 118/173] cleanup workflow page + bugfixes --- htdocs/admin/workflow.php | 304 ++++++++++++++++++++++---------------- 1 file changed, 173 insertions(+), 131 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 311531a52de..8d3b9576b29 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * 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 @@ -19,19 +19,20 @@ */ /** - * \file htdocs/admin/workflow.php - * \ingroup company - * \brief Workflows setup page + * \file htdocs/admin/workflow.php + * \ingroup company + * \brief Workflows setup page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -// Load translation files required by the page -$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions")); - +// security check if (!$user->admin) accessforbidden(); +// Load translation files required by the page +$langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors")); + $action = GETPOST('action', 'alpha'); @@ -39,157 +40,198 @@ $action = GETPOST('action', 'alpha'); * Actions */ -if (preg_match('/set(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/set(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } -if (preg_match('/del(.*)/', $action, $reg)) -{ - if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) - { - dol_print_error($db); - } +if (preg_match('/del(.*)/', $action, $reg)) { + if (!dolibarr_set_const($db, $reg[1], '0', 'chaine', 0, '', $conf->entity) > 0) { + dol_print_error($db); + } } +// List of workflow we can enable +clearstatcache(); + +$workflowcodes = array( + // Automatic creation + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array( + 'family'=>'create', + 'position'=>10, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( + 'family'=>'create', + 'position'=>20, + 'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'bill' + ), + + 'separator1'=>array('family'=>'separator', 'position'=>25), + + // Automatic classification of proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>30, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array( + 'family'=>'classify_proposal', + 'position'=>31, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->facture->enabled)), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification of order + 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( + 'family'=>'classify_order', + 'position'=>40, + 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array( + 'family'=>'classify_order', + 'position'=>41, + 'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. + + 'separator2'=>array('family'=>'separator', 'position'=>50), + + // Automatic classification supplier proposal + 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array( + 'family'=>'classify_supplier_proposal', + 'position'=>60, + 'enabled'=>(!empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'propal', + 'warning'=>'' + ), + + // Automatic classification supplier order + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array( + 'family'=>'classify_supplier_order', + 'position'=>62, + 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), + 'picto'=>'order', + 'warning'=>'' + ), + + // Automatic classification reception + 'WORKFLOW_BILL_ON_RECEPTION'=>array( + 'family'=>'classify_reception', + 'position'=>64, + 'enabled'=>(!empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 'picto'=>'bill' + ), +); + +if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) { + foreach ($conf->modules_parts['workflow'] as $workflow) { + $workflowcodes = array_merge($workflowcodes, $workflow); + } +} + +// remove not available workflows (based on activated modules and global defined keys) +$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); /* - * View + * View */ -llxHeader('', $langs->trans("WorkflowSetup"), ''); +llxHeader('', $langs->trans("WorkflowSetup"), "EN:Module_Workflow_En|FR:Module_Workflow|ES:Módulo_Workflow"); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("WorkflowSetup"), $linkback, 'title_setup'); -print ''.$langs->trans("WorkflowDesc").'
'; -print "
"; +print ''.$langs->trans("WorkflowDesc").''; +print '
'; +print '
'; -// List of workflow we can enable +// current module setup don't support any automatic workflow of this module +if (count($workflowcodes) < 1) { + print $langs->trans("ThereIsNoWorkflowToModify"); -clearstatcache(); - -$workflowcodes = array( - // Automatic creation - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), - 'separator1'=>array('family'=>'separator', 'position'=>25), - // Automatic classification of proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal', 'warning'=>''), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal', 'warning'=>''), - 'separator2'=>array('family'=>'separator', 'position'=>35), - // Automatic classification of order - 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order', 'warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. - 'separator3'=>array('family'=>'separator', 'position'=>50), - // Automatic classification supplier proposal - 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'propal', 'warning'=>''), - 'separator4'=>array('family'=>'separator', 'position'=>61), - // Automatic classification supplier order - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)', 'picto'=>'order', 'warning'=>''), - 'separator5'=>array('family'=>'separator', 'position'=>63), - // Automatic classification reception - 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>64, 'enabled'=>'! empty($conf->reception->enabled) && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', 'picto'=>'bill'), - 'separator6'=>array('family'=>'separator', 'position'=>90), - // Automatic classification of intervention - 'WORKFLOW_TICKET_CLOSE_INTERVENTION'=>array('family'=>'classify_intervention', 'position'=>100, 'enabled'=>'! empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)', 'picto'=>'intervention'), -); - -if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) -{ - foreach ($conf->modules_parts['workflow'] as $workflow) - { - $workflowcodes = array_merge($workflowcodes, $workflow); - } + llxFooter(); + $db->close(); + return; } // Sort on position $workflowcodes = dol_sort_array($workflowcodes, 'position'); -$nbqualified = 0; +print ''; + $oldfamily = ''; -print '
'."\n"; - -foreach ($workflowcodes as $key => $params) -{ - $picto = $params['picto']; - $enabled = $params['enabled']; - $family = $params['family']; - - if ($family == 'separator') - { - print '

'; - print ''."\n"; +foreach ($workflowcodes as $key => $params) { + if ($params['family'] == 'separator') { + print '
'; + print '
'; + print ''; continue; } - if (!verifCond($enabled)) continue; - - $nbqualified++; - - - if ($oldfamily != $family) - { - print ''."\n"; - print ' '; - print ' '; - print "\n"; - $oldfamily = $family; - } - print "\n"; - print "\n"; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + + $oldfamily = $params['family']; + } + + print ''; + print ''; + + print ''; + print ''; } -if ($nbqualified == 0) -{ - print '
'; - $reg = array(); - if ($family == 'create') { - print $langs->trans("AutomaticCreation"); - } elseif (preg_match('/classify_(.*)/', $family, $reg)) - { - print $langs->trans("AutomaticClassification"); - if ($reg[1] == 'proposal') print ' - '.$langs->trans('Proposal'); - if ($reg[1] == 'order') print ' - '.$langs->trans('Order'); - if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal'); - if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder'); - if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception'); - if ($reg[1] == 'intervention') print ' - '.$langs->trans('Intervention'); + if ($oldfamily != $params['family']) { + if ($params['family'] == 'create') { + $header = $langs->trans("AutomaticCreation"); + } elseif (preg_match('/classify_(.*)/', $params['family'], $reg)) { + $header = $langs->trans("AutomaticClassification"); + if ($reg[1] == 'proposal') $header .= ' - '.$langs->trans('Proposal'); + if ($reg[1] == 'order') $header .= ' - '.$langs->trans('Order'); + if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal'); + if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder'); + if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception'); } else { - print $langs->trans("Description"); + $header = $langs->trans("Description"); } - print ''.$langs->trans("Status").'
".img_object('', $picto, 'class="paddingright"').$langs->trans('desc'.$key); - if (!empty($params['warning'])) - { - $langs->load("errors"); - print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); - } - print "'; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff($key); - } else { - if (!empty($conf->global->$key)) - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - } - print '
'.$header.''.$langs->trans("Status").'
'; + print img_object('', $params['picto']); + print ' '.$langs->trans('desc'.$key); + + if (!empty($params['warning'])) { + print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); + } + + print ''; + + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff($key); + } else { + if (!empty($conf->global->$key)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + } + + print '
'.$langs->trans("ThereIsNoWorkflowToModify"); -} print '
'; // End of page From 97e74642ce7427408619f264bafcd0aa739f72af Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 11 Sep 2020 12:26:14 +0000 Subject: [PATCH 119/173] Fixing style errors. --- htdocs/admin/workflow.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 8d3b9576b29..671bacee080 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,8 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); +$workflowcodes = array_filter($workflowcodes, function ($var) { + return $var['enabled']; }); /* * View From 3930b00e4d407adb50adfa6a48d88a856f8fd9ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Sep 2020 14:35:52 +0200 Subject: [PATCH 120/173] Debug a not used page to show agenda per type of event --- htdocs/comm/action/index.php | 2 + htdocs/comm/action/pertype.php | 213 +++++++++++++++++++++++-------- htdocs/comm/action/peruser.php | 12 +- htdocs/theme/eldy/global.inc.php | 2 +- 4 files changed, 173 insertions(+), 56 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 0c6ca3c1acc..135f91c56f4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -398,6 +398,8 @@ if ($action == 'show_month') $tabactive = 'cardmonth'; if ($action == 'show_week') $tabactive = 'cardweek'; if ($action == 'show_day') $tabactive = 'cardday'; if ($action == 'show_list') $tabactive = 'cardlist'; +if ($action == 'show_pertuser') $tabactive = 'cardperuser'; +if ($action == 'show_pertype') $tabactive = 'cardpertype'; $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 7eb5b9e5c6d..72b25c9d731 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -41,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -$filter = GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("filtert", "int", 3); -$usergroup = GETPOST("usergroup", "int", 3); +$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; @@ -64,7 +64,7 @@ if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "a.datec"; // Security check -$socid = GETPOST("socid", "int"); +$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid = ''; @@ -79,22 +79,23 @@ if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no per //$action=GETPOST('action','alpha'); $action = 'show_pertype'; -$resourceid = GETPOST("resourceid", "int"); +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); -$pid = GETPOST("projectid", "int", 3); -$status = GETPOST("status", 'alpha'); -$type = GETPOST("type", 'alpha'); +$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('actioncode', 'array')) +if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); + $actioncode = GETPOST('search_actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -107,6 +108,7 @@ if ($dateselect > 0) } $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; +$tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); $end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); @@ -115,14 +117,15 @@ if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h <= $begin_h) $end_h = $begin_h + 1; $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; +$tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmparray = explode('-', $tmp); $begin_d = 1; -$end_d = 53; +$end_d = 53; if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { +if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { @@ -150,6 +153,10 @@ if ($action == 'delete_action') { $event = new ActionComm($db); $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; + $result = $event->delete(); } @@ -159,6 +166,27 @@ if ($action == 'delete_action') * View */ +$parameters = array( + 'socid' => $socid, + 'status' => $status, + 'year' => $year, + 'month' => $month, + 'day' => $day, + 'type' => $type, + 'maxprint' => $maxprint, + 'filter' => $filter, + 'filtert' => $filtert, + 'showbirthday' => $showbirthday, + 'canedit' => $canedit, + 'optioncss' => $optioncss, + 'actioncode' => $actioncode, + 'pid' => $pid, + 'resourceid' => $resourceid, + 'usergroup' => $usergroup, +); +$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $form = new Form($db); $companystatic = new Societe($db); @@ -199,18 +227,26 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode; -if ($resourceid > 0) $param .= "&resourceid=".$resourceid; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status; -if ($filter) $param .= "&filter=".$filter; -if ($filtert) $param .= "&filtert=".$filtert; -if ($usergroup) $param .= "&usergroup=".$usergroup; -if ($socid) $param .= "&socid=".$socid; -if ($showbirthday) $param .= "&showbirthday=1"; -if ($pid) $param .= "&projectid=".$pid; -if ($type) $param .= "&type=".$type; -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action; -$param .= "&maxprint=".$maxprint; +if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); +} +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); +if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); +if ($end_h != '') $param .= '&end_h='.urlencode($end_h); +if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); +if ($end_d != '') $param .= '&end_d='.urlencode($end_d); +$param .= "&maxprint=".urlencode($maxprint); $prev = dol_get_first_day($year, 1); $prev_year = $year - 1; @@ -238,6 +274,7 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; +$picto = 'calendartype'; $nav = "".img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")." \n"; @@ -245,7 +282,7 @@ $nav .= "".$langs->trans("Today").")"; $picto = 'calendarweek'; -$nav .= '  
'; +/*$nav .= '   '; $nav .= ''; $nav .= ''; $nav .= ''; @@ -260,27 +297,30 @@ $nav .= ''; $nav .= ''; $nav .= ''; $nav .= ''; - +*/ $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav .= ' '; -$nav .= '
'; +//$nav .= ' '; +$nav .= ' '; +//$nav .= ''; // Must be after the nav definition -$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); +$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); //print 'x'.$param; - - -$tabactive = 'cardpertype'; +$tabactive = ''; +if ($action == 'show_month') $tabactive = 'cardmonth'; +if ($action == 'show_week') $tabactive = 'cardweek'; +if ($action == 'show_day') $tabactive = 'cardday'; +if ($action == 'show_list') $tabactive = 'cardlist'; +if ($action == 'show_peruser') $tabactive = 'cardperuser'; +if ($action == 'show_pertype') $tabactive = 'cardpertype'; $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $head = calendars_prepare_head($paramnoaction); -dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); -print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -dol_fiche_end(); +print '
'."\n"; $showextcals = $listofextcals; // Legend @@ -334,10 +374,73 @@ if ($conf->use_javascript_ajax) } } +$massactionbutton = ''; + +$viewmode = ''; +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewList").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewCal").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewWeek").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewDay").''; + +$viewmode .= ''; +//$viewmode .= ''; +$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); +//$viewmode .= ''; +$viewmode .= ''.$langs->trans("ViewPerUser").''; + +$viewmode .= ''; + + +$newcardbutton = ''; +if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) +{ + $tmpforcreatebutton = dol_getdate(dol_now(), true); + + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; + + //$param='month='.$monthshown.'&year='.$year; + $hourminsec = '100000'; + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); +} + +print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); $link = ''; -print load_fiche_titre($s, $link.'     '.$nav, ''); +//print load_fiche_titre('', $link.'     '.$nav.' '.$newcardbutton, ''); + +// Local calendar +$newtitle = '
'; +$newtitle .= ' '.$langs->trans("LocalAgenda").'   '; +$newtitle .= '
'; +//$newtitle=$langs->trans($title); + +$s = $newtitle; + +print $s; + +print '
'; +print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +print '
'; // Get event in an array @@ -377,7 +480,12 @@ if (!empty($actioncode)) if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } } } } @@ -430,7 +538,7 @@ if ($filtert > 0 || $usergroup > 0) $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action //print $sql; -dol_syslog("comm/action/index.php", LOG_DEBUG); +dol_syslog("comm/action/pertype.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -529,6 +637,7 @@ if ($resql) } $i++; } + $db->free($resql); } else { dol_print_error($db); } @@ -536,6 +645,7 @@ if ($resql) $maxnbofchar = 18; $cachethirdparties = array(); $cachecontacts = array(); +$cacheusers = array(); // Define theme_datacolor array $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; @@ -557,11 +667,10 @@ $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter $newparam .= '&viewweek=1'; -echo ''; +print ''; echo ''; echo ''; echo ''; -echo '
'; // Line header with list of days @@ -603,6 +712,7 @@ $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm $resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { + $typeofevents[$obj->code] = $obj->code; $colorsbytype[$obj->code] = $obj->color; $labelbytype[$obj->code] = $obj->label; } @@ -616,7 +726,7 @@ foreach ($typeofevents as $typeofevent) { $var = !$var; echo ""; - echo ''.$username->getNomUrl(1).''; + echo ''.$typeofevent.''; $tmpday = $sav; // Lopp on each day of week @@ -642,7 +752,7 @@ foreach ($typeofevents as $typeofevent) if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; if ($today) $style = 'cal_today_peruser'; - show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); + show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, $mont, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); $i++; } @@ -651,7 +761,7 @@ foreach ($typeofevents as $typeofevent) } echo "\n"; - +echo "
"; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { @@ -678,6 +788,9 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) */ } +print "\n".''; +print "\n"; + // Add js code to manage click on a box print ''; -$sql = "SELECT"; -$sql .= " t.rowid,"; -$sql .= " t.entity,"; -$sql .= " t.fk_product,"; -$sql .= " t.batch,"; -$sql .= " t.sellby,"; -$sql .= " t.eatby,"; -$sql .= " t.datec as date_creation,"; -$sql .= " t.tms as date_update,"; -$sql .= " t.fk_user_creat,"; -$sql .= " t.fk_user_modif,"; -$sql .= " t.import_key,"; -$sql .= " p.fk_product_type as product_type,"; -$sql .= " p.ref as product_ref,"; -$sql .= " p.label as product_label,"; -$sql .= " p.tosell,"; -$sql .= " p.tobuy,"; -$sql .= " p.tobatch"; -// Add fields for extrafields +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; +} +// Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql .= " FROM ".MAIN_DB_PREFIX."product_lot as t"; +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (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 (t.rowid = ef.fk_object)"; -$sql .= ", ".MAIN_DB_PREFIX."product as p"; -$sql .= " WHERE p.rowid = t.fk_product"; -$sql .= " AND p.entity IN (".getEntity('product').")"; - -if ($search_entity) $sql .= natural_search("entity", $search_entity); -if ($search_product) $sql .= natural_search("p.ref", $search_product); -if ($search_batch) $sql .= natural_search("batch", $search_batch); -if ($search_fk_user_creat) $sql .= natural_search("fk_user_creat", $search_fk_user_creat); -if ($search_fk_user_modif) $sql .= natural_search("fk_user_modif", $search_fk_user_modif); -if ($search_import_key) $sql .= natural_search("import_key", $search_import_key); - -if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + +/* If a group by is required + $sql.= " GROUP BY "; + foreach($object->fields as $key => $val) + { + $sql.='t.'.$key.', '; + } + // Add fields from extrafields + if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + } + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql=preg_replace('/,\s*$/','', $sql); + */ + $sql .= $db->order($sortfield, $sortorder); -//$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->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 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } - -$sql .= $db->plimit($limit + 1, $offset); - - -dol_syslog($script_file, LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { + $num = $nbtotalofrecords; +} else { + if ($limit) $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + $num = $db->num_rows($resql); +} - $arrayofselected = is_array($toselect) ? $toselect : array(); +// Direct jump if only one record found +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('/mymodule/myobject_card.php', 1).'?id='.$id); + exit; +} - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - if ($search_entity != '') $param .= '&search_entity='.urlencode($search_entity); - if ($search_product != '') $param .= '&search_product='.urlencode($search_product); - if ($search_batch != '') $param .= '&search_batch='.urlencode($search_batch); - if ($search_fk_user_creat != '') $param .= '&search_fk_user_creat='.urlencode($search_fk_user_creat); - if ($search_fk_user_modif != '') $param .= '&search_fk_user_modif='.urlencode($search_fk_user_modif); - if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); - if ($optioncss != '') $param .= '&optioncss='.$optioncss; - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); +// Output page +// -------------------------------------------------------------------- - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +llxHeader('', $title, $help_url); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'lot', 0, '', '', $limit, 0, 0, 1); +$arrayofselected = is_array($toselect) ? $toselect : array(); - $topicmail = "Information"; - $modelmail = "productlot"; - $objecttmp = new Productlot($db); - $trackid = 'lot'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - if ($sall) +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$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 ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "Information"; +$modelmail = "productlot"; +$objecttmp = new Productlot($db); +$trackid = 'lot'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; +/*$moreforfilter.='
'; + $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= '
';*/ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (!empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // 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"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; - } - - /*$moreforfilter = ''; - $moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; - $moreforfilter.= '
';*/ - - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; - - if (!empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print '
'; - print '
'."\n"; - - // Fields title search - print ''; - if (!empty($arrayfields['t.entity']['checked'])) print ''; - if (!empty($arrayfields['t.batch']['checked'])) print ''; - if (!empty($arrayfields['t.fk_product']['checked'])) print ''; - if (!empty($arrayfields['t.sellby']['checked'])) print ''; - if (!empty($arrayfields['t.eatby']['checked'])) print ''; - if (!empty($arrayfields['t.fk_user_creat']['checked'])) print ''; - if (!empty($arrayfields['t.fk_user_modif']['checked'])) print ''; - if (!empty($arrayfields['t.import_key']['checked'])) print ''; - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['t.datec']['checked'])) - { - // Date creation - print ''; } - if (!empty($arrayfields['t.tms']['checked'])) +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) +{ + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - // Date modification - print ''; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } - /*if (! empty($arrayfields['u.statut']['checked'])) - { - // Status - print ''; - }*/ - // Action column - print ''; - print ''."\n"; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$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; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; - // Fields title - print ''; - if (!empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['t.datec']['checked'])) { - print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - if (!empty($arrayfields['t.tms']['checked'])) { - print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - } - //if (! empty($arrayfields['t.status']['checked'])) { - // print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.status", "", $param, '', $sortfield, $sortorder, 'center '); - //} - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - print ''."\n"; - $productlot = new Productlot($db); - - $i = 0; - $totalarray = array(); - while ($i < min($num, $limit)) +// Detect if we need a fetch on each output line +$needToFetchEachLine = 0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - $obj = $db->fetch_object($resql); - if ($obj) + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < ($limit ? min($num, $limit) : $num)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) + { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref' || $key == 'batch') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { - $productlot->id = $obj->rowid; - $productlot->status = $obj->tosell; - $productlot->batch = $obj->batch; - - // You can use here results - print ''; - if (!empty($arrayfields['t.entity']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.batch']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.fk_product']['checked'])) - { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->product_type; - $productstatic->ref = $obj->product_ref; - $productstatic->label = $obj->product_label; - $productstatic->status = $obj->tosell; - $productstatic->status_buy = $obj->tobuy; - $productstatic->status_batch = $obj->tobatch; - - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.sellby']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.eatby']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.fk_user_creat']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.fk_user_modif']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.import_key']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['t.datec']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date modification - if (!empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Status - /* - if (! empty($arrayfields['u.statut']['checked'])) - { - $userstatic->statut=$obj->statut; - print ''; - }*/ - - // Action column - print ''; if (!$i) $totalarray['nbfield']++; - - print ''; + if (!empty($val['isameasure'])) + { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $object->$key; + } } - $i++; } - - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - $db->free($resql); - - $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; - print '
'; + print ''; + if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + elseif (strpos($val['type'], 'integer:') === 0) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; - print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - print $searchpicto; - print '
'.$obj->entity.''.$productlot->getNomUrl(1).''.$productstatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->sellby), 'day').''.dol_print_date($db->jdate($obj->eatby), 'day').''.$obj->fk_user_creat.''.$obj->fk_user_modif.''.$obj->import_key.''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$userstatic->getLibStatut(3).''; - 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($obj->rowid, $arrayofselected)) $selected = 1; - print ''; + print ''; + if ($key == 'status') print $object->getLibStatut(5); + elseif ($key == 'rowid') print $object->id; + else { + if ($key == 'batch') { + print $object->getNomUrl(1); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } } print '
'; + 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 ''; + } + print '
'."\n"; - print '
'; + print ''."\n"; - print '
'."\n"; + $i++; +} - /* - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); +// If no record found +if ($num == 0) +{ + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; +} - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); - */ -} else { - $error++; - dol_print_error($db); +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print '
'."\n"; + +print ''."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page From e89bfe5ac1185bcd33c8a5d6c770ddb2bc098840 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Fri, 11 Sep 2020 22:31:48 +0100 Subject: [PATCH 125/173] fix: unuseful truncations in extrafield select lists --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1ed6056404e..f08516812be 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1218,13 +1218,13 @@ class ExtraFields } else { $labeltoshow = $obj->{$InfoFieldList[1]}; } - $labeltoshow = dol_trunc($labeltoshow, 45); + $labeltoshow = $labeltoshow; if ($value == $obj->rowid) { if (!$notrans) { foreach ($fields_label as $field_toshow) { $translabel = $langs->trans($obj->$field_toshow); - $labeltoshow = dol_trunc($translabel, 18).' '; + $labeltoshow = $translabel.' '; } } $out .= ''; From ead320642ea8913500c713c2210a30232abb2ecc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 00:58:06 +0200 Subject: [PATCH 126/173] Fix removed some non used sql requests on widgets --- htdocs/core/boxes/box_services_contracts.php | 26 ++++---------------- htdocs/index.php | 7 ++++-- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index aae8e0356d0..d528a4d68ca 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -90,7 +90,7 @@ class box_services_contracts extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; - $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type, cd.date_fin_validite as date_line,"; + $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut as contractline_status, cd.product_type as type, cd.date_fin_validite as date_line,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; @@ -125,6 +125,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->type = $objp->type; $contractlinestatic->product_id = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; + $contractlinestatic->statut = $objp->contractline_status; $contractstatic->id = $objp->rowid; $contractstatic->ref = $objp->ref; @@ -143,24 +144,7 @@ class box_services_contracts extends ModeleBoxes $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; $dateline = $this->db->jdate($objp->date_line); - if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); - - // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on - { - $sqld = "SELECT label"; - $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sqld .= " WHERE fk_product=".$objp->product_id; - $sqld .= " AND lang='".$langs->getDefaultLang()."'"; - $sqld .= " LIMIT 1"; - - $resultd = $this->db->query($sqld); - if ($resultd) - { - $objtp = $this->db->fetch_object($resultd); - if ($objtp->label != '') $contractlinestatic->label = $objtp->label; - } - } + if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->contractline_status == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); // Label if ($objp->product_id > 0) @@ -190,7 +174,7 @@ class box_services_contracts extends ModeleBoxes $description = ''; // Already added into main visible desc } - $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); + $s = $form->textwithtooltip($text, $description, 3, '', '', '', 0, (!empty($objp->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); } @@ -222,7 +206,7 @@ class box_services_contracts extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="right" width="18"', - 'text' => $contractlinestatic->LibStatut($objp->statut, 3) + 'text' => $contractlinestatic->getLibStatut(3) ); $i++; diff --git a/htdocs/index.php b/htdocs/index.php index 65787fda020..87f33851b92 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -294,7 +294,10 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) $boxstatItem = ''; $class = $classes[$val]; // Search in cache if load_state_board is already realized - if (!isset($boardloaded[$class]) || !is_object($boardloaded[$class])) + $classkeyforcache = $class; + if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product + + if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) { include_once $includes[$val]; // Loading a class cost around 1Mb @@ -302,7 +305,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) $board->load_state_board(); $boardloaded[$class] = $board; } else { - $board = $boardloaded[$class]; + $board = $boardloaded[$classkeyforcache]; } $langs->load(empty($langfile[$val]) ? $val : $langfile[$val]); From d44952011fc2b16de44a17268eecf55466cfa499 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 01:16:02 +0200 Subject: [PATCH 127/173] Update balance.php --- htdocs/accountancy/bookkeeping/balance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index ee51560818f..a9a1f1d12cf 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -269,7 +269,7 @@ if ($action != 'export_csv') $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; - $sql .= " WHERE t.entity IN (".getEntity('accountancy').")"; + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; $sql .= " GROUP BY t.numero_compte"; From f45054df06df6a027d38c829e0ad3a201cee9e2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 03:02:08 +0200 Subject: [PATCH 128/173] Close #14604 Merge manually change to get notification to show Remains: support call of the action=closereminderid done by browser once notif has be thrown. --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 3 - htdocs/comm/action/list.php | 2 +- htdocs/core/ajax/check_notifications.php | 68 ++++++++++++------- htdocs/core/js/lib_notification.js.php | 31 +++++++-- htdocs/core/lib/usergroups.lib.php | 2 +- htdocs/langs/en_US/mails.lang | 13 ++-- 7 files changed, 78 insertions(+), 43 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index a181586815f..d24bf74e99f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1043,7 +1043,7 @@ if ($action == 'create') }*/ print ''; - // Realised by + // Done by if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) { print ''.$langs->trans("ActionDoneBy").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dcbf0075007..43fcfd98d8d 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -33,9 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php'; - - - /** * Class to manage agenda events (actions) */ diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 20ba2928de1..ee47dbc3387 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -429,7 +429,7 @@ if ($resql) $arrayofselected = is_array($toselect) ? $toselect : array(); // Local calendar - $newtitle = '
'; + $newtitle = '
'; $newtitle .= ' '.$langs->trans("LocalAgenda").'   '; $newtitle .= '
'; //$newtitle=$langs->trans($title); diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 98d7d00a8dc..10172628805 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -1,7 +1,7 @@ * Copyright (C) 2017 Juanjo Menent - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,31 @@ */ if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' + require '../../main.inc.php'; @@ -46,7 +66,8 @@ $eventfound = array(); //dol_syslog('time='.$time.' $_SESSION[auto_ck_events_not_before]='.$_SESSION['auto_check_events_not_before']); // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened. -if ($time >= $_SESSION['auto_check_events_not_before']) +// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet). +if ($time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int')) { $time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined if (!empty($_SESSION['auto_check_events_not_before'])) @@ -66,7 +87,7 @@ if ($time >= $_SESSION['auto_check_events_not_before']) $_SESSION['auto_check_events_not_before'] = $time + $time_update; - // Force save of session change we did. + // Force save of the session change we did. // WARNING: Any change in sessions after that will not be saved ! session_write_close(); @@ -75,35 +96,34 @@ if ($time >= $_SESSION['auto_check_events_not_before']) dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']); - $sql = 'SELECT id'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm a, '.MAIN_DB_PREFIX.'actioncomm_resources ar'; - $sql .= ' WHERE a.id = ar.fk_actioncomm'; - // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened. - // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate (save is not done yet). - $sql .= " AND datep BETWEEN '".$db->idate($starttime)."' AND '".$db->idate($time + $time_update - 1)."'"; - $sql .= ' AND a.code <> "AC_OTH_AUTO"'; - $sql .= ' AND ar.element_type = "user"'; - $sql .= ' AND ar.fk_element = '.$user->id; + $sql = 'SELECT a.id, a.code, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; + $sql .= ' AND ('; + $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + $sql .= " OR (a.datep BETWEEN '".$db->idate($starttime)."' AND '".$db->idate($time + $time_update - 1)."')"; + $sql .= ' )'; + } else { + $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + } $sql .= ' LIMIT 10'; // Avoid too many notification at once $resql = $db->query($sql); if ($resql) { - $actionmod = new ActionComm($db); - while ($obj = $db->fetch_object($resql)) { - // Load translation files required by the page - $langs->loadLangs(array('agenda', 'commercial')); - - $actionmod->fetch($obj->id); - // Message must be formated and translated to be used with javascript directly $event = array(); $event['type'] = 'agenda'; - $event['id'] = $actionmod->id; - $event['tipo'] = $langs->transnoentities('Action'.$actionmod->code); - $event['titulo'] = $actionmod->label; - $event['location'] = $langs->transnoentities('Location').': '.$actionmod->location; + $event['id'] = $obj->id; + $event['id_reminder'] = $obj->id_reminder; + $event['code'] = $obj->code; + $event['label'] = $obj->label; + $event['location'] = $obj->location; + $event['date'] = $db->jdate($obj->dateremind); $eventfound[] = $event; } diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 250eb0231a6..fc3fd3512ad 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -79,6 +79,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav\');'; } ?> + var listofreminderids = ''; $.each(arr, function (index, value) { var url="notdefined"; @@ -88,6 +89,10 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP body += '\n' + value['location']; } + if(value['type'] == 'agenda' && (value['date'] != null || value['date'] != '')) { + body += '\n' + value['date']; + } + if (value['type'] == 'agenda') { url = '' + value['id']; @@ -105,14 +110,26 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP { audio.play(); } - noti.onclick = function (event) { - console.log("An event to notify on browser was received"); - event.preventDefault(); // prevent the browser from focusing the Notification's tab - window.focus(); - window.open(url, '_blank'); - noti.close(); - }; + + if (noti) { + noti.onclick = function (event) { + console.log("An event to notify on browser was received"); + event.preventDefault(); // prevent the browser from focusing the Notification's tab + window.focus(); + window.open(url, '_blank'); + noti.close(); + }; + + listofreminderids = listofreminderids + ',' + value['id'] + } }); + + // Update status of all notifications we sent on browser (listofreminderids) + $.ajax(""+listofreminderids, { + type: "get", // Usually post or get + async: true, + data: {time: time_js_next_test} + }); } } }); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 86a26c8f830..f917f32f21a 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -130,7 +130,7 @@ function user_prepare_head($object) } $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("Notifications"); + $head[$h][1] = $langs->trans("NotificationsAuto"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'notify'; $h++; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index a5139813014..c8b2da9e860 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -125,12 +125,13 @@ TagMailtoEmail=Recipient Email (including html "mailto:" link) NoEmailSentBadSenderOrRecipientEmail=No email sent. Bad sender or recipient email. Verify user profile. # Module Notifications Notifications=Notifications -NoNotificationsWillBeSent=No email notifications are planned for this event and company -ANotificationsWillBeSent=1 notification will be sent by email -SomeNotificationsWillBeSent=%s notifications will be sent by email -AddNewNotification=Activate a new email notification target/event -ListOfActiveNotifications=List all active targets/events for email notification -ListOfNotificationsDone=List all email notifications sent +NotificationsAuto=Notifications (Auto) +NoNotificationsWillBeSent=No automtic email notifications are planned for this event type and company +ANotificationsWillBeSent=1 automatic notification will be sent by email +SomeNotificationsWillBeSent=%s automatic notifications will be sent by email +AddNewNotification=Activate a new automatic email notification target/event +ListOfActiveNotifications=List all active targets/events for automatic email notification +ListOfNotificationsDone=List all automatic email notifications sent MailSendSetupIs=Configuration of email sending has been setup to '%s'. This mode can't be used to send mass emailing. MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Setup - EMails%s to change parameter '%s' to use mode '%s'. With this mode, you can enter setup of the SMTP server provided by your Internet Service Provider and use Mass emailing feature. MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s. From 2ffe84b5f547f30ee115b3dc46a0cec23acfcd9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 04:08:05 +0200 Subject: [PATCH 129/173] Debug notifications on browser --- htdocs/core/ajax/check_notifications.php | 49 +++++++++++++++++++++--- htdocs/core/js/lib_notification.js.php | 23 ++++++----- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 10172628805..b70afe936f7 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -46,6 +46,45 @@ if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); require '../../main.inc.php'; +$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late +//$time=dol_now(); +$action = GETPOST('action', 'aZ09'); +$listofreminderids = GETPOST('listofreminderids', 'aZ09'); + + +/* + * Actions + */ + +if ($action == 'stopreminder') { + dol_syslog("Clear notification for listofreminderids=".$listofreminderids); + $listofreminderidsarray = explode('-', GETPOST('listofreminderids', 'aZ09')); + + // Set the reminder as done + foreach($listofreminderidsarray as $listofreminderid) { + if (empty($listofreminderid)) continue; + //$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'action_reminder WHERE rowid = '.$listofreminderid.' AND fk_user = '.$user->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'actioncomm_reminder SET status = 1'; + $sql .= ' WHERE status = 0 AND rowid = '.$listofreminderid.' AND fk_user = '.$user->id.' AND entity = '.$conf->entity; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + } + + include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + + // Clean database + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'actioncomm_reminder'; + $sql .= " WHERE dateremind < '".$db->idate(dol_time_plus_duree(dol_now(), -1, 'm'))."'"; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + + exit; +} + /* * View @@ -55,10 +94,6 @@ top_httphead('text/html'); // TODO Use a json mime type global $user, $db, $langs, $conf; -$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late -//$time=dol_now(); - - $eventfound = array(); //Uncomment this to force a test //$eventfound[]=array('type'=>'agenda', 'id'=>1, 'tipo'=>'eee', 'location'=>'aaa'); @@ -96,7 +131,7 @@ if ($time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']); - $sql = 'SELECT a.id, a.code, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user'; + $sql = 'SELECT a.id, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; @@ -120,10 +155,12 @@ if ($time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow $event['type'] = 'agenda'; $event['id'] = $obj->id; $event['id_reminder'] = $obj->id_reminder; + $event['id_user'] = $obj->id_user_reminder; $event['code'] = $obj->code; $event['label'] = $obj->label; $event['location'] = $obj->location; - $event['date'] = $db->jdate($obj->dateremind); + $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); + $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); $eventfound[] = $event; } diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index fc3fd3512ad..50d3f7f3268 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -44,6 +44,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP /* Check if permission ok */ if (Notification.permission !== "granted") { + console.log("Ask Notification.permission"); Notification.requestPermission() } @@ -65,7 +66,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP function check_events() { if (Notification.permission === "granted") { - console.log("Call check_events time_js_next_test = date we are looking for event after ="+time_js_next_test); + console.log("Call check_events time_js_next_test = date we are looking for event after this date = "+time_js_next_test); $.ajax("", { type: "post", // Usually post or get async: true, @@ -82,15 +83,15 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP var listofreminderids = ''; $.each(arr, function (index, value) { - var url="notdefined"; - var title="Not defined"; - var body = value['tipo'] + ': ' + value['titulo']; + var url = "notdefined"; + var title = "Not defined"; + var body = value['type'] + ': ' + value['label']; if (value['type'] == 'agenda' && value['location'] != null && value['location'] != '') { body += '\n' + value['location']; } - if(value['type'] == 'agenda' && (value['date'] != null || value['date'] != '')) { - body += '\n' + value['date']; + if(value['type'] == 'agenda' && (value['event_date_start_formated'] != null || event_date_start_formated['event_date_start'] != '')) { + body += '\n' + value['event_date_start_formated']; } if (value['type'] == 'agenda') @@ -105,6 +106,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP }; // We release the notify + console.log("Send notification on browser"); var noti = new Notification(title, extra); if (index==0 && audio) { @@ -113,19 +115,20 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP if (noti) { noti.onclick = function (event) { - console.log("An event to notify on browser was received"); + console.log("A click on notification on browser has been done"); event.preventDefault(); // prevent the browser from focusing the Notification's tab window.focus(); window.open(url, '_blank'); noti.close(); }; - listofreminderids = listofreminderids + ',' + value['id'] + listofreminderids = listofreminderids + '-' + value['id_reminder'] } }); // Update status of all notifications we sent on browser (listofreminderids) - $.ajax(""+listofreminderids, { + console.log("Flag notification as done for listofreminderids="+listofreminderids); + $.ajax(""+listofreminderids, { type: "get", // Usually post or get async: true, data: {time: time_js_next_test} @@ -136,7 +139,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP } else { - console.log("Cancel check_events. Useless because Notification.permission is "+Notification.permission); + console.log("Cancel check_events. Useless because javascript Notification.permission is "+Notification.permission+"."); } time_js_next_test += time_auto_update; From 4b525f6826066657cfa95e338cc95a934430b278 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 04:12:39 +0200 Subject: [PATCH 130/173] Debug notifications on browser --- htdocs/core/lib/usergroups.lib.php | 3 ++- htdocs/langs/en_US/mails.lang | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index f917f32f21a..7d67635a1e2 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -47,7 +47,7 @@ function user_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("UserCard"); + $head[$h][1] = $langs->trans("User"); $head[$h][2] = 'user'; $h++; @@ -129,6 +129,7 @@ function user_prepare_head($object) dol_print_error($db); } + $langs->load("mails"); $head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id; $head[$h][1] = $langs->trans("NotificationsAuto"); if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index c8b2da9e860..009580e947a 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -125,7 +125,7 @@ TagMailtoEmail=Recipient Email (including html "mailto:" link) NoEmailSentBadSenderOrRecipientEmail=No email sent. Bad sender or recipient email. Verify user profile. # Module Notifications Notifications=Notifications -NotificationsAuto=Notifications (Auto) +NotificationsAuto=Notifications Auto. NoNotificationsWillBeSent=No automtic email notifications are planned for this event type and company ANotificationsWillBeSent=1 automatic notification will be sent by email SomeNotificationsWillBeSent=%s automatic notifications will be sent by email From 7d25de5713dfeef35993f12715ad17e0fd8c80d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 15:39:14 +0200 Subject: [PATCH 131/173] Enhance setup page for email setup --- htdocs/admin/mails.php | 60 +++++++++++++++++++++------------ htdocs/admin/mails_emailing.php | 2 +- htdocs/admin/mails_ticket.php | 2 +- htdocs/langs/en_US/admin.lang | 5 ++- htdocs/langs/en_US/mails.lang | 2 +- htdocs/langs/en_US/other.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 476d782368e..1c3d397bc83 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -269,14 +269,12 @@ if ($action == 'edit') print ''; print ''; + print ''; - //Add user to select destinaries list - print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; - print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', $conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT, 1); - print ''; + print '
'; - // Separator - print ' '; + print ''; + print ''; // Method print ''; - // Separator - print ''; + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; @@ -434,8 +432,12 @@ if ($action == 'edit') print ''; print '
 
'; + + print '
'; + + print ''; + print ''; // From print ''; @@ -451,9 +453,6 @@ if ($action == 'edit') print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0); print ''; - // Separator - print ''; - // From print ''; print ''; + // Add user to select destinaries list + print ''; + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").'
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; + print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT', $conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT, 1); + print '
'; dol_fiche_end(); @@ -498,17 +502,23 @@ if ($action == 'edit') } print ''; - //Add user to select destinaries list - print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).''; + print ''; - // Separator - print ' '; + print '
'; + + print ''; + print ''; // Method print ''; // Host server @@ -591,8 +601,16 @@ if ($action == 'edit') print ''; } - // Separator - print ''; + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; if (empty($text)) $text = $langs->trans("Undefined").img_warning(); print $text; + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print $form->textwithpicto('', $langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC"), 1, 'warning'); + } + print '
 
'; + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print info_admin($langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC"), 0, 0, 'warning'); + } + + print '
'; + + print ''; + print ''; // From print ''; @@ -645,9 +663,6 @@ if ($action == 'edit') } print ''; - // Separator - print ''; - // Errors To print ''; print ''; + //Add user to select destinaries list + print ''; + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; @@ -666,6 +681,9 @@ if ($action == 'edit') } print '
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
'; dol_fiche_end(); @@ -717,7 +735,7 @@ if ($action == 'edit') $text = ''; if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { - $text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS + //$text .= $langs->trans("WarningPHPMail"); // To encourage to use SMTPS } if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index f78ef0277bb..d841dcf0827 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -120,7 +120,7 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup'); $listofmethods['mail'] = 'PHP mail function'; //$listofmethods['simplemail']='Simplemail class'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; -$listofmethods['swiftmailer'] = 'Swift Mailer socket library'; +if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if ($action == 'edit') diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 0a452d109ce..a11859efc89 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -120,7 +120,7 @@ $listofmethods['default'] = $langs->trans('DefaultOutgoingEmailSetup'); $listofmethods['mail'] = 'PHP mail function'; //$listofmethods['simplemail']='Simplemail class'; $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; -$listofmethods['swiftmailer'] = 'Swift Mailer socket library'; +if (version_compare(phpversion(), '7.0', '>=')) $listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if ($action == 'edit') diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d1f79f859d3..f407d69251d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -478,7 +478,10 @@ ModuleCompanyCodeCustomerDigitaria=%s followed by the truncated customer name by ModuleCompanyCodeSupplierDigitaria=%s followed by the truncated supplier name by the number of characters: %s for the supplier accounting code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... -WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) do not allow you to send an email from another server than their own server. Your current setup uses the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not theirs, so few of your sent Emails may not be accepted (be careful also of your email provider's sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider. +WarningPHPMail=WARNING: The setup to send emails from the application is using the default generic setup. It is often better to setup outgoing emails to use the email server of your Email Service Provider instead of the default setup for several reasons: +WarningPHPMailA=- Using the server of the Email Service Provider increase the trustability of your email, so it increase the deliverablity without being flagging as SPAM +WarningPHPMailB=- Some Email Service Providers (like Yahoo) do not allow you to send an email from another server than their own server. Your current setup uses the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not theirs, so few of your sent Emails may not be accepted for delivery (be careful also of your email provider's sending quota). +WarningPHPMailC=- Using the SMTP server of your own Email Service Provider to send emails is also interesting so all emails sent from application will also be saved into your "Sent" directory of your mailbox. WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of the mail user agent (MUA) for your ERP CRM application: %s. WarningPHPMailSPF=If the domain name in your sender email address is protected by SPF (ask you email provider), you must include the following IPs in the SPF record of the DNS of your domain: %s. ClickToShowDescription=Click to show description diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 009580e947a..d259d073cb8 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -166,7 +166,7 @@ NoContactLinkedToThirdpartieWithCategoryFound=No contact/address with a category OutGoingEmailSetup=Outgoing email setup InGoingEmailSetup=Incoming email setup OutGoingEmailSetupForEmailing=Outgoing email setup (for module %s) -DefaultOutgoingEmailSetup=Default outgoing email setup +DefaultOutgoingEmailSetup=Same configuration than the global Outgoing email setup Information=Information ContactsWithThirdpartyFilter=Contacts with third-party filter Unanswered=Unanswered diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 0448672a577..59a0069cd7d 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -261,7 +261,7 @@ ContactCreatedByEmailCollector=Contact/address created by email collector from e ProjectCreatedByEmailCollector=Project created by email collector from email MSGID %s TicketCreatedByEmailCollector=Ticket created by email collector from email MSGID %s OpeningHoursFormatDesc=Use a - to separate opening and closing hours.
Use a space to enter different ranges.
Example: 8-12 14-18 - + ##### Export ##### ExportsArea=Exports area AvailableFormats=Available formats diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index baf38869cab..311c366d9e5 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -478,7 +478,7 @@ ModuleCompanyCodeCustomerDigitaria=%s suivi du nom de client tronqué du nombre ModuleCompanyCodeSupplierDigitaria=%s suivi du nom du fournisseur tronqué du nombre de caractères: %s pour le code comptable fournisseur. Use3StepsApproval=Par défaut, les commandes fournisseurs nécessitent d'être créées et approuvées par 2 utilisateurs différents (une étape/utilisateur pour créer et une étape/utilisateur pour approuver. Notez que si un utilisateur à les deux permissions, ces deux actions sont effectuées en une seule fois). Cette option ajoute la nécessité d'une approbation par une troisième étape/utilisateur, si le montant de la commande est supérieur au montant d'une valeur définie (soit 3 étapes nécessaire: 1 =Validation, 2=Première approbation et 3=seconde approbation si le montant l'exige).
Laissez le champ vide si une seule approbation (2 étapes) est suffisante, placez une valeur très faible (0.1) si une deuxième approbation (3 étapes) est toujours exigée. UseDoubleApproval=Activer l'approbation en trois étapes si le montant HT est supérieur à... -WarningPHPMail=Attention : Il est préférable de configurer les emails sortant pour utiliser le serveur email de votre fournisseur plutôt que la configuration par défaut. Certains fournisseurs email (comme Yahoo) ne permettent pas l'envoi d'e-mails depuis un autre serveur que le leur si l'adresse d'envoi utilisée est une adresse autre que la leur. Votre configuration actuelle utilise le serveur de l'application pour l'envoi d'e-mails et non le serveur de votre fournisseur de messagerie, aussi certains destinataires (ceux compatibles avec le protocole restrictif DMARC) demanderont au fournisseur d'email si ils peuvent accepter l'email et certains fournisseurs (comme Yahoo) peuvent répondre "non" car le serveur utilisé pour l'envoi n'est pas un serveur appartenant au fournisseur, aussi certains de vos emails envoyés peuvent ne pas etre accepté (faites attention aussi aux quotas de votre fournisseur d'email).
SI votre fournisseur d'email (comme Yahoo) impose cette restriction, vous devrez modifier votre configuration et opter pour l'autre méthode d'envoi "SMTP server" et saisir les identifiants SMTP de votre compte fournis par votre fournisseur d'e-mail (à demander à votre fournisseur d'e-mail) +WarningPHPMail=Attention : La configuration d'envoi d'email utilise une configuration par défaut. Il est préférable de configurer les emails sortant pour utiliser le serveur email de votre fournisseur plutôt que la configuration par défaut pour plusieurs raisons: WarningPHPMail2=Si votre fournisseur de messagerie SMTP a besoin de restreindre le client de messagerie à certaines adresses IP (très rare), voici l'adresse IP du mail user agent (MUA) de votre application CRM ERP : %s . WarningPHPMailSPF=Si le nom de domaine de votre adresse e-mail d'expéditeur est protégé par SPF (demandez à votre fournisseur d'e-mail), vous devez inclure les adresses IP suivantes dans l'enregistrement SPF du DNS de votre domaine: %s . ClickToShowDescription=Cliquer pour afficher la description From 48e34c2069e4ff6a16e6314a5ab59760bb594f73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Sep 2020 15:53:18 +0200 Subject: [PATCH 132/173] Add int --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f1b10559898..f94a5ac3154 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -264,7 +264,7 @@ class ProductCombination $this->fetchCombinationPriceLevels(); } - return $this->fk_product_parent; + return (int) $this->fk_product_parent; } /** From 7252022afedab42ce4bedfd1722f257381546119 Mon Sep 17 00:00:00 2001 From: chkernit <46865400+99Deon@users.noreply.github.com> Date: Sat, 12 Sep 2020 16:33:07 +0100 Subject: [PATCH 133/173] fix problem in table "llx_c_ticket_category.sql" when install dolibarr project the step of creation tables does not completed because there are a bug in create llx_c_ticket_category.sql table . --- htdocs/install/mysql/tables/llx_c_ticket_category.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index 1e98de92d3b..58126633ce1 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -24,7 +24,7 @@ create table llx_c_ticket_category label varchar(128) NOT NULL, active integer DEFAULT 1, use_default integer DEFAULT 1, - fk_parent integer DEFAULT 0 NOT NULL; -- Parent group + fk_parent integer DEFAULT 0 NOT NULL, -- Parent group force_severity varchar(32) NULL, -- To force the severity if we choosed this category description varchar(255) )ENGINE=innodb; From ef0b84a507bd696769d237471ea32b1a34f0f389 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Sat, 12 Sep 2020 16:40:00 +0100 Subject: [PATCH 134/173] allow external users to see thirdparties with printFieldListWhere hook; --- htdocs/societe/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 923e930c796..8ee66b11657 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -433,7 +433,6 @@ if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciau elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL"; @@ -488,6 +487,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook) && $socid) $sql .= " AND s.rowid = ".$socid; + $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); From d728d268cad3feb1889eb03df254dbf354a8e0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:49:52 +0200 Subject: [PATCH 135/173] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index df3bd5eaf69..94c5971a416 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -143,6 +143,10 @@ class Paiement extends CommonObject */ public $fk_paiement; // Type of payment + /** + * @var string payment external reference + */ + public $ref_ext; /** * Constructor @@ -164,7 +168,7 @@ class Paiement extends CommonObject */ public function fetch($id, $ref = '', $fk_bank = '') { - $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; + $sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as type_code, c.libelle as type_label,'; $sql .= ' p.num_paiement as num_payment, p.note,'; $sql .= ' b.fk_account'; @@ -187,6 +191,7 @@ class Paiement extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref ? $obj->ref : $obj->rowid; + $this->ref_ext = $obj->ref_ext; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); $this->num_paiement = $obj->num_payment; // deprecated @@ -278,6 +283,10 @@ class Paiement extends CommonObject $this->db->begin(); $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); + + if (empty($this->ref_ext)) { + $this->ref_ext = ''; + } if ($way == 'dolibarr') { @@ -291,8 +300,8 @@ class Paiement extends CommonObject $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement); $note = ($this->note_public ? $this->note_public : $this->note); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; $resql = $this->db->query($sql); From 1f5419c883c24bb6f076035e31b639154884268b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:53:02 +0200 Subject: [PATCH 136/173] Update llx_paiement.sql --- htdocs/install/mysql/tables/llx_paiement.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index d19d38312a4..dabe261798b 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -22,6 +22,7 @@ create table llx_paiement ( rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30) NULL, -- payment reference number + ref_ext varchar(255) NULL, -- payment external reference entity integer DEFAULT 1 NOT NULL, -- Multi company id datec datetime, -- date de creation tms timestamp, From 29931bbdedf7e74ea6a53d4cd0ac3cca603defd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:55:26 +0200 Subject: [PATCH 137/173] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index defe5736aa8..e3a1d1807bc 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -320,3 +320,5 @@ ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL; ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; +ALTER TABLE llx_paiement ADD COLUMN ref_ext varchar(255) AFTER ref; + From acc995a5536708dd515c150ddbbefe06c9ac0c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 19:05:33 +0200 Subject: [PATCH 138/173] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 628abc128f4..9e78d186172 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -297,6 +297,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiement'; $field = 'fk_facture'; $field2 = 'fk_paiement'; + $field3=', p.ref_ext'; $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -304,10 +305,11 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiementfourn'; $field = 'fk_facturefourn'; $field2 = 'fk_paiementfourn'; + $field3=''; $sharedentity = 'facture_fourn'; } - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; + $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3; $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; $sql .= ' WHERE pf.'.$field.' = '.$this->id; //$sql.= ' WHERE pf.'.$field.' = 1'; @@ -325,7 +327,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + if (!empty($field3)) { + $tmp['ref_ext'] = $obj->ref_ext; + } + $retarray[]=$tmp; $i++; } $this->db->free($resql); From 2cfe740d85df1bb1f82ee2e10ccda46fdc21507e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 12 Sep 2020 17:08:44 +0000 Subject: [PATCH 139/173] Fixing style errors. --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 94c5971a416..67ab5fc3c22 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -283,7 +283,7 @@ class Paiement extends CommonObject $this->db->begin(); $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); - + if (empty($this->ref_ext)) { $this->ref_ext = ''; } From 1c523abbd838cbd454f83e8015e8a2d49364e716 Mon Sep 17 00:00:00 2001 From: "DEMAREST Maxime (Indelog)" Date: Sat, 12 Sep 2020 08:51:58 +0200 Subject: [PATCH 140/173] Fix: getLabelOfUnit() for Product, CommonObjectline to print long label Also add $type = 'code' for return unit code in form 'unitXX' (where XX is the code of unit). for get return like unitXX where XX is the code of unit --- htdocs/core/class/commonobjectline.class.php | 17 ++++++++--------- htdocs/product/class/product.class.php | 12 ++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 4874dded08d..5d03c91ca4b 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -54,7 +54,7 @@ abstract class CommonObjectLine extends CommonObject * Returns the translation key from units dictionary. * A langs->trans() must be called on result to get translated value. * - * @param string $type Label type (long or short). This can be a translation key. + * @param string $type Label type (long, short or code). This can be a translation key. * @return string|int <0 if ko, label if ok */ public function getLabelOfUnit($type = 'long') @@ -69,17 +69,16 @@ abstract class CommonObjectLine extends CommonObject $label_type = 'label'; - if ($type == 'short') - { - $label_type = 'short_label'; - } + $label_type = 'label'; + if ($type == 'short') $label_type = 'short_label'; + elseif ($type == 'code') $label_type = 'code'; - $sql = 'select '.$label_type.',code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; + $sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; $resql = $this->db->query($sql); - if ($resql && $this->db->num_rows($resql) > 0) - { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); - $label = ($label_type == 'short' ? $res[$label_type] : 'unit'.$res['code']); + if ($label_type == 'code') $label = 'unit'.$res['code']; + else $label = $res[$label_type]; $this->db->free($resql); return $label; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d1f36ca055d..b5f278bcf61 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5368,8 +5368,9 @@ class Product extends CommonObject /** * Returns the text label from units dictionary + * A langs->trans() must be called on result to get translated value. * - * @param string $type Label type (long or short) + * @param string $type Label type (long, short or code) * @return string|int <0 if ko, label if ok */ public function getLabelOfUnit($type = 'long') @@ -5383,16 +5384,15 @@ class Product extends CommonObject $langs->load('products'); $label_type = 'label'; - - if ($type == 'short') { - $label_type = 'short_label'; - } + if ($type == 'short') $label_type = 'short_label'; + elseif ($type == 'code') $label_type = 'code'; $sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); - $label = ($label_type == 'short_label' ? $res[$label_type] : 'unit'.$res['code']); + if ($label_type == 'code') $label = 'unit'.$res['code']; + else $label = $res[$label_type]; $this->db->free($resql); return $label; } From 8a561c644fd595332e35f7fe44fcbddc730ee0a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:03:33 +0200 Subject: [PATCH 141/173] Doc --- build/exe/doliwamp/README.md | 1 + build/exe/doliwamp/doliwamp.iss | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/exe/doliwamp/README.md b/build/exe/doliwamp/README.md index 87d3371f9bb..be8cf1f3ac5 100644 --- a/build/exe/doliwamp/README.md +++ b/build/exe/doliwamp/README.md @@ -5,6 +5,7 @@ It's a dedicated Dolibarr version for Windows newbies with no technical knowledg This directory contains files used by *makepack-dolibarr.pl* script to build the all-in-on .EXE package DoliWamp, ready to be distributed (for Windows). +The build of .exe files need to have some windows executable files already installed (Apache, MariaDb). The package to install to get this files are defined into the file *doliwamp.iss* (searhc line starting with "; Value OK:") If you have technical knowledge in web administration and plan to share your server instance (Apache, Mysql or PHP) with other projects than Dolibarr or want to use Dolibarr other components (PostgreSQL), you should not use this assistant and make a manual installation of Dolibarr on your existing server by downloading the standard package (.tgz or .zip file). diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 4a6dca3af01..49f943cfe82 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -104,7 +104,7 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) -; Value To test: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) +; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" From 3aff66bc899e0d7e70d45af52afe3e5d91a3845a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:08:28 +0200 Subject: [PATCH 142/173] Doc --- build/README | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build/README b/build/README index 67ceb05c8d2..a621e4cb9e5 100644 --- a/build/README +++ b/build/README @@ -19,10 +19,8 @@ Note: Prerequisites to build autoexe DoliWamp package: > Launch "wine cmd" to check a drive Z: pointing to / exists. > Install InnoSetup For example by running isetup-5.3.9.exe (http://www.jrsoftware.org) -> Install WampServer into "C:\Program Files\Wamp" - For example by running wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe (http://www.wampserver.com) -> Install WampServer addon to have versions: Mysql5.0.45 - For example by running WampServer2-MYSQL5045.exe (http://www.wampserver.com) +> Install WampServer into "C:\Program Files\Wamp" to have Apache and MariaDB + For example by running wampserver3.2.0_x64.exe (http://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup. > To build from Windows (running from makepack-dolibarr.pl script is however recommanded), open file build/exe/doliwamp.iss and click on button "Compile". The .exe file will be build into directory build. From 5e2494a82c30faeb8da08bf929990967453a629d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:17:21 +0200 Subject: [PATCH 143/173] Update doc --- build/README | 32 ++++++++++++++++++++++---------- build/pdf/README.txt | 13 +++++++------ build/sitemap/urllist-wiki.txt | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/build/README b/build/README index a621e4cb9e5..f7e8ebfe60b 100644 --- a/build/README +++ b/build/README @@ -19,28 +19,34 @@ Note: Prerequisites to build autoexe DoliWamp package: > Launch "wine cmd" to check a drive Z: pointing to / exists. > Install InnoSetup For example by running isetup-5.3.9.exe (http://www.jrsoftware.org) -> Install WampServer into "C:\Program Files\Wamp" to have Apache and MariaDB +> Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB For example by running wampserver3.2.0_x64.exe (http://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup. -> To build from Windows (running from makepack-dolibarr.pl script is however - recommanded), open file build/exe/doliwamp.iss and click on button "Compile". - The .exe file will be build into directory build. > Add path to ISCC into PATH windows var: Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH +> To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded), + open file build/exe/doliwamp.iss and click on button "Compile". + The .exe file will be build into directory build. + + - To build a theme package, launch the script > perl makepack-dolibarrtheme.pl + + - To build a package for a module, launch the script > perl makepack-dolibarrmodule.pl + + - To build developper documentation, launch the script > perl dolibarr-doxygen-build.pl + Note: -The build directory and all its contents is absolutely not required to make -Dolibarr working. It is here only to build Dolibarr packages, and those -generated packages will not contains this "build" directory. +The build directory and all its contents is absolutely not required to make Dolibarr working. +It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory. You can find in "build", following sub-directories: @@ -57,6 +63,9 @@ To build Mac OS package (not ready yet). * doap: To build Doap descriptor to promote/describe Dolibarr releases. +* docker: +To deploy Dolibarr with docker. + * doxygen: Dir with config file to build doxygen documentation. @@ -64,12 +73,12 @@ Dir with config file to build doxygen documentation. To build exe package for Windows that distribute Dolibarr sources or to build the complete DoliWamp package. +* gource: +To build the video of history of git changes. + * launchpad: Doc file to explain how to use launchpad. -* live: -Doc file to explain how to create a demo live CD. - * obs: Doc file to explain how to push release onto OBS. @@ -88,5 +97,8 @@ To build Redhat, Opensuse or Mandriva package. * tgz: To build a tgz package. +* travis-ci: +Used by travis to make CI. + * zip: To build a zip package. diff --git a/build/pdf/README.txt b/build/pdf/README.txt index 2335ff4b7f7..7a5424ca3d5 100644 --- a/build/pdf/README.txt +++ b/build/pdf/README.txt @@ -1,9 +1,10 @@ -To make htmldoc working from wiki.dolibarr.org, them must be modified to have +To make htmldoc working from wiki.dolibarr.org, the wiki must be modified to have -$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z" -$_COOKIE["htmldoc"] may also be defined if set on command line. - -To disable part, add -class="htmldoc-ignore" with css +To disable part of content, add: +class="htmldoc-ignore" +with css .htmldoc-ignore { display: none; } +Note: +$_SERVER["HTTP_USER_AGENT"] is "HTMLDOC/x.y.z" +$_COOKIE["htmldoc"] may also be defined if set on command line. diff --git a/build/sitemap/urllist-wiki.txt b/build/sitemap/urllist-wiki.txt index ae13bb96d87..2a70e61f146 100644 --- a/build/sitemap/urllist-wiki.txt +++ b/build/sitemap/urllist-wiki.txt @@ -1 +1 @@ -http://wiki.dolibarr.org/ +https://wiki.dolibarr.org/ From ca4716dfb7227749f65d63284c9b48e795fc776c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:45:28 +0200 Subject: [PATCH 144/173] Fix for wampserver3_64 --- build/exe/doliwamp/doliwamp.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 49f943cfe82..ed8e07d7468 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -105,7 +105,7 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) ; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" +Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" ;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" From 76fc8330a31ed7b2418c356efbb13276e88591db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 13:45:28 +0200 Subject: [PATCH 145/173] Fix for wampserver3_64 Conflicts: build/exe/doliwamp/doliwamp.iss --- build/exe/doliwamp/doliwamp.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 4a6dca3af01..ed8e07d7468 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -104,8 +104,8 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) -; Value To test: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" +; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) +Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" ;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" From f9af7bc1144bc3e607cdd164d211ec4e77bdd1a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 14:42:56 +0200 Subject: [PATCH 146/173] Fix phpcs --- htdocs/core/ajax/check_notifications.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index b70afe936f7..f8a30e69aa9 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -61,7 +61,7 @@ if ($action == 'stopreminder') { $listofreminderidsarray = explode('-', GETPOST('listofreminderids', 'aZ09')); // Set the reminder as done - foreach($listofreminderidsarray as $listofreminderid) { + foreach ($listofreminderidsarray as $listofreminderid) { if (empty($listofreminderid)) continue; //$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'action_reminder WHERE rowid = '.$listofreminderid.' AND fk_user = '.$user->id; $sql = 'UPDATE '.MAIN_DB_PREFIX.'actioncomm_reminder SET status = 1'; @@ -72,7 +72,7 @@ if ($action == 'stopreminder') { } } - include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Clean database $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'actioncomm_reminder'; From 929804f4d2a4a6c1972ab1ad367349f91f8c833c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sun, 13 Sep 2020 15:12:22 +0200 Subject: [PATCH 147/173] Update api_invoices.class.php --- .../facture/class/api_invoices.class.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 53603415d7f..eed22f5d761 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1522,6 +1522,52 @@ class Invoices extends DolibarrApi return $paiement_id; } + + /** + * Update a payment + * + * @param int $id Id of payment + * @param string $num_paiement Payment number + * + * @url PUT payments/{id} + * + * @return array + * @throws 400 + * @throws 401 + * @throws 404 + */ + public function putPayment($id, $num_paiement = '') + { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Payment ID is mandatory'); + } + + $paiement = new Paiement($this->db); + $result = $paiement->fetch($id); + + if (!$result) { + throw new RestException(404, 'Paiement not found'); + } + + if (!empty($num_paiement)) { + $result = $paiement->update_num($num_paiement); + if ($result < 0) { + throw new RestException(500, 'Error when updating the payment num'); + } + } + + return [ + 'success' => [ + 'code' => 200, + 'message' => 'Payment updated' + ] + ]; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** From 8d3bc3ee6f9e69ca4df88c0121bbf8d04bc26f23 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 13 Sep 2020 13:18:42 +0000 Subject: [PATCH 148/173] Fixing style errors. --- htdocs/compta/facture/class/api_invoices.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index eed22f5d761..0cb2a1f78fa 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1522,7 +1522,7 @@ class Invoices extends DolibarrApi return $paiement_id; } - + /** * Update a payment * @@ -1539,28 +1539,28 @@ class Invoices extends DolibarrApi public function putPayment($id, $num_paiement = '') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } if (empty($id)) { throw new RestException(400, 'Payment ID is mandatory'); } - + $paiement = new Paiement($this->db); $result = $paiement->fetch($id); - + if (!$result) { throw new RestException(404, 'Paiement not found'); } - + if (!empty($num_paiement)) { $result = $paiement->update_num($num_paiement); if ($result < 0) { throw new RestException(500, 'Error when updating the payment num'); } } - + return [ 'success' => [ 'code' => 200, From 3585d3d52fce87b11227a0cec79be02764e9987f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Sep 2020 15:21:45 +0200 Subject: [PATCH 149/173] css --- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/dropdown.inc.php | 4 +++- htdocs/theme/md/style.css.php | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 83cba7b4f55..5ce53a23ed8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4197,7 +4197,7 @@ div.ui-tooltip.mytooltip { filter:progid:DXImageTransform.Microsoft.Shadow(color=#656565, Direction=134, Strength=5); background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor); - line-height: 1.8em; + line-height: 1.6em; } diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index b86b935c5d1..a8d2f77498d 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -218,7 +218,7 @@ a.top-menu-dropdown-link { .dropdown-menu .dropdown-header{ - padding: 5px 10px 10px 10px; + padding: 8px 10px 10px 10px; } .dropdown-menu > .user-footer { @@ -232,6 +232,8 @@ a.top-menu-dropdown-link { .dropdown-menu > .bookmark-footer{ + border-top: 1px solid #f0f0f0; + background-color: #f9f9f9; padding: 10px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 970c81e9139..4234790cc87 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4093,17 +4093,20 @@ div.ui-tooltip { max-width: px !important; } -.mytooltip { +div.ui-tooltip.mytooltip { width: px; border-top: solid 1px #BBBBBB; border-: solid 1px #BBBBBB; border-: solid 1px #444444; border-bottom: solid 1px #444444; - padding: 5px 20px; + padding: 10px 20px; border-radius: 0; box-shadow: 0 0 4px grey; margin: 2px; font-stretch: condensed; + /*background: var(--tooltipbgcolor) !important; + color : var(--tooltipfontcolor);*/ + line-height: 1.6em; } @@ -6154,6 +6157,25 @@ border-top-right-radius: 6px; } +/* ============================================================================== */ +/* CSS style for debugbar */ +/* ============================================================================== */ + +span.phpdebugbar-tooltip.phpdebugbar-tooltip-extra-wide, span.phpdebugbar-tooltip.phpdebugbar-tooltip-wide { + width: 250px !important; +} +.phpdebugbar-indicator span.phpdebugbar-tooltip { + opacity: .95 !important; +} +a.phpdebugbar-tab.phpdebugbar-active { + background-image: unset !important; +} +.phpdebugbar-indicator .fa { + font-family: "Font Awesome 5 Free"; + font-weight: 600; +} + + /* ============================================================================== */ /* CSS style used for jFlot */ /* ============================================================================== */ From e55c16c039211124e82c868cb35b19e2d130aff6 Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sun, 13 Sep 2020 21:12:14 +0200 Subject: [PATCH 150/173] NEW Weighing Scale compatibility with TakePOS connector --- htdocs/langs/en_US/cashdesk.lang | 3 ++- htdocs/takepos/admin/receipt.php | 8 ++++++++ htdocs/takepos/index.php | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 40691eb70e7..549646ab110 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -121,4 +121,5 @@ GiftReceiptButton=Add a "Gift receipt" button GiftReceipt=Gift receipt ModuleReceiptPrinterMustBeEnabled=Module Receipt printer must have been enabled first AllowDelayedPayment=Allow delayed payment -PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts \ No newline at end of file +PrintPaymentMethodOnReceipts=Print payment method on tickets|receipts +WeighingScale=Weighing scale \ No newline at end of file diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index cff6eabd449..62e08d2084d 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -233,6 +233,14 @@ print ''; print $form->selectyesno("TAKEPOS_AUTO_PRINT_TICKETS", $conf->global->TAKEPOS_AUTO_PRINT_TICKETS, 1); print "\n"; +if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector" && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { + print ''; + print $langs->trans('WeighingScale'); + print ''; + print ajax_constantonoff("TAKEPOS_WEIGHING_SCALE", array(), $conf->entity, 0, 0, 1, 0); + print "\n"; +} + print ''; print '
'; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 82dec49b7db..390f71491ba 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -747,6 +747,19 @@ function FullScreen() { document.documentElement.requestFullscreen(); } +function WeighingScale(){ + console.log("Weighing Scale"); + $.ajax({ + type: "POST", + url: 'global->TAKEPOS_PRINT_SERVER; ?>/scale', + }) + .done(function( editnumber ) { + $("#poslines").load("invoice.php?action=updateqty&place="+place+"&idline="+selectedline+"&number="+editnumber, function() { + editnumber=""; + }); + }); +} + $( document ).ready(function() { PrintCategories(0); LoadProducts(0); @@ -975,6 +988,11 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { $menus[$r++] = array('title'=>'
'.$langs->trans("Logout").'
', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); } +if ($conf->global->TAKEPOS_WEIGHING_SCALE) +{ + $menus[$r++] = array('title'=>'
'.$langs->trans("WeighingScale").'
', 'action'=>'WeighingScale();'); +} + ?>
From a4fb16b4f30277c263dc8086b11655289b8c3294 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:03:49 +0200 Subject: [PATCH 151/173] Add a warning to warn about security leak --- htdocs/admin/system/dolibarr.php | 18 ++++++++++-------- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 0796d934a74..97e7370a148 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -376,8 +376,7 @@ foreach ($configfileparameters as $key => $value) print ""; if ($newkey == 'dolibarr_main_db_pass') print preg_replace('/./i', '*', ${$newkey}); elseif ($newkey == 'dolibarr_main_url_root' && preg_match('/__auto__/', ${$newkey})) print ${$newkey}.' => '.constant('DOL_MAIN_URL_ROOT'); - elseif ($newkey == 'dolibarr_main_document_root_alt') - { + elseif ($newkey == 'dolibarr_main_document_root_alt') { $tmparray = explode(',', ${$newkey}); $i = 0; foreach ($tmparray as $value2) @@ -391,9 +390,7 @@ foreach ($configfileparameters as $key => $value) } ++$i; } - } - elseif ($newkey == 'dolibarr_main_instance_unique_id') - { + } elseif ($newkey == 'dolibarr_main_instance_unique_id') { //print $conf->file->instance_unique_id; global $dolibarr_main_cookie_cryptkey; $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey @@ -402,9 +399,14 @@ foreach ($configfileparameters as $key => $value) print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); } print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; - } - else - { + } elseif ($newkey == 'dolibarr_main_prod') { + print ${$newkey}; + + $valuetoshow = ${$newkey}; + if (empty($valuetoshow)) { + print img_warning($langs->trans('SwitchThisForABetterSecurity')); + } + } else { print ${$newkey}; } if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 482f89b30e7..ed10332352c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2022,3 +2022,4 @@ MeasuringScaleDesc=The scale is the number of places you have to move the decima TemplateAdded=Template added TemplateUpdated=Template updated TemplateDeleted=Template deleted +SwitchThisForABetterSecurity=Switching this value to 1 is recommended for more security From 0d9d9498e2623e2d850767d109c071dbdaae02fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:13:12 +0200 Subject: [PATCH 152/173] Update commonobjectline.class.php --- htdocs/core/class/commonobjectline.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5d03c91ca4b..a68d5c22002 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -51,7 +51,7 @@ abstract class CommonObjectLine extends CommonObject /** - * Returns the translation key from units dictionary. + * Returns the label, shot_label or code found in units dictionary from ->fk_unit. * A langs->trans() must be called on result to get translated value. * * @param string $type Label type (long, short or code). This can be a translation key. From d0698735d61969ce96474de6b78de5e5ed94c6f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:14:25 +0200 Subject: [PATCH 153/173] Update product.class.php --- htdocs/product/class/product.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b5f278bcf61..99590e27a36 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5367,11 +5367,12 @@ class Product extends CommonObject } /** - * Returns the text label from units dictionary - * A langs->trans() must be called on result to get translated value. + * Returns the label, shot_label or code found in units dictionary from ->fk_unit. + * A langs->trans() must be called on result to get translated value. * * @param string $type Label type (long, short or code) * @return string|int <0 if ko, label if ok + * @see getLabelOfUnit() in CommonObjectLine */ public function getLabelOfUnit($type = 'long') { From 26b4fb3e68d5a8c683bcd3948556111a2cd7a8ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:22:58 +0200 Subject: [PATCH 154/173] Update list.php --- htdocs/societe/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 8ee66b11657..96b50a34bf8 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -483,12 +483,12 @@ if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_s if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - // Add where from hooks -$parameters = array(); +$parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook) && $socid) $sql .= " AND s.rowid = ".$socid; - +if (empty($reshook)) { + if ($socid) $sql .= " AND s.rowid = ".$socid; +} $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); From dcdce246b1d24e2a87d9a162b18573dd4753c398 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:26:16 +0200 Subject: [PATCH 155/173] Update api_invoices.class.php --- htdocs/compta/facture/class/api_invoices.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 0cb2a1f78fa..3b77d2ed8b2 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1496,7 +1496,7 @@ class Invoices extends DolibarrApi $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); - $paiement->num_paiement = $num_paiement; + $paiement->num_payment = $num_paiement; $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($paiement_id < 0) @@ -1527,7 +1527,7 @@ class Invoices extends DolibarrApi * Update a payment * * @param int $id Id of payment - * @param string $num_paiement Payment number + * @param string $num_payment Payment number * * @url PUT payments/{id} * @@ -1547,15 +1547,15 @@ class Invoices extends DolibarrApi throw new RestException(400, 'Payment ID is mandatory'); } - $paiement = new Paiement($this->db); - $result = $paiement->fetch($id); + $paymentobj = new Paiement($this->db); + $result = $paymentobj->fetch($id); if (!$result) { - throw new RestException(404, 'Paiement not found'); + throw new RestException(404, 'Payment not found'); } - if (!empty($num_paiement)) { - $result = $paiement->update_num($num_paiement); + if (!empty($num_payment)) { + $result = $paymentobj->update_num($num_payment); if ($result < 0) { throw new RestException(500, 'Error when updating the payment num'); } From e9d0869383e10ead5a80b5e9f17201802499d777 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:28:43 +0200 Subject: [PATCH 156/173] Update api_invoices.class.php --- .../facture/class/api_invoices.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3b77d2ed8b2..e620506a8e7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1284,7 +1284,7 @@ class Invoices extends DolibarrApi * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} - * @param string $num_paiement {@from body} Payment number (optional) + * @param string $num_payment {@from body} Payment number (optional) * @param string $comment {@from body} Note (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) @@ -1297,7 +1297,7 @@ class Invoices extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1321,7 +1321,7 @@ class Invoices extends DolibarrApi } if (empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + throw new RestException(400, 'Payment ID or Payment Code is mandatory'); } @@ -1364,7 +1364,7 @@ class Invoices extends DolibarrApi $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); - $paiement->num_paiement = $num_paiement; + $paiement->num_payment = $num_payment; $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices @@ -1404,7 +1404,7 @@ class Invoices extends DolibarrApi * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} - * @param string $num_paiement {@from body} Payment number (optional) + * @param string $num_payment {@from body} Payment number (optional) * @param string $comment {@from body} Note (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) @@ -1418,7 +1418,7 @@ class Invoices extends DolibarrApi * @throws RestException 403 * @throws RestException 404 */ - public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1442,7 +1442,7 @@ class Invoices extends DolibarrApi } } if (empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + throw new RestException(400, 'Payment ID or Payment Code is mandatory'); } $this->db->begin(); @@ -1496,7 +1496,7 @@ class Invoices extends DolibarrApi $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); - $paiement->num_payment = $num_paiement; + $paiement->num_payment = $num_payment; $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($paiement_id < 0) @@ -1536,7 +1536,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - public function putPayment($id, $num_paiement = '') + public function putPayment($id, $num_payment = '') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; From a2df666d344f69e992c5de26df546bfd225fa954 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:41:31 +0200 Subject: [PATCH 157/173] Standardize code --- .../facture/class/api_invoices.class.php | 99 ++++++++++--------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e620506a8e7..f0125482cf9 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -876,8 +876,8 @@ class Invoices extends DolibarrApi * Sets an invoice as paid * * @param int $id Order ID - * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) - * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) + * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) + * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) * * @url POST {id}/settopaid * @@ -1060,7 +1060,7 @@ class Invoices extends DolibarrApi // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT // Total payments - $sql = 'SELECT SUM(pf.amount) as total_paiements'; + $sql = 'SELECT SUM(pf.amount) as total_payments'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' WHERE pf.fk_facture = '.$this->invoice->id; @@ -1070,7 +1070,7 @@ class Invoices extends DolibarrApi if (!$resql) dol_print_error($this->db); $res = $this->db->fetch_object($resql); - $total_paiements = $res->total_paiements; + $total_payments = $res->total_payments; // Total credit note and deposit $total_creditnote_and_deposit = 0; @@ -1083,7 +1083,7 @@ class Invoices extends DolibarrApi while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; } else dol_print_error($this->db); - $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $this->invoice->total_ttc; + $discount->amount_ht = $discount->amount_ttc = $total_payments + $total_creditnote_and_deposit - $this->invoice->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; @@ -1281,12 +1281,12 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param int $paymentid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note (optional) - * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') + * @param string $comment {@from body} Note public (optional) + * @param string $chqemetteur {@from body} Payment issuer (mandatory if paymentcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * * @url POST {id}/payments @@ -1297,7 +1297,7 @@ class Invoices extends DolibarrApi * @throws RestException 401 * @throws RestException 404 */ - public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1320,7 +1320,7 @@ class Invoices extends DolibarrApi } } - if (empty($paiementid)) { + if (empty($paymentid)) { throw new RestException(400, 'Payment ID or Payment Code is mandatory'); } @@ -1358,40 +1358,40 @@ class Invoices extends DolibarrApi // Creation of payment line - $paiement = new Paiement($this->db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; - $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); - $paiement->num_payment = $num_payment; - $paiement->note = $comment; + $paymentobj = new Paiement($this->db); + $paymentobj->datepaye = $datepaye; + $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id + $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paymentobj->paiementid = $paymentid; + $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); + $paymentobj->num_payment = $num_payment; + $paymentobj->note_public = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($paiement_id < 0) + $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices + if ($payment_id < 0) { $this->db->rollback(); - throw new RestException(400, 'Payment error : '.$paiement->error); + throw new RestException(400, 'Payment error : '.$paymentobj->error); } if (!empty($conf->banque->enabled)) { $label = '(CustomerInvoicePayment)'; - if ($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { - throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); + if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); } if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); if ($result < 0) { $this->db->rollback(); - throw new RestException(400, 'Add payment to bank error : '.$paiement->error); + throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); } } $this->db->commit(); - return $paiement_id; + return $payment_id; } /** @@ -1401,11 +1401,11 @@ class Invoices extends DolibarrApi * * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param int $paymentid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note (optional) + * @param string $comment {@from body} Note public (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * @@ -1418,7 +1418,7 @@ class Invoices extends DolibarrApi * @throws RestException 403 * @throws RestException 404 */ - public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1441,7 +1441,7 @@ class Invoices extends DolibarrApi throw new RestException(400, 'Account ID is mandatory'); } } - if (empty($paiementid)) { + if (empty($paymentid)) { throw new RestException(400, 'Payment ID or Payment Code is mandatory'); } @@ -1490,37 +1490,38 @@ class Invoices extends DolibarrApi } // Creation of payment line - $paiement = new Paiement($this->db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; - $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); - $paiement->num_payment = $num_payment; - $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($paiement_id < 0) + $paymentobj = new Paiement($this->db); + $paymentobj->datepaye = $datepaye; + $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id + $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paymentobj->paiementid = $paymentid; + $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); + $paymentobj->num_payment = $num_payment; + $paymentobj->note_public = $comment; + + $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices + if ($payment_id < 0) { $this->db->rollback(); - throw new RestException(400, 'Payment error : '.$paiement->error); + throw new RestException(400, 'Payment error : '.$paymentobj->error); } if (!empty($conf->banque->enabled)) { $label = '(CustomerInvoicePayment)'; - if ($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { - throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); + if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); } if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result = $paiement->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); if ($result < 0) { $this->db->rollback(); - throw new RestException(400, 'Add payment to bank error : '.$paiement->error); + throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); } } $this->db->commit(); - return $paiement_id; + return $payment_id; } /** @@ -1532,9 +1533,9 @@ class Invoices extends DolibarrApi * @url PUT payments/{id} * * @return array - * @throws 400 - * @throws 401 - * @throws 404 + * @throws RestException 400 Bad parameters + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found */ public function putPayment($id, $num_payment = '') { From 970995d72883c7f5bc35c5351cfec67b492b812b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 01:03:51 +0200 Subject: [PATCH 158/173] Clean code. Replace num_paiement with num_payment everywhere. --- htdocs/blockedlog/class/blockedlog.class.php | 2 +- htdocs/cashdesk/validation_verif.php | 3 +-- htdocs/compta/facture/class/api_invoices.class.php | 8 ++++---- htdocs/compta/paiement.php | 6 ++---- htdocs/compta/paiement/class/paiement.class.php | 14 +++----------- htdocs/compta/payment_sc/card.php | 2 +- .../prelevement/class/bonprelevement.class.php | 1 - .../prelevement/class/rejetprelevement.class.php | 1 - .../class/paymentsocialcontribution.class.php | 13 +++++-------- htdocs/expensereport/card.php | 1 - htdocs/fourn/class/paiementfourn.class.php | 3 +-- htdocs/fourn/facture/card.php | 6 +++--- htdocs/fourn/facture/paiement.php | 2 -- htdocs/public/payment/paymentok.php | 1 - 14 files changed, 21 insertions(+), 42 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index a9864e34c0d..7bb252394c3 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -476,7 +476,7 @@ class BlockedLog $this->object_data->ref = $object->ref; $this->object_data->date = $datepayment; $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code'); - $this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment); + $this->object_data->payment_num = $object->num_payment; //$this->object_data->fk_account = $object->fk_account; $this->object_data->note = $object->note; //var_dump($this->object_data);exit; diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 3253d6d5d3e..6b8e9af94f1 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -294,9 +294,8 @@ switch ($action) // Add the payment $payment = new Paiement($db); $payment->datepaye = $now; - $payment->bank_account = $conf_fkaccount; $payment->amounts[$invoice->id] = $obj_facturation->amountWithTax(); - $payment->note = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice(); + $payment->note_public = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice(); $payment->paiementid = $invoice->mode_reglement_id; $payment->num_paiement = ''; $payment->num_payment = ''; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index f0125482cf9..fe8ca7d42d3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1285,7 +1285,7 @@ class Invoices extends DolibarrApi * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note public (optional) + * @param string $comment {@from body} Note private (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if paymentcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * @@ -1365,7 +1365,7 @@ class Invoices extends DolibarrApi $paymentobj->paiementid = $paymentid; $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); $paymentobj->num_payment = $num_payment; - $paymentobj->note_public = $comment; + $paymentobj->note_private = $comment; $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($payment_id < 0) @@ -1405,7 +1405,7 @@ class Invoices extends DolibarrApi * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note public (optional) + * @param string $comment {@from body} Note private (optional) * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * @@ -1497,7 +1497,7 @@ class Invoices extends DolibarrApi $paymentobj->paiementid = $paymentid; $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); $paymentobj->num_payment = $num_payment; - $paymentobj->note_public = $comment; + $paymentobj->note_private = $comment; $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices if ($payment_id < 0) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 4390c9c1cb0..865ef40a258 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -265,8 +265,6 @@ if (empty($reshook)) $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility - $paiement->note = $paiement->note_private; // For bacward compatibility if (!$error) { @@ -851,7 +849,7 @@ if (!GETPOST('action', 'aZ09')) if (!$sortfield) $sortfield = 'p.datep'; $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; - $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE p.fk_facture = f.rowid'; @@ -887,7 +885,7 @@ if (!GETPOST('action', 'aZ09')) print ''; print ''.$objp->ref."\n"; print ''.dol_print_date($db->jdate($objp->dp))."\n"; - print ''.$objp->paiement_type.' '.$objp->num_paiement."\n"; + print ''.$objp->paiement_type.' '.$objp->num_payment."\n"; print ''.price($objp->amount).''; print ' '; print ''; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 67ab5fc3c22..a772d1856ee 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -90,13 +90,6 @@ class Paiement extends CommonObject */ public $type_code; - /** - * @var string Numero du CHQ, VIR, etc... - * @deprecated - * @see $num_payment - */ - public $numero; - /** * @var string Numero du CHQ, VIR, etc... * @deprecated @@ -194,7 +187,6 @@ class Paiement extends CommonObject $this->ref_ext = $obj->ref_ext; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); - $this->num_paiement = $obj->num_payment; // deprecated $this->num_payment = $obj->num_payment; $this->montant = $obj->amount; // deprecated $this->amount = $obj->amount; @@ -297,8 +289,8 @@ class Paiement extends CommonObject $mtotal = $totalamount; } - $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement); - $note = ($this->note_public ? $this->note_public : $this->note); + $num_payment = $this->num_payment; + $note = ($this->note_private ? $this->note_private : $this->note); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; @@ -716,7 +708,7 @@ class Paiement extends CommonObject $bank_line_id, $this->id_prelevement, DOL_URL_ROOT.'/compta/prelevement/card.php?id=', - $this->num_paiement, + $this->num_payment, 'withdraw' ); } diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index fbe5d926d33..2819e492f7b 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -182,7 +182,7 @@ print ''.$langs->trans('Date').''.dol_print_date($o print ''.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).''; // Numero -print ''.$langs->trans('Numero').''.$object->num_paiement.''; +print ''.$langs->trans('Numero').''.$object->num_payment.''; // Montant print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index fa2ef4e1387..067dd33cd81 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -507,7 +507,6 @@ class BonPrelevement extends CommonObject } $paiement->num_payment = $this->ref; // Set ref of direct debit note - $paiement->num_paiement = $this->ref; // For backward compatibility $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 8599987fb23..20d600bf9b4 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -153,7 +153,6 @@ class RejetPrelevement $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1); $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal - $pai->num_paiement = $fac->ref; $pai->num_payment = $fac->ref; if ($pai->create($this->user) < 0) // we call with no_commit diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 52939d6add7..62b02860f08 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -134,9 +134,8 @@ class PaymentSocialContribution extends CommonObject if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; if (isset($this->amount)) $this->amount = trim($this->amount); if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); - if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -265,9 +264,8 @@ class PaymentSocialContribution extends CommonObject $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; $this->fk_typepaiement = $obj->fk_typepaiement; - $this->num_paiement = $obj->num_payment; $this->num_payment = $obj->num_payment; - $this->note = $obj->note; + $this->note_private = $obj->note; $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; @@ -305,9 +303,8 @@ class PaymentSocialContribution extends CommonObject if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; if (isset($this->amount)) $this->amount = trim($this->amount); if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); - if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -326,7 +323,7 @@ class PaymentSocialContribution extends CommonObject $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; - $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; @@ -504,7 +501,7 @@ class PaymentSocialContribution extends CommonObject global $conf; // Clean data - $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); + $this->num_payment = trim($this->num_payment); $error = 0; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c3883ee6b3d..023b114835a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1933,7 +1933,6 @@ if ($action == 'create') $paymentexpensereportstatic->id = $objp->rowid; $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp); $paymentexpensereportstatic->ref = $objp->rowid; - $paymentexpensereportstatic->num_paiement = $objp->num_payment; $paymentexpensereportstatic->num_payment = $objp->num_payment; $paymentexpensereportstatic->payment_code = $objp->payment_code; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 404566b5392..67133ed97b2 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -119,7 +119,6 @@ class PaiementFourn extends Paiement $this->entity = $obj->entity; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); - $this->num_paiement = $obj->num_payment; $this->num_payment = $obj->num_payment; $this->bank_account = $obj->fk_account; $this->fk_account = $obj->fk_account; @@ -207,7 +206,7 @@ class PaiementFourn extends Paiement $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; $sql .= 'ref, entity, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; $sql .= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.", 0)"; + $sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', ".$user->id.", 0)"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d53a554f9d8..278896aae9b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2717,7 +2717,7 @@ if ($action == 'create') if ($societe->localtax1_assuj == "1") $nbrows++; if ($societe->localtax2_assuj == "1") $nbrows++; - $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,'; $sql .= ' c.id as paiement_type,'; $sql .= ' pf.amount,'; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal'; @@ -2755,7 +2755,7 @@ if ($action == 'create') $paymentstatic->id = $objp->rowid; $paymentstatic->datepaye = $db->jdate($objp->dp); $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); - $paymentstatic->num_paiement = $objp->num_paiement; + $paymentstatic->num_payment = $objp->num_payment; $paymentstatic->payment_code = $objp->payment_code; print ''; @@ -2764,7 +2764,7 @@ if ($action == 'create') print ''; print ''.dol_print_date($db->jdate($objp->dp), 'day').''; print ''; - print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_paiement; + print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_payment; print ''; if (!empty($conf->banque->enabled)) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index d5212582420..65b8936a592 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -301,9 +301,7 @@ if (empty($reshook)) $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->num_paiement = $paiement->num_payment; // For backward compatibility $paiement->num_payment = $paiement->num_payment; - $paiement->note = $paiement->note_private; // For backward compatibility $paiement->note_private = $paiement->note_private; if (!$error) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b2993ec86f5..3be1af4935e 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -628,7 +628,6 @@ if ($ispaymentok) $error++; // Not yet supported } $paiement->paiementid = $paymentTypeId; - $paiement->num_paiement = ''; $paiement->num_payment = ''; $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; $paiement->ext_payment_id = $TRANSACTIONID; From 442fef207c031c87b0f286441fea3b79a235c95d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 01:04:29 +0200 Subject: [PATCH 159/173] Doc --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9653e4577cc..d1aa820e4a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ Following changes may create regressions for some external modules, but were nec your email templates. * The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom days of holiday. +* Property num_paiement has been renamed num_payment everywhere for better code consistency. + ***** ChangeLog for 12.0.2 compared to 12.0.1 ***** FIX: computation of the bottom margin of returns NaN because body is not loaded yet From dad02afa22931e7c8aa3c7a9c59309dd5e8ea874 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 01:13:07 +0200 Subject: [PATCH 160/173] Update accountancy.lang --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index f661ab07fe1..464823810b2 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -172,7 +172,7 @@ ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions -ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Accounting account to register customer deposit +ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT=Accounting account by default to register customer deposit ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for the bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT=Accounting account by default for the bought products in EEC (used if not defined in the product sheet) From c3ba8f7843461fe26a5c90a69c0eb5ddf19a109b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:13:27 +0200 Subject: [PATCH 161/173] Better translation --- htdocs/core/tpl/objectline_title.tpl.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index f04bfc50da8..88a8d69cdf7 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -59,7 +59,13 @@ if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' } // VAT -print ''.$langs->trans('VAT').''; +print ''; +if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FACTURE_LOCAL_TAX1_OPTION)) { + print $langs->trans('Taxes'); +} else { + print $langs->trans('VAT'); +} +print ''; // Price HT print ''.$langs->trans('PriceUHT').''; From a891211f78d804bf92dc22c3fc8ac2d064602aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:32:30 +0200 Subject: [PATCH 162/173] Fix bad link --- htdocs/adherents/stats/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 10eca32ac13..762a7d666c7 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -183,9 +183,9 @@ foreach ($data as $val) $oldyear--; print ''; print ''; - print ''; + //print ''; print $oldyear; - print ''; + //print ''; print ''; print '0'; print '0'; From 701b83db3851d442c2411a304ef52fd7cd9f9726 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:38:12 +0200 Subject: [PATCH 163/173] FIX Bad number of subscription (forgotten when member was resiliated) --- htdocs/adherents/class/adherentstats.class.php | 2 +- htdocs/adherents/stats/byproperties.php | 6 +++--- htdocs/adherents/stats/geo.php | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index bdb174cc0bd..eff42f92a43 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -68,7 +68,7 @@ class AdherentStats extends Stats $this->field = 'subscription'; - $this->where .= " m.statut != 0"; + $this->where .= " m.statut != -1"; $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; //if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->memberid) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 7927c2e3f00..3a6a7eb0342 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -108,19 +108,19 @@ dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'use // Print title if (!count($data)) { - print $langs->trans("NoValidatedMemberYet").'
'; + print ''.$langs->trans("NoValidatedMemberYet").'
'; print '
'; } else { - print $langs->trans("MembersByNature").'
'; + print ''.$langs->trans("MembersByNature").'
'; print '
'; } // Print array print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 5b51008a9a2..db556c0eea7 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -221,13 +221,13 @@ if ($mode && !count($data)) } else { - if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'
'; - elseif ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'
'; - elseif ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print $langs->trans("MembersByRegion").'
'; //+ + if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; + elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; + elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; + elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ else { - print $langs->trans("MembersStatisticsDesc").'
'; + print ''.$langs->trans("MembersStatisticsDesc").'
'; print '
'; print ''.$langs->trans("MembersStatisticsByCountries").'
'; print '
'; From 78a999e6f33b2f47c938c258d738d731d8f7588c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 02:57:43 +0200 Subject: [PATCH 164/173] css --- htdocs/theme/eldy/global.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 5ce53a23ed8..1e4f278afc0 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4198,6 +4198,7 @@ div.ui-tooltip.mytooltip { background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor); line-height: 1.6em; + min-width: 200px; } From 419ac91a7a8232e4b7ddd9f3a4a4c86162bd928e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 03:34:03 +0200 Subject: [PATCH 165/173] FIX #14538 --- htdocs/adherents/stats/byproperties.php | 57 +++++++++++++++++++++---- htdocs/adherents/stats/geo.php | 16 +++---- htdocs/langs/en_US/members.lang | 1 + 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index fa8e07ad053..d64fbdfa35d 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -61,16 +61,16 @@ print load_fiche_titre($title, '', 'object_group'); dol_mkdir($dir); -$tab = 'byproperties'; - $data = array(); -$sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code"; + +$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,"; +$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,"; +$sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; +$sql .= " AND d.statut != -1"; // Not draft $sql .= " GROUP BY d.morphy"; - $foundphy = $foundmor = 0; // Define $data array @@ -85,7 +85,38 @@ if ($resql) { if ($obj->code == 'phy') $foundphy++; if ($obj->code == 'mor') $foundmor++; - $data[] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); + $data[$obj->code] = array('label'=>$obj->code, 'nb'=>$obj->nb, 'nbsubscriptions'=>$obj->nbsubscriptions, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); + + $i++; + } + $db->free($resql); +} else { + dol_print_error($db); +} + +$sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions,"; +$sql .= " MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate,"; +$sql .= " d.morphy as code"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; +$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; +$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) +$sql .= " GROUP BY d.morphy"; +$foundphy = $foundmor = 0; + +// Define $data array +dol_syslog("Count member still active", LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($obj->code == 'phy') $foundphy++; + if ($obj->code == 'mor') $foundmor++; + + $data[$obj->code]['nbactive'] = $obj->nb; $i++; } @@ -114,18 +145,26 @@ print '
'.$langs->trans("Nature").''.$langs->trans("MemberNature").''.$langs->trans("NbOfMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'; print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; print ''; -if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); -if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); +if (!$foundphy) $data[] = array('label'=>'phy', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); +if (!$foundmor) $data[] = array('label'=>'mor', 'nb'=>'0', 'nbactive'=>'0', 'lastdate'=>'', 'lastsubscriptiondate'=>''); foreach ($data as $val) { + $nb = $val['nb']; + $nbsubscriptions = $val['nbsubscriptions']; + $nbactive = $val['nbactive']; + print ''; print ''; - print ''; + print ''; + print ''; print ''; + print ''; print ''; print ''; } diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index ae88b924ea6..aa574e970ca 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -74,12 +74,12 @@ if ($mode) { $tab = 'statscountry'; $data = array(); - $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut = 1"; + $sql .= " AND d.statut != -1"; $sql .= " GROUP BY c.label, c.code"; //print $sql; } @@ -90,14 +90,14 @@ if ($mode) { $tab = 'statsstate'; $data = array(); - $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut = 1"; + $sql .= " AND d.statut != -1"; $sql .= " GROUP BY co.label, co.code, c.nom"; //print $sql; } @@ -107,14 +107,14 @@ if ($mode) { $tab = 'statsregion'; //onglet $data = array(); //tableau de donnée - $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut = 1"; + $sql .= " AND d.statut != -1"; $sql .= " GROUP BY co.label, co.code, r.nom"; //+ //print $sql; } @@ -124,12 +124,12 @@ if ($mode) { $tab = 'statstown'; $data = array(); - $sql .= "SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut = 1"; + $sql .= " AND d.statut != -1"; $sql .= " GROUP BY c.label, c.code, d.town"; //print $sql; } diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 2f126b11fdf..a48a584c5c1 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -168,6 +168,7 @@ MembersStatisticsByState=Members statistics by state/province MembersStatisticsByTown=Members statistics by town MembersStatisticsByRegion=Members statistics by region NbOfMembers=Number of members +NbOfActiveMembers=Number of still active members NoValidatedMemberYet=No validated members found MembersByCountryDesc=This screen show you statistics on members by countries. Graphic depends however on Google online graph service and is available only if an internet connection is is working. MembersByStateDesc=This screen show you statistics on members by state/provinces/canton. From dd06ff3a0d15b5803bd3585edcb77299a7cb877f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 03:41:18 +0200 Subject: [PATCH 166/173] Label --- htdocs/adherents/stats/byproperties.php | 2 +- htdocs/adherents/stats/geo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index d64fbdfa35d..90187e483dc 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -144,7 +144,7 @@ if (!count($data)) { print '
'.$langs->trans("MemberNature").''.$langs->trans("NbOfMembers").''.$langs->trans("NbOfActiveMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("NbOfSubscriptions").''.$langs->trans("LatestSubscriptionDate").'
'.$memberstatic->getmorphylib($val['label']).''.$val['nb'].''.$nb.''.$nbactive.''.dol_print_date($val['lastdate'], 'dayhour').''.$nbsubscriptions.''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index aa574e970ca..bfdaed1094e 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -278,7 +278,7 @@ if ($mode) { print ''; print ''; if ($label2) print ''; - print ''; + print ''; print ''; print ''; print ''; From 7ca9fd9dce5f06cef4fed8527f31a6b21df277bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 03:49:31 +0200 Subject: [PATCH 167/173] Fix merge --- htdocs/core/tpl/objectline_title.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 375992be60d..1154dd61834 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -59,7 +59,7 @@ if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' } // VAT -print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); @@ -298,7 +298,7 @@ foreach ($moduleList as $module) { $idperms .= ($idperms ? ", " : "").$permission; $translationKey = "Permission".$permission; - if (! empty($conf->global->MAIN_SHOW_PERMISSION)) { + if (!empty($conf->global->MAIN_SHOW_PERMISSION)) { if (empty($langs->tab_translate[$translationKey])) { $tooltip = 'Missing translation (key '.$translationkey.' not found in admin.lang)'; $idperms .= ' Warning'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 43fcfd98d8d..dc82c0cfaa4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1995,7 +1995,7 @@ class ActionComm extends CommonObject $formmail = new FormMail($this->db); $actionCommReminder = new ActionCommReminder($this->db); - while ($obj = $this->db->fetch_object($resql)){ + while ($obj = $this->db->fetch_object($resql)) { $res = $actionCommReminder->fetch($obj->id); if ($res < 0) { $error++; @@ -2055,7 +2055,7 @@ class ActionComm extends CommonObject { $errorsMsg[] = "Failed to update status of ActionComm Reminder"; $error++; - break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. + break; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first. } else { $nbMailSend++; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 75f9457b45f..f62c00ee81b 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -475,16 +475,16 @@ class Orders extends DolibarrApi */ public function getContacts($id, $type = '') { - if (! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -556,16 +556,16 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index e7fc86ba8ee..cfecfecffa5 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -134,18 +134,18 @@ $fieldstosearchall = array( // Definition of fields for lists $arrayfields = array( - 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), - 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), - 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), - 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), - 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), - 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), - 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), - 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), - 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), - 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)), - 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), - 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), + 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), + 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), + 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), + 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), + 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), + 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), + 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), + 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)), + 'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)), + 'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)), + 'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500), + 'credit' =>array('label'=>"Credit", 'checked'=>1, 'position'=>510), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -168,13 +168,13 @@ if (empty($reshook)) { */ $form = new Form($db); -if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); -if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); +if ($arrayfields['account']['checked'] || $arrayfields['subledger']['checked']) $formaccounting = new FormAccounting($db); +if ($arrayfields['bank']['checked'] && !empty($conf->accounting->enabled)) $accountingjournal = new AccountingJournal($db); if ($arrayfields['ref']['checked']) $variousstatic = new PaymentVarious($db); if ($arrayfields['bank']['checked']) $accountstatic = new Account($db); -if ($arrayfields['project']['checked']) $proj = new Project($db); -if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); -if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db); +if ($arrayfields['project']['checked']) $proj = new Project($db); +if ($arrayfields['entry']['checked']) $bankline = new AccountLine($db); +if ($arrayfields['account']['checked']) $accountingaccount = new AccountingAccount($db); $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.subledger_account, v.fk_projet as fk_project,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index fe8ca7d42d3..1828493d89f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -28,96 +28,96 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class Invoices extends DolibarrApi { - /** - * - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid', - ); + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid', + ); - /** - * @var Facture $invoice {@type Facture} - */ - public $invoice; + /** + * @var Facture $invoice {@type Facture} + */ + public $invoice; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->invoice = new Facture($this->db); - } - - /** - * Get properties of a invoice object - * - * Return an array with invoice informations - * - * @param int $id ID of invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id, $contact_list = 1) + /** + * Constructor + */ + public function __construct() { - return $this->_fetch($id, '', '', $contact_list); + global $db, $conf; + $this->db = $db; + $this->invoice = new Facture($this->db); } - /** - * Get properties of an invoice object by ref - * - * Return an array with invoice informations - * - * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref/{ref} - * - * @throws RestException - */ - public function getByRef($ref, $contact_list = 1) - { - return $this->_fetch('', $ref, '', $contact_list); - } + /** + * Get properties of a invoice object + * + * Return an array with invoice informations + * + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id, $contact_list = 1) + { + return $this->_fetch($id, '', '', $contact_list); + } - /** - * Get properties of an invoice object by ref_ext - * - * Return an array with invoice informations - * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @url GET ref_ext/{ref_ext} - * - * @throws RestException - */ - public function getByRefExt($ref_ext, $contact_list = 1) - { - return $this->_fetch('', '', $ref_ext, $contact_list); - } + /** + * Get properties of an invoice object by ref + * + * Return an array with invoice informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', $contact_list); + } - /** - * Get properties of an invoice object - * - * Return an array with invoice informations - * - * @param int $id ID of order + /** + * Get properties of an invoice object by ref_ext + * + * Return an array with invoice informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, $contact_list); + } + + /** + * Get properties of an invoice object + * + * Return an array with invoice informations + * + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information - * - * @throws RestException - */ - private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) - { + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) + { if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } @@ -142,138 +142,138 @@ class Invoices extends DolibarrApi $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); - } + } - /** - * List invoices - * - * Get a list of invoices - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of invoice objects - * + /** + * List invoices + * + * Get a list of invoices + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of invoice objects + * * @throws RestException 404 Not found * @throws RestException 503 Error - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') - { - global $db, $conf; + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= " FROM ".MAIN_DB_PREFIX."facture as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= ' WHERE t.entity IN ('.getEntity('invoice').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= ' WHERE t.entity IN ('.getEntity('invoice').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Filter by status - if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + if ($status == 'draft') $sql .= " AND t.fk_statut IN (0)"; + if ($status == 'unpaid') $sql .= " AND t.fk_statut IN (1)"; + if ($status == 'paid') $sql .= " AND t.fk_statut IN (2)"; + if ($status == 'cancelled') $sql .= " AND t.fk_statut IN (3)"; + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $db->order($sortfield, $sortorder); - if ($limit) - { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $db->order($sortfield, $sortorder); + if ($limit) + { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $db->plimit($limit + 1, $offset); - } + $sql .= $db->plimit($limit + 1, $offset); + } - $result = $db->query($sql); - if ($result) - { - $i = 0; - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $db->fetch_object($result); - $invoice_static = new Facture($db); - if ($invoice_static->fetch($obj->rowid)) - { - // Get payment details - $invoice_static->totalpaid = $invoice_static->getSommePaiement(); - $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); - $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); - $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $invoice_static = new Facture($db); + if ($invoice_static->fetch($obj->rowid)) + { + // Get payment details + $invoice_static->totalpaid = $invoice_static->getSommePaiement(); + $invoice_static->totalcreditnotes = $invoice_static->getSumCreditNotesUsed(); + $invoice_static->totaldeposits = $invoice_static->getSumDepositsUsed(); + $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - $obj_ret[] = $this->_cleanObjectDatas($invoice_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No invoice found'); - } + $obj_ret[] = $this->_cleanObjectDatas($invoice_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No invoice found'); + } return $obj_ret; - } + } - /** - * Create invoice object - * - * @param array $request_data Request datas - * @return int ID of invoice - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + /** + * Create invoice object + * + * @param array $request_data Request datas + * @return int ID of invoice + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->invoice->$field = $value; - } - if (!array_key_exists('date', $request_data)) { - $this->invoice->date = dol_now(); - } - /* We keep lines as an array + foreach ($request_data as $field => $value) { + $this->invoice->$field = $value; + } + if (!array_key_exists('date', $request_data)) { + $this->invoice->date = dol_now(); + } + /* We keep lines as an array if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { @@ -282,154 +282,154 @@ class Invoices extends DolibarrApi $this->invoice->lines = $lines; }*/ - if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { - throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); - } - return $this->invoice->id; - } + if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { + throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); + } + return $this->invoice->id; + } - /** - * Create an invoice using an existing order. - * - * - * @param int $orderid Id of the order - * - * @url POST /createfromorder/{orderid} - * - * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function createInvoiceFromOrder($orderid) - { + /** + * Create an invoice using an existing order. + * + * + * @param int $orderid Id of the order + * + * @url POST /createfromorder/{orderid} + * + * @return int + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function createInvoiceFromOrder($orderid) + { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - if (!DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($orderid)) { - throw new RestException(400, 'Order ID is mandatory'); - } + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($orderid)) { + throw new RestException(400, 'Order ID is mandatory'); + } - $order = new Commande($this->db); - $result = $order->fetch($orderid); - if (!$result) { - throw new RestException(404, 'Order not found'); - } + $order = new Commande($this->db); + $result = $order->fetch($orderid); + if (!$result) { + throw new RestException(404, 'Order not found'); + } - $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(405, $this->invoice->error); - } - $this->invoice->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->invoice); - } + $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(405, $this->invoice->error); + } + $this->invoice->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Get lines of an invoice - * - * @param int $id Id of invoice - * - * @url GET {id}/lines - * - * @return int - */ - public function getLines($id) - { - if (!DolibarrApiAccess::$user->rights->facture->lire) { - throw new RestException(401); - } + /** + * Get lines of an invoice + * + * @param int $id Id of invoice + * + * @url GET {id}/lines + * + * @return int + */ + public function getLines($id) + { + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->invoice->getLinesArray(); - $result = array(); - foreach ($this->invoice->lines as $line) { - array_push($result, $this->_cleanObjectDatas($line)); - } - return $result; - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->invoice->getLinesArray(); + $result = array(); + foreach ($this->invoice->lines as $line) { + array_push($result, $this->_cleanObjectDatas($line)); + } + return $result; + } - /** - * Update a line to a given invoice - * - * @param int $id Id of invoice to update - * @param int $lineid Id of line to update - * @param array $request_data InvoiceLine data - * - * @url PUT {id}/lines/{lineid} - * - * @return array - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 Invoice not found - */ - public function putLine($id, $lineid, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + /** + * Update a line to a given invoice + * + * @param int $id Id of invoice to update + * @param int $lineid Id of line to update + * @param array $request_data InvoiceLine data + * + * @url PUT {id}/lines/{lineid} + * + * @return array + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 Invoice not found + */ + public function putLine($id, $lineid, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->invoice->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->date_start, - $request_data->date_end, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - 'HT', - $request_data->info_bits, - $request_data->product_type, - $request_data->fk_parent_line, - 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->special_code, - $request_data->array_options, - $request_data->situation_percent, - $request_data->fk_unit, - $request_data->multicurrency_subprice, - 0, - $request_data->ref_ext - ); + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->invoice->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->date_start, + $request_data->date_end, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->situation_percent, + $request_data->fk_unit, + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } else { - throw new RestException(304, $this->invoice->error); - } - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } else { + throw new RestException(304, $this->invoice->error); + } + } - /** + /** * Add a contact type of given invoice * * @param int $id Id of invoice to update @@ -440,39 +440,39 @@ class Invoices extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 + * @throws RestException 401 + * @throws RestException 404 */ - public function postContact($id, $contactid, $type) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + public function postContact($id, $contactid, $type) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); + $result = $this->invoice->fetch($id); if (!$result) { throw new RestException(404, 'Invoice not found'); } - if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { - throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); - } + if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { + throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); + } - if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->add_contact($contactid, $type, 'external'); + $result = $this->invoice->add_contact($contactid, $type, 'external'); - if (!$result) { - throw new RestException(500, 'Error when added the contact'); - } + if (!$result) { + throw new RestException(500, 'Error when added the contact'); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** + /** * Delete a contact type of given invoice * * @param int $id Id of invoice to update diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d47caa3b92a..5110b1194e5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5160,15 +5160,15 @@ class FactureLigne extends CommonInvoiceLine $this->db->begin(); - // Update line in database - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql .= " description='".$this->db->escape($this->desc)."'"; - $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", subprice=".price2num($this->subprice).""; - $sql .= ", remise_percent=".price2num($this->remise_percent).""; - if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; - else $sql .= ", fk_remise_except=null"; + // Update line in database + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; + $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= ", ref_ext='".$this->db->escape($this->ref_ext)."'"; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", subprice=".price2num($this->subprice).""; + $sql .= ", remise_percent=".price2num($this->remise_percent).""; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".$this->fk_remise_except; + else $sql .= ", fk_remise_except=null"; $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->db->escape($this->vat_src_code))."'"; $sql .= ", tva_tx=".price2num($this->tva_tx).""; $sql .= ", localtax1_tx=".price2num($this->localtax1_tx).""; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f08516812be..ddf811cfc77 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1231,7 +1231,7 @@ class ExtraFields } else { if (!$notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - $labeltoshow =$translabel; + $labeltoshow = $translabel; } if (empty($labeltoshow)) $labeltoshow = '(not defined)'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9b450925a42..3350507e543 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7993,18 +7993,18 @@ class Form include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); + $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs); if ($default) $TModels[0] = $langs->trans('DefaultMailModel'); if ($result > 0) { - foreach ($formmail->lines_model as $model){ + foreach ($formmail->lines_model as $model) { $TModels[$model->id] = $model->label; } } $retstring .= ''; - print ''; // Destinataires @@ -987,7 +987,7 @@ class FormTicket } // MESSAGE - $defaultmessage=""; + $defaultmessage = ""; if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; } diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ea84e5ab76e..4d949f4f7d8 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -709,7 +709,7 @@ class Menubase $tabMenu[$b]['mainmenu'] = $menu['mainmenu']; $tabMenu[$b]['leftmenu'] = $menu['leftmenu']; $tabMenu[$b]['perms'] = $perms; - $tabMenu[$b]['langs'] = $menu['langs']; // Note that this should not be used, lang file should be already loaded. + $tabMenu[$b]['langs'] = $menu['langs']; // Note that this should not be used, lang file should be already loaded. $tabMenu[$b]['enabled'] = $enabled; $tabMenu[$b]['type'] = $menu['type']; $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 57941a4fb2d..fe684d2100e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6187,15 +6187,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; if ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = dol_print_date($object->array_options['options_' . $key], 'day'); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = dol_print_date($object->array_options['options_' . $key], 'day', 'tzserver', $outputlangs); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = dol_print_date($object->array_options['options_' . $key], 'dayrfc'); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = dol_print_date($object->array_options['options_'.$key], 'day'); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = dol_print_date($object->array_options['options_'.$key], 'day', 'tzserver', $outputlangs); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = dol_print_date($object->array_options['options_'.$key], 'dayrfc'); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour') : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhour', 'tzserver', $outputlangs) : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_DAY_LOCALE__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'day', 'tzserver', $outputlangs) : ''); + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_RFC__'] = ($datetime != "0000-00-00 00:00:00" ? dol_print_date($datetime, 'dayhourrfc') : ''); } } } diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 1d391846339..e6fd6d04091 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -42,12 +42,12 @@ class pdf_standard extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - public function addSticker(&$pdf, $outputlangs, $param) - { + public function addSticker(&$pdf, $outputlangs, $param) + { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - __LOGO__ is replace with company logo @@ -65,7 +65,7 @@ class pdf_standard extends CommonStickerGenerator */ public function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') { - // phpcs:enable + // phpcs:enable global $db, $mysoc, $conf, $langs; global $forceimgscalewidth, $forceimgscaleheight; @@ -229,7 +229,7 @@ class pdf_standard extends CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP stream. * @@ -311,14 +311,14 @@ class pdf_standard extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } $this->type = 'pdf'; - // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; - } else { - //custom - $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); - $this->format = $resolution; - } + // standard format or custom + if ($this->Tformat['paper-size'] != 'custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -339,13 +339,13 @@ class pdf_standard extends CommonStickerGenerator $filename = 'tmp_cards.pdf'; if (is_object($object)) { - $outputdir = $conf->adherent->dir_output; - $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); - $file = $dir.'/'.$filename; + $outputdir = $conf->adherent->dir_output; + $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); + $file = $dir.'/'.$filename; } else { - $outputdir = $conf->adherent->dir_temp; - $dir = $outputdir; - $file = $dir.'/'.$filename; + $outputdir = $conf->adherent->dir_temp; + $dir = $outputdir; + $file = $dir.'/'.$filename; } //var_dump($file);exit; @@ -416,22 +416,22 @@ class pdf_standard extends CommonStickerGenerator // Output to http stream if (empty($nooutput)) { - clearstatcache(); + clearstatcache(); - $attachment = true; - if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; - $type = dol_mimetype($filename); + $attachment = true; + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; + $type = dol_mimetype($filename); - //if ($encoding) header('Content-Encoding: '.$encoding); - if ($type) header('Content-Type: '.$type); - if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); - else header('Content-Disposition: inline; filename="'.$filename.'"'); + //if ($encoding) header('Content-Encoding: '.$encoding); + if ($type) header('Content-Type: '.$type); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); - // Ajout directives pour resoudre bug IE - header('Cache-Control: Public, must-revalidate'); - header('Pragma: public'); + // Ajout directives pour resoudre bug IE + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); - readfile($file); + readfile($file); } return 1; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index a8a7a674ed7..386bedad910 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -791,16 +791,16 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg2 = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } } - if (empty($object->actionmsg)) { + if (empty($object->actionmsg)) { $langs->loadLangs(array("agenda", "other")); if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key $object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } else { // generic translation key $tmp = explode('_', $action); - $object->actionmsg = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities($tmp[count($tmp) - 1]."InDolibarr", ($object->newref ? $object->newref : $object->ref)); } } @@ -843,7 +843,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $projectid = isset($object->fk_project) ? $object->fk_project : 0; if ($object->element == 'project') $projectid = $object->id; - $elementid = $object->id; // id of object + $elementid = $object->id; // id of object $elementtype = $object->element; $elementmodule = $object->module; if ($object->element == 'subscription') diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php index 91606babb84..721febdd13c 100644 --- a/htdocs/debugbar/class/autoloader.php +++ b/htdocs/debugbar/class/autoloader.php @@ -4,7 +4,7 @@ * Simple autoloader, so we don't need Composer just for this. */ -spl_autoload_register(function ($class) { +spl_autoload_register(function($class) { if (preg_match('/^DebugBar/', $class)) { $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; //var_dump($class.' - '.file_exists($file).' - '.$file); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index be53ebefaeb..4b84a97fde0 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -299,8 +299,8 @@ class EmailCollector extends CommonObject // Load source object $object->fetchCommon($fromid); - $object->fetchFilters(); // Rules - $object->fetchActions(); // Operations + $object->fetchFilters(); // Rules + $object->fetchActions(); // Operations // Reset some properties unset($object->id); @@ -979,7 +979,7 @@ class EmailCollector extends CommonObject { if (empty($rule['status'])) continue; - if ($rule['type'] == 'to') { + if ($rule['type'] == 'to') { $tmprulevaluearray = explode('*', $rule['rulevalue']); if (count($tmprulevaluearray) >= 2) { foreach ($tmprulevaluearray as $tmprulevalue) { @@ -1163,7 +1163,7 @@ class EmailCollector extends CommonObject if (!empty($headers['References']) && preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } @@ -1171,7 +1171,7 @@ class EmailCollector extends CommonObject if (empty($headers['In-Reply-To'])) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } // Note: we can have // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) @@ -1182,7 +1182,7 @@ class EmailCollector extends CommonObject if (!$isanswer) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } if ($searchfilterisnotanswer > 0) { @@ -1196,7 +1196,7 @@ class EmailCollector extends CommonObject //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; if ($isanswer) { $nbemailprocessed++; - continue; // Exclude email + continue; // Exclude email } } } @@ -1702,7 +1702,7 @@ class EmailCollector extends CommonObject if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementid = $fk_element_id; + $actioncomm->elementid = $fk_element_id; $actioncomm->elementtype = $fk_element_type; if (is_object($objectemail) && $objectemail->module) { $actioncomm->elementtype .= '@'.$objectemail->module; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 4f41c7cf734..00171264ddb 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -454,7 +454,7 @@ class SupplierInvoices extends DolibarrApi $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = $payment_mode_id; $paiement->paiementcode = dol_getIdFromCode($this->db, $payment_mode_id, 'c_paiement', 'id', 'code', 1); - $paiement->oper = $paiement->paiementcode; // For backward compatibility + $paiement->oper = $paiement->paiementcode; // For backward compatibility $paiement->num_payment = $num_payment; $paiement->note_public = $comment; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b824796155e..f94cadbca9c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -696,13 +696,13 @@ class FactureFournisseur extends CommonInvoice $this->author = $obj->fk_user_author; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_facture_source = $obj->fk_facture_source; - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; $this->fk_account = $obj->fk_account; - $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; $this->date_echeance = $this->db->jdate($obj->date_lim_reglement); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 6d412ae6f0a..961011b51e0 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -354,13 +354,13 @@ class Stripe extends CommonObject // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; - $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; - $sql.= " WHERE pi.fk_facture = " . $object->id; - $sql.= " AND pi.sourcetype = '" . $object->element . "'"; - $sql.= " AND pi.entity IN (".getEntity('societe').")"; - $sql.= " AND pi.ext_payment_site = '" . $service . "'"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pi"; + $sql .= " WHERE pi.fk_facture = ".$object->id; + $sql .= " AND pi.sourcetype = '".$object->element."'"; + $sql .= " AND pi.entity IN (".getEntity('societe').")"; + $sql .= " AND pi.ext_payment_site = '".$service."'"; - dol_syslog(get_class($this) . "::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); + dol_syslog(get_class($this)."::getPaymentIntent search stripe payment intent for object id = ".$object->id, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -369,7 +369,7 @@ class Stripe extends CommonObject $obj = $this->db->fetch_object($resql); $intent = $obj->ext_payment_id; - dol_syslog(get_class($this) . "::getPaymentIntent found existing payment intent record"); + dol_syslog(get_class($this)."::getPaymentIntent found existing payment intent record"); // Force to use the correct API key global $stripearrayofkeysbyenv; @@ -403,8 +403,8 @@ class Stripe extends CommonObject // list of payment method types $paymentmethodtypes = array("card"); - if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) - if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_IDEAL)) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) $dataforintent = array( "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 2e2f6f46f73..fcf1013d982 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -312,10 +312,10 @@ if (empty($reshook)) { if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?track_id=' . $object->track_id; + $url = 'card.php?track_id='.$object->track_id; } - header('Location: ' . $url); + header('Location: '.$url); exit(); } } @@ -657,10 +657,10 @@ if ($action == 'create' || $action == 'presend') $head = ticket_prepare_head($object); - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); @@ -668,28 +668,28 @@ if ($action == 'create' || $action == 'presend') print '
'.$langs->trans("MemberNature").''.$langs->trans("NbOfMembers").''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("NbOfActiveMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("NbOfSubscriptions").'
'.$label.''.$label2.''.$langs->trans("NbOfMembers").''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
' +print ''; if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FACTURE_LOCAL_TAX2_OPTION)) { print $langs->trans('Taxes'); } else { From b20be7074e4e370d39b960b657452329905ed3c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 04:08:11 +0200 Subject: [PATCH 168/173] phpcs --- htdocs/adherents/stats/geo.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index bfdaed1094e..edb37a9d4a8 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -208,8 +208,7 @@ if ($mode && !count($data)) { elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ - else - { + else { print ''.$langs->trans("MembersStatisticsDesc").'
'; print '
'; print ''.$langs->trans("MembersStatisticsByCountries").'
'; From 814f07d316c254eac32df23e5d4b6fc800433343 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 04:11:12 +0200 Subject: [PATCH 169/173] Missing picto property --- htdocs/livraison/class/livraison.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 9910855f463..c612dbf6fe2 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -59,6 +59,11 @@ class Livraison extends CommonObject */ public $table_element_line = "livraisondet"; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'sending'; + public $brouillon; public $socid; public $ref_customer; @@ -716,7 +721,6 @@ class Livraison extends CommonObject global $langs; $result = ''; - $picto = 'sending'; $label = img_picto('', $this->picto).' '.$langs->trans("ShowReceiving").':
'; $label .= ''.$langs->trans("Status").': '.$this->ref; @@ -735,7 +739,7 @@ class Livraison extends CommonObject $linkstart = ''; $linkend = ''; - if ($withpicto) $result .= ($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($linkstart.img_object($label, $this->picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; $result .= $linkstart.$this->ref.$linkend; return $result; From c0ef7e8f137032939df25c82867826665d479708 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 04:23:14 +0200 Subject: [PATCH 170/173] fix phpcs --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f94a5ac3154..b4dac8475c0 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1223,7 +1223,7 @@ class ProductCombinationLevel $productCombinationLevel->fk_price_level = $fkPriceLevel; $productCombinationLevel->fk_product_attribute_combination = $productCombination->id; $productCombinationLevel->variation_price = $productCombination->variation_price; - $productCombinationLevel->variation_price_percentage = $productCombination->variation_price_percentage; + $productCombinationLevel->variation_price_percentage = (bool) $productCombination->variation_price_percentage; return $productCombinationLevel; } From 22edd650d3612cfda93a2a82870cd9940452bc72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 04:24:35 +0200 Subject: [PATCH 171/173] Fix phpcs --- htdocs/compta/bank/various_payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 70963e29f6d..e7fc86ba8ee 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -101,7 +101,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $typeid = ''; } -$search_all = GETPOSTISSET("search_all") ? trim(GETPOSTISSET("search_all", 'alpha')) : trim(GETPOST('sall')); +$search_all = GETPOSTISSET("search_all") ? trim(GETPOST("search_all", 'alpha')) : trim(GETPOST('sall')); /* * TODO: fill array "$fields" in "/compta/bank/class/paymentvarious.class.php" and use From 73915d51c841d3d3befd5b1f83bdbd9e9d05a98f Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 14 Sep 2020 02:30:04 +0000 Subject: [PATCH 172/173] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/accountancy/admin/index.php | 4 +- htdocs/admin/system/modules.php | 24 +- htdocs/comm/action/class/actioncomm.class.php | 4 +- htdocs/commande/class/api_orders.class.php | 12 +- htdocs/compta/bank/various_payment/list.php | 34 +- .../facture/class/api_invoices.class.php | 686 +++++++++--------- htdocs/compta/facture/class/facture.class.php | 18 +- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/class/html.form.class.php | 6 +- htdocs/core/class/html.formticket.class.php | 4 +- htdocs/core/class/menubase.class.php | 2 +- htdocs/core/lib/functions.lib.php | 14 +- .../modules/member/doc/pdf_standard.class.php | 62 +- ...terface_50_modAgenda_ActionsAuto.class.php | 8 +- htdocs/debugbar/class/autoloader.php | 2 +- .../class/emailcollector.class.php | 16 +- .../class/api_supplier_invoices.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 6 +- htdocs/stripe/class/stripe.class.php | 18 +- htdocs/ticket/card.php | 28 +- 20 files changed, 476 insertions(+), 476 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3c98c59c0c6..f37ff79a1fa 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -385,8 +385,8 @@ foreach ($list_binding as $key) if ($key == 'ACCOUNTING_DATE_START_BINDING') { print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { - $array=array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); - print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER)?$conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER:0)); + $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); } else { print ''; } diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 34b89e911f6..cdaa8974e24 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -32,13 +32,13 @@ if (!$user->admin) { // Load translation files required by the page $langs->loadLangs(array("install", "other", "admin")); -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'moduleoverview'; $search_name = GETPOST("search_name", 'alpha'); -$search_id = GETPOST("search_id", 'alpha'); -$search_version = GETPOST("search_version", 'alpha'); -$search_permission = GETPOST("search_permission", 'alpha'); +$search_id = GETPOST("search_id", 'alpha'); +$search_version = GETPOST("search_version", 'alpha'); +$search_permission = GETPOST("search_permission", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -126,9 +126,9 @@ foreach ($modulesdir as $dir) { foreach ($modules as $key=>$module) { $newModule = new stdClass(); - $newModule->name = $module->getName(); - $newModule->version = $module->getVersion(); - $newModule->id = $key; + $newModule->name = $module->getName(); + $newModule->version = $module->getVersion(); + $newModule->id = $key; $alt = $module->name.' - '.$modules_files[$key]; @@ -260,13 +260,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print '
'; // Type - print ''; // Severity - print ''; // Group - print ''; // Subject - print ''; // Other attributes $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -701,9 +701,9 @@ if ($action == 'create' || $action == 'presend') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -1250,7 +1250,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action = } if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { - print ''; + print ''; } // Close ticket if statut is read From 3de5e0f9573edcdbf758ac6548e8a736d4131682 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 14 Sep 2020 02:30:37 +0000 Subject: [PATCH 173/173] Fixing style errors. --- htdocs/admin/system/modules.php | 8 ++++---- htdocs/debugbar/class/autoloader.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index cdaa8974e24..c909084f1d6 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -260,13 +260,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php index 721febdd13c..91606babb84 100644 --- a/htdocs/debugbar/class/autoloader.php +++ b/htdocs/debugbar/class/autoloader.php @@ -4,7 +4,7 @@ * Simple autoloader, so we don't need Composer just for this. */ -spl_autoload_register(function($class) { +spl_autoload_register(function ($class) { if (preg_match('/^DebugBar/', $class)) { $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; //var_dump($class.' - '.file_exists($file).' - '.$file);
'; + print '
'; $formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); print '
'; + print '
'; $formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); print '
'; + print '
'; $formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); print '
'; - print ''; + print '
'; + print ''; print '