diff --git a/.travis.yml b/.travis.yml index d660f89e79d..9539d08b231 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,7 @@ php: - '7.0' - '7.1' - '7.2' +- '7.3' - nightly env: @@ -59,6 +60,7 @@ matrix: fast_finish: true allow_failures: - php: nightly + - php: '7.3' # We exclude some combinations not usefull to save Travis CPU exclude: - php: '5.5' @@ -77,6 +79,8 @@ matrix: env: DB=postgresql - php: '7.1' env: DB=postgresql + - php: '7.3' + env: DB=postgresql - php: nightly env: DB=postgresql @@ -130,7 +134,7 @@ install: if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then composer -n require phpunit/phpunit ^5 fi - if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer -n require phpunit/phpunit ^5 fi echo @@ -165,13 +169,9 @@ before_script: echo "Set timezone" echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then - #echo - #echo "Enabling APC for PHP <= 5.4" - # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! - #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! echo echo "Enabling Memcached for PHP <= 5.4" - # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini fi phpenv rehash @@ -211,8 +211,14 @@ before_script: mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql fi if [ "$DB" = 'postgresql' ]; then - #pgloader mysql://root:pass@127.0.0.1/dolibarr_35 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev + #pgloader mysql://root:pass@127.0.0.1/dolibarr_9 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev + echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis pgloader mysql://root@127.0.0.1/travis postgresql:///travis + echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis + echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis + #echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis + #echo 'select * from information_schema.table_constraints;' | psql travis + #echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis fi # TODO: SQLite echo @@ -229,9 +235,11 @@ before_script: echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_port=\'3306\'';' >> $CONF_FILE fi if [ "$DB" = 'postgresql' ]; then echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_port=\'5432\'';' >> $CONF_FILE fi # TODO: SQLite echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE @@ -253,7 +261,7 @@ before_script: # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf fi @@ -276,11 +284,12 @@ before_script: script: - | echo "Checking webserver availability by a wget -O - http://127.0.0.1" - # Ensure we catch errors - set -e + # Ensure we stop on error with set -e + set +e # The wget should return a page with line ' wget -O - http://127.0.0.1 > test.html head test.html + sudo cat /var/log/apache2/travis_error_log set +e echo @@ -309,7 +318,7 @@ script: - | echo "Upgrading Dolibarr" - # Ensure we catch errors + # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. set +e cd htdocs/install php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log @@ -325,7 +334,7 @@ script: php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log + php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log @@ -334,18 +343,22 @@ script: php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log - php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log - php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log + php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log + # Enable modules not enabled into original dump + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log + echo $? cd - set +e echo #cat /tmp/dolibarr_install.log + cat $TRAVIS_BUILD_DIR/enablemodule.log - | echo "Unit testing" @@ -358,9 +371,10 @@ script: after_script: - | - echo "After script - Output 50 latest lines of dolibarr.log" + echo "After script - Output lines of dolibarr.log" ls $TRAVIS_BUILD_DIR/documents - tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log + sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: - | @@ -369,7 +383,7 @@ after_success: after_failure: - | echo Failure detected, so we show samples of log to help diagnose - # This part of code is executed only if previous commande that fails are enclosed with set +e + # This part of code is executed only if previous command that fails are enclosed with set +e # Upgrade log files for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` do @@ -378,7 +392,7 @@ after_failure: done # Apache log file echo "Debugging informations for file apache error.log" - sudo cat /var/log/apache2/error.log + sudo cat /var/log/apache2/travis_error_log if [ "$DEBUG" = true ]; then # Dolibarr log file echo "Debugging informations for file dolibarr.log (latest 50 lines)" diff --git a/ChangeLog b/ChangeLog index d609b7a347a..39c4d5d6ca8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,10 +36,8 @@ NEW: Add option PDF_DISABLE_MYCOMPANY_LOGO to disable logo on PDF NEW: add option PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT NEW: Add option to display thirdparty adress in combolist NEW: Add option to swap sender/recipient address on PDF -NEW: Add option to display thirdparty adress in combolist -NEW: Add project on pament of salaries +NEW: Add project on payment of salaries NEW: Add SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME and -NEW: Add somes hooks in bank planned entries NEW: Add supplier ref in item reception page NEW: Advanced permission to ignore price min NEW: Allow to enter a timespent with a numeric value @@ -80,11 +78,13 @@ NEW: tag odt line_product_ref_fourn for supplier doc lines NEW: The binding step in accountancy has a country filter with autocompletion NEW: Top menu is always on screen with MD theme. NEW: Withdraw request massaction can include already partially paid invoices - +NEW: Option "Simplify interface for blind persons" +NEW: Generic cash fence feature (compatible with several POS modules) For developers: NEW: Add lib for multiselect with checkboxes NEW: Add function isValidMXRecord +NEW: Add somes hooks in bank planned entries NEW: Add hook changeRoundingMode in update_price NEW: Add hook formconfirm to contractcard NEW: Add hook for virtual stock @@ -121,6 +121,71 @@ Following changes may create regressions for some external modules, but were nec * Remove the no more used and deprecated dol_print_graph function +***** ChangeLog for 8.0.4 compared to 8.0.3 ***** +FIX: #10030 better german chart +FIX: #10036 +FIX: #10080 Supplier translations are in english +FIX: #10183 using backport of fix done in 9.0 +FIX: #10218 Bad redirection after deleting a user or group +FIX: #3234 +FIX: #6580 +FIX: #8741 +FIX: #9629 #9625 +FIX: #9971 +FIX: avoid Class 'AdherentType' not found +FIX: Can relaunch install on v8 +FIX: Can't create a thirdparty from member if customer code is mandatory. +FIX: Can't delete a line of minimal stock per warehouse +FIX: check if "entity" is already defined in "$param" +FIX: contact/address tab issue when changing company +FIX: contact/adress tab: when changing company ajax combo, the first contact change is not taken into account +FIX: CVE-2018-19799 +FIX: CVE-2018-19992 +FIX: CVE-2018-19993 +FIX: CVE-2018-19994 +FIX: CVE-2018-19995 and CVE-2018-19998 +FIX: Error reported when creation of thirdparty from member fails +FIX: export only prices of the current entity ! +FIX: Extrafields on shipment module +FIX: filter on product category doesn't work +FIX: form actions: select_type_actions could be too small + bad $db init +FIX: form actions: select_type_actions could be too small + bad init +FIX: fourn payment modes musn't be available on customer docs +FIX: Function updatePrice with wrong parameters +FIX: hidden extrafield +FIX: if qty is 0 +FIX: If we change customer/supplier rule we can't edit old thirdparty. +FIX: lang not loaded +FIX: Lines are not inserted correctly if VAT have code +FIX: marge sign +FIX: Method setValid not found +FIX: Migration do not create not used table +FIX: missing action "edit" for the hook +FIX: missing field "visible" +FIX: Missing last month on vat report per month +FIX: mode is only customer in stats fichinter +FIX: OppStatusShort doesn't exists +FIX: Remote ip detection was wrong with proxy (example: cloudflare) +FIX: Removed not use table +FIX: Replenishment with option STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE +FIX: responsive +FIX: Same on customer card +FIX: same on lines +FIX: screen size fall +FIX: Select first mail model by default +FIX: slow SQL query on creating a new supplier invoice +FIX: sql query performance on list_qualified_avoir_supplier_invoices. +FIX: supplier order list keep socid +FIX: Same on customer card +FIX: same on lines +FIX: screen size fall +FIX: Select first mail model by default +FIX: slow SQL query on creating a new supplier invoice +FIX: sql query performance on list_qualified_avoir_supplier_invoices. +FIX: supplier order list keep socid +FIX: Vendor translations are in english +FIX: Warning: count() +FIX: We want to be able to send PDF of paid invoices ***** ChangeLog for 8.0.3 compared to 8.0.2 ***** FIX: #9161 @@ -459,6 +524,38 @@ Following changes may create regressions for some external modules, but were nec where {TYPE} is contact type code (BILLING, SHIPPING, CUSTOMER, ... see contact type dictionnary). +***** ChangeLog for 7.0.5 compared to 7.0.4 ***** +FIX: #3234 +FIX: #6580 +FIX: #8741 +FIX: #9934 +FIX: avoid Class 'AdherentType' not found +FIX: Can't create a thirdparty from member if customer code is mandatory. +FIX: Can't generate invoice pdf +FIX: contact/adress tab: when changing company ajax combo, the first contact change is not taken into account +FIX: Error generating ODT when option to use contact on doc on +FIX: Error reported when creation of thirdparty from member fails +FIX: filter on product category doesn't work +FIX: form actions: select_type_actions could be too small + bad init +FIX: fourn payment modes musn't be available on customer docs +FIX: Function updatePrice with wrong parameters +FIX: If we change customer/supplier rule we can't edit old thirdparty. +FIX: Interface regression for bind people. Fix option MAIN_OPTIMIZEFORTEXTBROWSER +FIX: Lines are not inserted correctly if VAT have code +FIX: OppStatusShort doesn't exists +FIX: pdf typhon: order reference duplicate +FIX: propal pdf: missing parenthesis for customs code +FIX: Same on customer card +FIX: same on lines +FIX: Select first mail model by default +FIX: sql query performance on list_qualified_avoir_supplier_invoices. +FIX: task time screen: last fix was overkill +FIX: task time screen: prevent users with access to all project from assigning to tasks they're not allowed to do +FIX: use discount with multicurrency +FIX: Variable name +FIX: We want to be able to send PDF of paid invoices +FIX: When delete a product, llx_product_association rows are not deleted +FIX: wrong occurence number of contract on contact card, we must only count externals ***** ChangeLog for 7.0.4 compared to 7.0.3 ***** FIX: #8984 button create expense report diff --git a/README.md b/README.md index c38d0ca7dd1..bcff409035f 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) -|6|7|8|develop| -|----------|----------|----------|----------| -|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/6.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/7.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/8.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)| +|6|7|8|9|develop| +|----------|----------|----------|----------|----------| +|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/6.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/7.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/8.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/9.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)| Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). diff --git a/build/README b/build/README index 4816be8bc3a..27ddf4178fd 100644 --- a/build/README +++ b/build/README @@ -16,18 +16,20 @@ Note: Prerequisites to build tgz, debian, rpm package > apt-get install tar dpkg dpatch p7zip-full rpm zip Note: Prerequisites to build autoexe DoliWamp package: +> apt-get install wine q4wine +> 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.2e-php5.4.3-httpd-2.4.2-mysql5.5.24-x64.exe (http://www.wampserver.com) -> Install WampServer addon to have versions: Apache2.2.11, Mysql5.0.45, Php5.3.0 - For example by running WampServer2-APACHE2211.exe (http://www.wampserver.com) + 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) - For example by running WampServer2-PHP530.exe (http://www.wampserver.com) > 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 a theme package, launch the script > perl makepack-dolibarrtheme.pl @@ -46,9 +48,6 @@ generated packages will not contains this "build" directory. We can find in "build", following sub-directories: -* aps: -To build APS package. - * debian: To build Debian package. diff --git a/build/exe/doliwamp/README b/build/exe/doliwamp/README index 3cbd8986700..9d4c68daf3d 100644 --- a/build/exe/doliwamp/README +++ b/build/exe/doliwamp/README @@ -5,4 +5,4 @@ DOLIWAMP Package tools This directory contains files used by makepack-dolibarr.pl script to build the all-in-on .EXE package DoliWamp, ready -to be distributedt (for Windows). \ No newline at end of file +to be distributed (for Windows). \ No newline at end of file diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index cc6a39a62a4..587f2584dbe 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -32,7 +32,7 @@ AppPublisherURL=https://www.nltechno.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares. -AppCopyright=Copyright (C) 2008-2018 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2019 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index d78ba1e717d..14f28a71edc 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -36,7 +36,7 @@ $PUBLISHBETARC="dolibarr\@vmprod1.dolibarr.org:/home/dolibarr/dolibarr.org/httpd "RPM_FEDORA"=>"rpmbuild", "RPM_MANDRIVA"=>"rpmbuild", "RPM_OPENSUSE"=>"rpmbuild", -"DEB"=>"dpkg", +"DEB"=>"dpkg dpatch", "FLATPACK"=>"flatpack", "EXEDOLIWAMP"=>"ISCC.exe", "SNAPSHOT"=>"tar" @@ -589,6 +589,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Examples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/unitTests`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/dav/tests`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/LICENSE`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; @@ -1057,7 +1058,7 @@ if ($nboftargetok) { $ret=`cat "$SOURCE/build/exe/doliwamp/doliwamp.iss" | sed -e 's/__FILENAMEEXEDOLIWAMP__/$FILENAMEEXEDOLIWAMP/g' > "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"`; print "Compil exe $FILENAMEEXEDOLIWAMP.exe file from iss file \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\"\n"; - $cmd= "ISCC.exe \"Z:$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\""; + $cmd= "wine ISCC.exe \"Z:$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\""; print "$cmd\n"; $ret= `$cmd`; #print "$ret\n"; diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index f1770a692c0..477d129d459 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -43,9 +43,9 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol - Run makepack-dolibarr.pl to generate all packages. - Check content of built packages. -- Move build files into www.dolibarr.org web site - (/home/dolibarr/wwwroot/files/stable). +- Run makepack-dolibarr.pl again with option to publish files on + dolibarr foundation server (Dir /home/dolibarr/wwwroot/files/stable on www.dolibarr.org). - Run makepack-dolibarr.pl again with option to publish files on sourceforge. This will also add official tag. - Edit symbolic links in directory "/home/dolibarr/wwwroot/files/stable/xxx" diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf index a4965c40d68..60a4095c34a 100644 --- a/build/travis-ci/apache.conf +++ b/build/travis-ci/apache.conf @@ -1,5 +1,6 @@ DocumentRoot %TRAVIS_BUILD_DIR%/htdocs + ErrorLog /var/log/apache2/travis_error_log Options FollowSymLinks MultiViews ExecCGI diff --git a/dev/initdemo/mysqldump_dolibarr_9.0.0.sql b/dev/initdemo/mysqldump_dolibarr_9.0.0.sql index fc2be863791..c2fc6e39c9f 100644 --- a/dev/initdemo/mysqldump_dolibarr_9.0.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_9.0.0.sql @@ -4242,100 +4242,6 @@ INSERT INTO `llx_c_ticket_type` VALUES (1,1,'COM','10','Commercial question',1,1 /*!40000 ALTER TABLE `llx_c_ticket_type` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `llx_c_ticketsup_category` --- - -DROP TABLE IF EXISTS `llx_c_ticketsup_category`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_c_ticketsup_category` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `code` varchar(32) NOT NULL, - `pos` varchar(32) NOT NULL, - `label` varchar(128) NOT NULL, - `active` int(11) DEFAULT '1', - `use_default` int(11) DEFAULT '1', - `description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_code` (`code`,`entity`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_c_ticketsup_category` --- - -LOCK TABLES `llx_c_ticketsup_category` WRITE; -/*!40000 ALTER TABLE `llx_c_ticketsup_category` DISABLE KEYS */; -INSERT INTO `llx_c_ticketsup_category` VALUES (1,1,'OTHER','10','Other',1,1,NULL); -/*!40000 ALTER TABLE `llx_c_ticketsup_category` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_c_ticketsup_severity` --- - -DROP TABLE IF EXISTS `llx_c_ticketsup_severity`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_c_ticketsup_severity` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `code` varchar(32) NOT NULL, - `pos` varchar(32) NOT NULL, - `label` varchar(128) NOT NULL, - `color` varchar(10) NOT NULL, - `active` int(11) DEFAULT '1', - `use_default` int(11) DEFAULT '1', - `description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_code` (`code`,`entity`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_c_ticketsup_severity` --- - -LOCK TABLES `llx_c_ticketsup_severity` WRITE; -/*!40000 ALTER TABLE `llx_c_ticketsup_severity` DISABLE KEYS */; -INSERT INTO `llx_c_ticketsup_severity` VALUES (1,1,'LOW','10','Low','',1,0,NULL),(2,1,'NORMAL','20','Normal','',1,1,NULL),(3,1,'HIGH','30','High','',1,0,NULL),(4,1,'BLOCKING','40','Critical / blocking','',1,0,NULL); -/*!40000 ALTER TABLE `llx_c_ticketsup_severity` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_c_ticketsup_type` --- - -DROP TABLE IF EXISTS `llx_c_ticketsup_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_c_ticketsup_type` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `code` varchar(32) NOT NULL, - `pos` varchar(32) NOT NULL, - `label` varchar(128) NOT NULL, - `active` int(11) DEFAULT '1', - `use_default` int(11) DEFAULT '1', - `description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_code` (`code`,`entity`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_c_ticketsup_type` --- - -LOCK TABLES `llx_c_ticketsup_type` WRITE; -/*!40000 ALTER TABLE `llx_c_ticketsup_type` DISABLE KEYS */; -INSERT INTO `llx_c_ticketsup_type` VALUES (1,1,'COM','10','Commercial question',1,1,NULL),(2,1,'ISSUE','20','Issue or problem',1,0,NULL),(3,1,'REQUEST','25','Change or enhancement request',1,0,NULL),(4,1,'PROJECT','30','Project',1,0,NULL),(5,1,'OTHER','40','Other',1,0,NULL); -/*!40000 ALTER TABLE `llx_c_ticketsup_type` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `llx_c_tva` -- @@ -13005,36 +12911,6 @@ INSERT INTO `llx_ticket_extrafields` VALUES (1,'2018-06-04 19:36:42',1,NULL,NULL /*!40000 ALTER TABLE `llx_ticket_extrafields` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `llx_ticket_logs` --- - -DROP TABLE IF EXISTS `llx_ticket_logs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_ticket_logs` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `fk_track_id` varchar(128) DEFAULT NULL, - `fk_user_create` int(11) DEFAULT NULL, - `datec` datetime DEFAULT NULL, - `message` text, - PRIMARY KEY (`rowid`), - KEY `fk_ticket_logs_fk_track_id` (`fk_track_id`), - CONSTRAINT `fk_ticket_logs_fk_track_id` FOREIGN KEY (`fk_track_id`) REFERENCES `llx_ticket` (`track_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_ticket_logs` --- - -LOCK TABLES `llx_ticket_logs` WRITE; -/*!40000 ALTER TABLE `llx_ticket_logs` DISABLE KEYS */; -INSERT INTO `llx_ticket_logs` VALUES (1,1,'d42iybp7p6d1cvqi',12,'2018-10-01 03:20:18','Ticket read by Alice Adminson'); -/*!40000 ALTER TABLE `llx_ticket_logs` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `llx_ticket_msg` -- @@ -13066,143 +12942,6 @@ INSERT INTO `llx_ticket_msg` VALUES (1,1,'d42iybp7p6d1cvqi',12,'2018-10-01 03:18 /*!40000 ALTER TABLE `llx_ticket_msg` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `llx_ticketsup` --- - -DROP TABLE IF EXISTS `llx_ticketsup`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_ticketsup` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `ref` varchar(128) NOT NULL, - `track_id` varchar(128) NOT NULL, - `fk_soc` int(11) DEFAULT '0', - `fk_project` int(11) DEFAULT '0', - `origin_email` varchar(128) DEFAULT NULL, - `fk_user_create` int(11) DEFAULT NULL, - `fk_user_assign` int(11) DEFAULT NULL, - `subject` varchar(255) DEFAULT NULL, - `message` text, - `fk_statut` int(11) DEFAULT NULL, - `resolution` int(11) DEFAULT NULL, - `progress` varchar(100) DEFAULT NULL, - `timing` varchar(20) DEFAULT NULL, - `type_code` varchar(32) DEFAULT NULL, - `category_code` varchar(32) DEFAULT NULL, - `severity_code` varchar(32) DEFAULT NULL, - `datec` datetime DEFAULT NULL, - `date_read` datetime DEFAULT NULL, - `date_close` datetime DEFAULT NULL, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `notify_tiers_at_create` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`), - UNIQUE KEY `uk_ticketsup_track_id` (`track_id`), - KEY `id_ticketsup_track_id` (`track_id`) -) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_ticketsup` --- - -LOCK TABLES `llx_ticketsup` WRITE; -/*!40000 ALTER TABLE `llx_ticketsup` DISABLE KEYS */; -INSERT INTO `llx_ticketsup` VALUES (16,1,'TS1803-0001','bmhki5neaa7bszvy',64,12,NULL,12,11,'hfghfgbvcbcv','hgfhfghf
\r\ngdgdgdhghfghf',3,NULL,'100','NORMAL','COM','OTHER','NORMAL','2018-03-13 15:19:47','2018-03-18 21:55:12','2018-04-10 18:00:15','2018-05-01 10:32:20',1),(17,1,'TS1803-0002','ltvd8zthmu5b7v42',148,NULL,NULL,12,NULL,'hfghf','jghjhg',6,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-03-16 13:30:33','2018-03-18 22:00:39',NULL,'2018-03-18 18:27:03',1),(20,1,'TS1803-0005','o9997psaapahwrxi',NULL,NULL,NULL,12,NULL,'khjkhj','mmmmm',1,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-03-18 22:55:56','2018-03-19 14:57:36',NULL,'2018-03-19 10:57:36',0),(21,1,'TS1803-0006','hh2ludsvj32lp8sq',NULL,NULL,NULL,12,NULL,'gdfg','gdfgfd',0,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-03-18 22:56:20',NULL,NULL,'2018-03-18 18:56:20',1),(22,1,'TS1803-0007','4e8iy89hes9a5w8d',NULL,NULL,NULL,12,NULL,'ffffffff','fsdf',0,NULL,'0','NORMAL','COM','OTHER','NORMAL','2018-03-18 23:00:41',NULL,NULL,'2018-04-12 19:41:47',1),(23,1,'TS1804-0008','jbm8vxsqw19817fm',79,NULL,'aaa@aaa.com',NULL,NULL,'ssss','mmm',0,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-04-12 23:20:40',NULL,NULL,'2018-04-12 21:20:40',1),(24,1,'TS1804-0009','q32naisayppjgr5b',NULL,NULL,'f@f.com',NULL,NULL,'sss','mmm',0,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-04-12 23:23:34',NULL,NULL,'2018-04-12 21:23:34',1),(25,1,'TS1804-0010','dst5xryjb55jjxs6',NULL,NULL,'f@f.com',NULL,NULL,'sss','mmm',0,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-04-12 23:31:01',NULL,NULL,'2018-04-12 21:31:01',1),(26,1,'TS1804-0011','qh9ar34ut2shp5rq',151,NULL,'testldr6@dolicloud.com',NULL,NULL,'ppppp','gdgdgdfg',0,NULL,'0',NULL,'COM','OTHER','NORMAL','2018-04-19 15:05:23',NULL,NULL,'2018-04-19 13:05:23',1); -/*!40000 ALTER TABLE `llx_ticketsup` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_ticketsup_extrafields` --- - -DROP TABLE IF EXISTS `llx_ticketsup_extrafields`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_ticketsup_extrafields` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `fk_object` int(11) NOT NULL, - `import_key` varchar(14) DEFAULT NULL, - `aaa` varchar(255) DEFAULT NULL, - `listeonly` varchar(255) DEFAULT NULL, - `bbb` varchar(255) DEFAULT NULL, - PRIMARY KEY (`rowid`) -) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_ticketsup_extrafields` --- - -LOCK TABLES `llx_ticketsup_extrafields` WRITE; -/*!40000 ALTER TABLE `llx_ticketsup_extrafields` DISABLE KEYS */; -INSERT INTO `llx_ticketsup_extrafields` VALUES (15,'2018-04-12 21:20:40',23,NULL,'aaaa',NULL,NULL),(16,'2018-04-12 21:23:34',24,NULL,'aaa',NULL,NULL),(17,'2018-04-12 21:31:01',25,NULL,'aaa',NULL,NULL),(20,'2018-04-13 10:42:15',22,NULL,'fffppgggffooppmmpp',NULL,NULL),(26,'2018-04-19 13:05:23',26,NULL,'aaa',NULL,NULL),(56,'2018-04-30 08:32:50',16,NULL,'ljklj',NULL,NULL); -/*!40000 ALTER TABLE `llx_ticketsup_extrafields` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_ticketsup_logs` --- - -DROP TABLE IF EXISTS `llx_ticketsup_logs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_ticketsup_logs` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `fk_track_id` varchar(128) DEFAULT NULL, - `fk_user_create` int(11) DEFAULT NULL, - `datec` datetime DEFAULT NULL, - `message` text, - PRIMARY KEY (`rowid`), - KEY `fk_ticketsup_logs_fk_track_id` (`fk_track_id`), - CONSTRAINT `fk_ticketsup_logs_fk_track_id` FOREIGN KEY (`fk_track_id`) REFERENCES `llx_ticketsup` (`track_id`) -) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_ticketsup_logs` --- - -LOCK TABLES `llx_ticketsup_logs` WRITE; -/*!40000 ALTER TABLE `llx_ticketsup_logs` DISABLE KEYS */; -INSERT INTO `llx_ticketsup_logs` VALUES (14,1,'bmhki5neaa7bszvy',12,'2018-03-16 13:31:15','Change classification : from Other to Other'),(15,1,'bmhki5neaa7bszvy',12,'2018-03-16 13:31:22','Change classification : from Commercial question to Issue or problem'),(16,1,'bmhki5neaa7bszvy',12,'2018-03-18 14:59:27','Ticket assigned to David Doe'),(17,1,'bmhki5neaa7bszvy',12,'2018-03-18 14:59:36','Ticket assigned to hgfhfg hgfh'),(18,1,'bmhki5neaa7bszvy',12,'2018-03-18 14:59:47','Ticket assigned to Sam Scientol'),(19,1,'bmhki5neaa7bszvy',12,'2018-03-18 15:01:20','Ticket assigned to Zack Zeceo'),(20,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:30:49','Ticket read by Alice Adminson'),(22,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:37:42','Status changed : Read to Not read'),(23,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:37:55','Ticket read by Alice Adminson'),(24,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:38:03','Status changed : Read to Not read'),(25,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:38:25','Ticket read by Alice Adminson'),(26,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:38:29','Status changed : Read to Not read'),(27,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:38:45','Ticket read by Alice Adminson'),(28,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:43:30','Status changed : Read to Not read'),(29,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:19','Status changed : Not read to Read'),(30,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:21','Status changed : Read to Not read'),(31,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:25','Ticket read by Alice Adminson'),(32,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:29','Status changed : Read to Not read'),(33,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:31','Status changed : Not read to Read'),(34,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:44:40','Status changed : Read to Not read'),(35,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:48:06','Ticket read by Alice Adminson'),(36,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:48:10','Status changed : Read to Not read'),(37,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:55:06','Ticket read by Alice Adminson'),(38,1,'bmhki5neaa7bszvy',12,'2018-03-18 21:55:12','Ticket read by Alice Adminson'),(39,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:00:39','Ticket read by Alice Adminson'),(40,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:25:01','Status changed : Answered to Assigned'),(41,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:25:08','Status changed : Assigned to Answered'),(42,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:25:16','Status changed : Answered to In progress'),(43,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:27:03','Status changed : In progress to Waiting'),(44,1,'o9997psaapahwrxi',12,'2018-03-19 14:57:35','Ticket read by Alice Adminson'),(45,1,'o9997psaapahwrxi',12,'2018-03-19 14:57:36','Ticket read by Alice Adminson'),(46,1,'bmhki5neaa7bszvy',12,'2018-04-10 17:58:28','Status changed : Lu to En cours'),(47,1,'bmhki5neaa7bszvy',12,'2018-04-10 17:58:44','Ticket clôt par Alice Adminson'),(48,1,'bmhki5neaa7bszvy',12,'2018-04-10 18:00:15','Ticket clôt par Alice Adminson'),(49,1,'bmhki5neaa7bszvy',12,'2018-04-13 12:11:32','Ticket ré-ouvert'),(50,1,'bmhki5neaa7bszvy',12,'2018-04-15 11:45:53','Status changed : assigné to Unread'),(51,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:01:24','Change classification : from to '),(52,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:01:26','Change classification : from to '),(53,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:02:03','Change classification : from to '),(54,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:02:27','Change classification : from to '),(55,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:09:03','Change classification : from to '),(56,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:09:34','Change classification : from to '),(57,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:15:04','Change classification : from to '),(58,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:15:54','Change classification : from to '),(59,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:17:47','Change classification : from to '),(60,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:18:04','Change classification : from to '),(61,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:18:28','Change classification : from to '),(62,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:18:39','Change classification : from to '),(63,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:19:00','Change classification : from to '),(64,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:19:06','Change classification : from to '),(65,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:19:09','Change classification : from to '),(66,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:19:13','Change classification : from to '),(67,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:24:52','Change classification : from to '),(68,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:24:58','Change classification : from to '),(69,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:26:41','Change classification : from to '),(70,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:27:03','Change classification : from to '),(71,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:27:06','Change classification : from to '),(72,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:27:30','Initial message modified \n hgfhfghf\n+ gdgdgd\n'),(73,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:28:13','Initial message modified \n hgfhfghf\n gdgdgd\n'),(74,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:28:28','Initial message modified \n hgfhfghf\n gdgdgd\n'),(75,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:28:47','Initial message modified \n hgfhfghf\n gdgdgd\n'),(76,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:28:55','Initial message modified \n hgfhfghf\n- gdgdgd\n+ gdgdgdhghfghf\n'),(77,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:28:58','Change classification : from to '),(78,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:29:55','Change classification : from to '),(79,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:32:42','Change classification : from to '),(80,1,'bmhki5neaa7bszvy',12,'2018-04-30 10:32:50','Change classification : from to '),(81,1,'bmhki5neaa7bszvy',12,'2018-05-01 12:32:20','Status changed : Unread to Answered'); -/*!40000 ALTER TABLE `llx_ticketsup_logs` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `llx_ticketsup_msg` --- - -DROP TABLE IF EXISTS `llx_ticketsup_msg`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_ticketsup_msg` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `entity` int(11) DEFAULT '1', - `fk_track_id` varchar(128) DEFAULT NULL, - `fk_user_action` int(11) DEFAULT NULL, - `datec` datetime DEFAULT NULL, - `message` text, - `private` int(11) DEFAULT '0', - PRIMARY KEY (`rowid`), - KEY `fk_ticketsup_msg_fk_track_id` (`fk_track_id`), - CONSTRAINT `fk_ticketsup_msg_fk_track_id` FOREIGN KEY (`fk_track_id`) REFERENCES `llx_ticketsup` (`track_id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `llx_ticketsup_msg` --- - -LOCK TABLES `llx_ticketsup_msg` WRITE; -/*!40000 ALTER TABLE `llx_ticketsup_msg` DISABLE KEYS */; -INSERT INTO `llx_ticketsup_msg` VALUES (1,1,'bmhki5neaa7bszvy',12,'2018-03-16 13:30:57','gdfd',0),(2,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:24:18','fdsfds',0),(3,1,'ltvd8zthmu5b7v42',12,'2018-03-18 22:24:39','hfghfg',0); -/*!40000 ALTER TABLE `llx_ticketsup_msg` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `llx_tva` -- diff --git a/dev/initdemo/savedemo.sh b/dev/initdemo/savedemo.sh index e94169ff155..1e051b4cded 100755 --- a/dev/initdemo/savedemo.sh +++ b/dev/initdemo/savedemo.sh @@ -191,6 +191,9 @@ export list=" --ignore-table=$base.llx_c_dolicloud_plans --ignore-table=$base.llx_c_pays --ignore-table=$base.llx_c_source + --ignore-table=$base.llx_c_ticketsup_category + --ignore-table=$base.llx_c_ticketsup_severity + --ignore-table=$base.llx_c_ticketsup_type --ignore-table=$base.llx_cabinetmed_c_banques --ignore-table=$base.llx_cabinetmed_c_ccam --ignore-table=$base.llx_cabinetmed_c_examconclusion @@ -248,6 +251,8 @@ export list=" --ignore-table=$base.llx_residence --ignore-table=$base.llx_residence_building --ignore-table=$base.llx_residence_building_links + --ignore-table=$base.llx_societe_rib2 + --ignore-table=$base.llx_ticketsup --ignore-table=$base.llx_ultimatepdf --ignore-table=$base.llx_update_modules --ignore-table=$base.llx_ventilation_achat diff --git a/dev/resources/dbmodel/dolibarr.uml b/dev/resources/dbmodel/dolibarr.uml deleted file mode 100644 index 57078d6668b..00000000000 --- a/dev/resources/dbmodel/dolibarr.uml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/dev/resources/dbmodel/dolibarr.umldi b/dev/resources/dbmodel/dolibarr.umldi deleted file mode 100644 index ff97a2a25b1..00000000000 --- a/dev/resources/dbmodel/dolibarr.umldi +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/resources/dbmodel/dolibarr_schema.mwb b/dev/resources/dbmodel/dolibarr_schema.mwb index aec0f2d2299..27bc4ab2403 100644 Binary files a/dev/resources/dbmodel/dolibarr_schema.mwb and b/dev/resources/dbmodel/dolibarr_schema.mwb differ diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 67bf58e51ed..879d791b8e9 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -50,7 +50,22 @@ 0 - + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + '; + echo $option; + } + } + } + else { + echo ''; + echo $morelogincontent; + } +} +?> +   diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index 53209d735c4..c7bbfa329c2 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -45,8 +45,7 @@ $societe = new Societe($db); $societe->fetch($thirdpartyid); /** end add Ditto */ -$tab=array(); -$tab = $_SESSION['poscart']; +$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); $tab_size=count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 22648189f99..8ced2826155 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -432,8 +432,8 @@ if ($action == 'update') foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); $object->contactid = GETPOST("contactid",'int'); $object->fk_project = GETPOST("projectid",'int'); - $object->note = GETPOST("note"); - $object->pnote = GETPOST("note"); + $object->note = GETPOST("note","none"); // deprecated + $object->note_private= GETPOST("note","none"); $object->fk_element = GETPOST("fk_element"); $object->elementtype = GETPOST("elementtype"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index aef77513e7b..2d0ba61fff9 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -490,8 +490,6 @@ class ActionComm extends CommonObject { global $db, $user, $langs, $conf, $hookmanager; - $this->context['createfromclone']='createfromclone'; - $error=0; $now=dol_now(); @@ -524,7 +522,8 @@ class ActionComm extends CommonObject } // Create clone - $result=$this->create($fuser); + $this->context['createfromclone']='createfromclone'; + $result=$this->create($fuser); if ($result < 0) $error++; if (! $error) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 57337226f40..3e8d5d4ee99 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -241,8 +241,15 @@ $sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; $sql.= " c.code as type_code, c.libelle as type_label,"; $sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_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."actioncomm as a"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -314,9 +321,15 @@ if ($filtert > 0 || $usergroup > 0) if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))"; if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; + // 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 +$sql.=$hookmanager->resPrint; + $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 9cd85e4ad36..3ac0ab2822b 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -327,7 +327,7 @@ if ($object->id > 0) print ''; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id',1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { @@ -346,7 +346,7 @@ if ($object->id > 0) print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_id,'mode_reglement_id', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 57d6adc1ba9..cc920e3d124 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -329,14 +329,16 @@ if ($object->fetch($id) >= 0) // Si le module mailing est qualifie if ($qualified) { + $var = ! $var; + if ($allowaddtarget) { - print '
'; + print ''; print ''; } else { - print '
'; + print '
'; } print '
'; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 11708c3b4ca..b807ea23334 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -279,8 +279,6 @@ class Mailing extends CommonObject $object=new Mailing($this->db); - $object->context['createfromclone']='createfromclone'; - $this->db->begin(); // Load source object @@ -314,6 +312,7 @@ class Mailing extends CommonObject } // Create clone + $object->context['createfromclone']='createfromclone'; $result=$object->create($user); // Other options @@ -345,7 +344,6 @@ class Mailing extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles "; $sql.= " WHERE fk_mailing = ".$fromid; - dol_syslog(get_class($this)."::createFromClone", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0bd4bb3d0d7..ed1c5c627ee 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2105,7 +2105,7 @@ if ($action == 'create') print ''; print ''; if (! empty($object->brouillon) && $action == 'editmode' && $usercancreate) { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 196d6f50451..511fb2087ec 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1222,31 +1222,30 @@ class Propal extends CommonObject dol_include_once('/projet/class/project.class.php'); - $this->context['createfromclone']='createfromclone'; - $error=0; $now=dol_now(); + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + $this->db->begin(); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals(); - - // Load dest object - $clonedObj = clone $this; + // Load source object + $object->fetch($this->id); + $object->fetch_lines(); $objsoc=new Societe($this->db); // Change socid if needed - if (! empty($socid) && $socid != $clonedObj->socid) + if (! empty($socid) && $socid != $object->socid) { if ($objsoc->fetch($socid) > 0) { - $clonedObj->socid = $objsoc->id; - $clonedObj->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $clonedObj->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $clonedObj->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_delivery_address = ''; /*if (!empty($conf->projet->enabled)) { @@ -1258,44 +1257,51 @@ class Propal extends CommonObject $clonedObj->fk_project = ''; } }*/ - $clonedObj->fk_project = ''; // A cloned proposal is set by default to no project. + $object->fk_project = ''; // A cloned proposal is set by default to no project. } // reset ref_client - $clonedObj->ref_client = ''; + $object->ref_client = ''; // TODO Change product price if multi-prices } else { - $objsoc->fetch($clonedObj->socid); + $objsoc->fetch($object->socid); } - $clonedObj->id=0; - $clonedObj->ref=''; - $clonedObj->statut=self::STATUS_DRAFT; + $object->id=0; + $object->ref=''; + $object->statut=self::STATUS_DRAFT; // Clear fields - $clonedObj->user_author = $user->id; - $clonedObj->user_valid = ''; - $clonedObj->date = $now; - $clonedObj->datep = $now; // deprecated - $clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600); - if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; + $object->user_author = $user->id; + $object->user_valid = ''; + $object->date = $now; + $object->datep = $now; // deprecated + $object->fin_validite = $object->date + ($object->duree_validite * 24 * 3600); + if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $object->ref_client = ''; // Create clone - $result=$clonedObj->create($user); + $object->context['createfromclone']='createfromclone'; + $result=$object->create($user); if ($result < 0) $error++; - else + + if (! $error) { // copy internal contacts - if ($clonedObj->copy_linked_contact($this, 'internal') < 0) + if ($object->copy_linked_contact($this, 'internal') < 0) + { $error++; + } + } + if (! $error) + { // copy external contacts if same company - elseif ($this->socid == $clonedObj->socid) + if ($this->socid == $object->socid) { - if ($clonedObj->copy_linked_contact($this, 'external') < 0) + if ($object->copy_linked_contact($this, 'external') < 0) $error++; } } @@ -1312,13 +1318,13 @@ class Propal extends CommonObject } } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) { $this->db->commit(); - return $clonedObj->id; + return $object->id; } else { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 98ff1c45194..f87a73b5288 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array('companies','propal','compta','bills','orders','products','deliveries')); +$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); $socid=GETPOST('socid','int'); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 978bc5aa04a..547b3803f7f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2191,7 +2191,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5b3f8006345..d8aed383905 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1066,8 +1066,6 @@ class Commande extends CommonOrder $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get lines so they will be clone @@ -1108,6 +1106,7 @@ class Commande extends CommonOrder $this->ref_client = ''; // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7cb6b09fbaf..88f3cae0a21 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1471,7 +1471,7 @@ class Account extends CommonObject { $country_code=$this->getCountryCode(); - if (in_array($country_code,array('CH','FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... + if (in_array($country_code,array('FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH if (in_array($country_code,array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... return 0; } diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 9efdf3932ff..dc9c1d242e8 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -280,8 +280,6 @@ class BankCateg // extends CommonObject $object = new BankCateg($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -290,6 +288,7 @@ class BankCateg // extends CommonObject $object->statut = 0; // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 4b9f55f025f..dd734bf3316 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -341,16 +341,26 @@ if ($result) { if ($key) print '
'; if ($links[$key]['type']=='payment') { - print ''; + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paymenttmp=new Paiement($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('ShowPayment'),'payment').' '; print $langs->trans("Payment"); - print ''; + print '';*/ + print $paymenttmp->getNomUrl(1); } else if ($links[$key]['type']=='payment_supplier') { - print ''; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + $paymenttmp=new PaiementFourn($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('ShowPayment'),'payment').' '; print $langs->trans("Payment"); - print ''; + print '';*/ + print $paymenttmp->getNomUrl(1); } else if ($links[$key]['type']=='company') { $societe=new Societe($db); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index ef471aea693..3d9ba5e376d 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -115,11 +115,10 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''.$langs->trans("ThirdParty").''; print ''.$langs->trans("Debit").''; print ''.$langs->trans("Credit").''; - print ''.$langs->trans("BankBalance").''; + print ''.$langs->trans("BankBalance").''; print ''; // Current balance - print ''; print ''.$langs->trans("CurrentBalance").''; print ''.price($solde).''; @@ -133,7 +132,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Remainder to pay in future - $sqls = array(); + $sqls = array(); // Customer invoices $sql = "SELECT 'invoice' as family, f.rowid as objid, f.facnumber as ref, f.total_ttc, f.type, f.date_lim_reglement as dlr,"; @@ -142,9 +141,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Supplier invoices $sql = " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; @@ -153,51 +152,51 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql.= " WHERE ff.entity = ".$conf->entity; $sql.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice - $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sql.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql.= " ORDER BY dlr ASC"; + $sqls[] = $sql; // Social contributions $sql = " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; - $sql.= ", cs.fk_account"; + $sql.= ", cs.fk_account"; $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql.= " WHERE cs.entity = ".$conf->entity; $sql.= " AND cs.paye = 0"; // Not paid - $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql.= " ORDER BY dlr ASC"; - $sqls[] = $sql; + $sqls[] = $sql; - // others sql - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook) and isset($hookmanager->resArray['sql'])){ - $sqls[] = $hookmanager->resArray['sql']; - } + // others sql + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook) and isset($hookmanager->resArray['sql'])){ + $sqls[] = $hookmanager->resArray['sql']; + } $error=0; $tab_sqlobjOrder=array(); $tab_sqlobj=array(); - foreach($sqls as $sql){ - $resql = $db->query($sql); - if($resql){ - while($sqlobj = $db->fetch_object($resql)){ - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); - } - $db->free($resql); - }else{ - $error++; - } - } + foreach($sqls as $sql){ + $resql = $db->query($sql); + if($resql){ + while($sqlobj = $db->fetch_object($resql)){ + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); + } + $db->free($resql); + }else{ + $error++; + } + } // Sort array if (! $error) { array_multisort($tab_sqlobjOrder,$tab_sqlobj); - //Apply distinct filter + // Apply distinct filter foreach ($tab_sqlobj as $key=>$value) { $tab_sqlobj[$key] = "'" . serialize($value) . "'"; } @@ -262,13 +261,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $paiement = -1*$socialcontribstatic->getSommePaiement(); // Payment already done } - $parameters = array('obj' => $obj); - $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if(empty($reshook)){ - $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; - $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; - $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; - } + $parameters = array('obj' => $obj); + $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if(empty($reshook)){ + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + } $total_ttc = $obj->total_ttc; if ($paiement) $total_ttc = $obj->total_ttc - $paiement; @@ -307,7 +306,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } - // solde + // solde print ''; print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.')'; print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php new file mode 100644 index 00000000000..314a4641f12 --- /dev/null +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -0,0 +1,575 @@ + + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Charles-Fr BENKE + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Andreu Bisquerra + * + * 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/compta/cashcontrol/cashcontrol_card.php + * \ingroup cashdesk|takepos + * \brief Page to show a cash fence + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; + +$langs->loadLangs(array("install","cashdesk","admin","banks")); + +$id=GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action=GETPOST('action','aZ09'); +$categid = GETPOST('categid'); +$label = GETPOST("label"); + +$now=dol_now(); +$syear = (GETPOSTISSET('closeyear')?GETPOST('closeyear', 'int'):dol_print_date($now, "%Y")); +$smonth = (GETPOSTISSET('closemonth')?GETPOST('closemonth', 'int'):dol_print_date($now, "%m")); +$sday = (GETPOSTISSET('closeday')?GETPOST('closeday', 'int'):dol_print_date($now, "%d")); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='rowid'; +if (! $sortorder) $sortorder='ASC'; + +// Security check +if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use) +{ + accessforbidden(); +} + +$arrayofpaymentmode=array('cash'=>'Cash', 'cheque'=>'Cheque', 'card'=>'CreditCard'); + +$arrayofposavailable=array(); +if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs->trans('CashDesk').' (cashdesk)'; +if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; +// TODO Add hook here to allow other POS to add themself + +$object= new CashControl($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('cashcontrolcard','globalcard')); + + +/* + * Actions + */ + +$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use); +$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); +if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); +$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php',1); +$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record + +if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) +{ + setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors'); +} + + +if (GETPOST('cancel','alpha')) +{ + $action = 'create'; +} + +if ($action=="start") +{ + $error=0; + if (! GETPOST('posmodule','alpha') || GETPOST('posmodule','alpha') == '-1') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Module")), null, 'errors'); + $action='create'; + $error++; + } + if (GETPOST('posnumber','alpha') == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CashDesk")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('closeyear','alpha') || GETPOST('closeyear','alpha') == '-1') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Year")), null, 'errors'); + $action='create'; + $error++; + } +} +elseif ($action=="add") +{ + if (GETPOST('opening','alpha') == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InitialBankBalance")), null, 'errors'); + $action='start'; + $error++; + } + $error=0; + foreach($arrayofpaymentmode as $key=>$val) + { + if (GETPOST($key.'_amount','alpha') == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); + $action='start'; + $error++; + } + else + { + $object->$key = price2num(GETPOST($key.'_amount','alpha')); + } + } + + if (! $error) + { + $object->day_close = GETPOST('closeday', 'int'); + $object->month_close = GETPOST('closemonth', 'int'); + $object->year_close = GETPOST('closeyear', 'int'); + + $object->opening=price2num(GETPOST('opening','alpha')); + $object->posmodule=GETPOST('posmodule','alpha'); + $object->posnumber=GETPOST('posnumber','alpha'); + + $db->begin(); + + $id=$object->create($user); + + if ($id > 0) + { + $db->commit(); + $action="view"; + } + else + { + $db->rollback; + $action="view"; + } + } +} + +if ($action=="close") +{ + $object->fetch($id); + + $result = $object->valid($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + setEventMessages($langs->trans("CashFenceDone"), null); + } + + $action="view"; +} + +// Action to delete +if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +{ + $object->fetch($id); + + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + + $result=$object->delete($user); + var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } +} + + +/* + * View + */ + +$form=new Form($db); + +if ($action=="create" || $action=="start") +{ + llxHeader(); + + $initialbalanceforterminal=array(); + $theoricalamountforterminal=array(); + $theoricalnbofinvoiceforterminal=array(); + + if (GETPOST('posnumber','alpha') != '' && GETPOST('posnumber','alpha') != '' && GETPOST('posnumber','alpha') != '-1') + { + $posmodule = GETPOST('posmodule','alpha'); + $terminalid = GETPOST('posnumber','alpha'); + + // Calculate $initialbalanceforterminal for terminal 0 + foreach($arrayofpaymentmode as $key => $val) + { + if ($key != 'cash') + { + $initialbalanceforterminal[$terminalid][$key] = 0; + continue; + } + + // Get the bank account dedicated to this point of sale module/terminal + $bankid = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) + // Hook to get the good bank id according to posmodule and posnumber. + // @TODO add hook here + + $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account = ".$bankid; + if ($syear && ! $smonth) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql.= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); + + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; + } + else dol_print_error($db); + } + + // Calculate $theoricalamountforterminal for terminal 0 + foreach($arrayofpaymentmode as $key => $val) + { + /*$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account = ".$bankid;*/ + $sql = "SELECT SUM(pf.amount) as total, COUNT(*) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; + $sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; + $sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; + $sql.= " AND f.pos_source = '".$db->escape($terminalid)."'"; + $sql.= " AND f.paye = 1"; + $sql.= " AND p.entity IN (".getEntity('facture').")"; + if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; + elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; + elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; + else + { + dol_print_error('Value for key = '.$key.' not supported'); + exit; + } + if ($syear && ! $smonth) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; + elseif ($syear && $smonth && ! $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); + + $resql = $db->query($sql); + if ($resql) + { + $theoricalamountforterminal[$terminalid][$key] = $initialbalanceforterminal[$terminalid][$key]; + + $obj = $db->fetch_object($resql); + if ($obj) + { + $theoricalamountforterminal[$terminalid][$key] = price2num($theoricalamountforterminal[$terminalid][$key] + $obj->total); + $theoricalnbofinvoiceforterminal[$terminalid][$key] = $obj->nb; + } + } + else dol_print_error($db); + } + } + + print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'title_bank.png'); + + print ''; + if ($action == 'start' && GETPOST('posnumber','int') != '' && GETPOST('posnumber','int') != '' && GETPOST('posnumber','int') != '-1') + { + print ''; + } + else + { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $disabled=0; + $prefix='close'; + + print ''; + print ''; + print ''; + // Year + print ''; + // Month + print ''; + // Day + print ''; + // Button Start + print ''; + print '
'.$langs->trans("Module").''.$langs->trans("CashDesk").' ID'.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule','alpha'), (count($arrayofposavailable)>1?1:0)).''; + $retstring=''; + for ($year = $syear - 10; $year < $syear + 10 ; $year++) + { + $retstring.=''; + } + $retstring.="\n"; + print $retstring; + print ''; + $retstring=''; + $retstring.=''; + for ($month = 1 ; $month <= 12 ; $month++) + { + $retstring.='"; + } + $retstring.=""; + print $retstring; + print ''; + $retstring=''; + $retstring.=''; + for ($day = 1 ; $day <= 31; $day++) + { + $retstring.=''; + } + $retstring.=""; + print $retstring; + print ''; + if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') + { + print ''; + } + else + { + print ''; + } + print '
'; + + if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') + { + $posmodule = GETPOST('posmodule','alpha'); + $terminalid = GETPOST('posnumber','alpha'); + + print '
'; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + $i=0; + foreach($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i=0; + foreach($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i=0; + foreach($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i=0; + foreach($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + } + print ''; +} + +if (empty($action) || $action=="view") +{ + $object->fetch($id); + + llxHeader('', $langs->trans("CashControl")); + + $head=array(); + $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; + $head[0][1] = $langs->trans("Card"); + $head[0][2] = 'cashcontrol'; + + dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'cashcontrol'); + + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + $morehtmlref.='
'; + + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); + + print '
'; + print '
'; + print '
'; + print '
'.$langs->trans("InitialBankBalance"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'; + print $langs->trans("AmountAtEndOfPeriod"); + print '
'.$langs->trans("Cash"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans($val); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
'.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
'; + print '
'; + print price($theoricalamountforterminal[$terminalid][$key]).'
'; + print '
'.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + + print ''; + + print '"; + + print '"; + + print ''; + + print '
'; + print $langs->trans("Ref"); + print ''; + print $id; + print '
'.$langs->trans("Module").''; + print $object->posmodule; + print "
'.$langs->trans("CashDesk").' ID'; + print $object->posnumber; + print "
'; + print $langs->trans("Period"); + print ''; + print $object->year_close."-".$object->month_close."-".$object->day_close; + print '
'; + print '
'; + + print '
'; + print '
'; + print ''; + + print ''; + + print '"; + + foreach($arrayofpaymentmode as $key => $val) + { + print '"; + } + + print "
'; + print $langs->trans("DateCreationShort"); + print ''; + print dol_print_date($object->date_creation, 'dayhour'); + print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; + print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
\n"; + print '
'; + print '
'; + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + if ($object->status == CashControl::STATUS_DRAFT) + { + print ''; + + print ''; + } + print '
'; + + print '
'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php new file mode 100644 index 00000000000..11c14218440 --- /dev/null +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -0,0 +1,573 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 cashcontrol_list.php + * \ingroup cashdesk|takepos + * \brief List page for cashcontrol + */ + +//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 + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("banks","other")); + +$action = GETPOST('action','aZ09')?GETPOST('action','aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cashcontrol'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + +// Initialize technical objects +$object=new CashControl($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('cashcontrol'); // Load $extrafields->attributes['cashcontrol'] +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +//$result = restrictedArea($user, 'monmodule', $id, ''); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); +} +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$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'; + + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='CashControl'; + $objectlabel='CashControl'; + $permtoread = ($user->rights->cashdesk->use || $user->rights->takepos->use); + $permtodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use); + + //$uploaddir = ''; + //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence"; +$help_url=''; +$title = $langs->trans('CashControl'); + + +// 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.', ' : ''); +} +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $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)"; +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 ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// 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, $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('/, $/','', $sql); + */ + +$sql.=$db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $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; + } +} +// 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) +{ + $num = $nbtotalofrecords; +} +else +{ + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/compta/cashcontrol/cashcontrol_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$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) +{ + $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'; + +// List of mass actions available +$arrayofmassactions = array( +//'presend'=>$langs->trans("SendByMail"), +//'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton=''; +//if ($user->rights->monmodule->creer) + //{ +$newcardbutton=''.$langs->trans('New').''; +$newcardbutton.= ''; +$newcardbutton.= ''; +//} + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail="SendCashControlRef"; +$modelmail="cashcontrol"; +$objecttmp=new CashControl($db); +$trackid='xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) +{ + 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, $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=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$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, $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=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\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; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print ''."\n"; + + +// 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) + { + 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 < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $cssforfield=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $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 ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + +$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 '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +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($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\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=$user->rights->monmodule->read; + $delallowed=$user->rights->monmodule->create; + + print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php new file mode 100644 index 00000000000..d0a10ec94da --- /dev/null +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -0,0 +1,429 @@ + + * Copyright (C) 2009 Regis Houssin + * Copyright (C) 2016 Marcos García + * Copyright (C) 2018 Andreu Bisquerra + * + * 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 cashcontrol/class/cashcontrol.class.php + * \ingroup cashdesk|takepos + * \brief This file is CRUD class file (Create/Read/Update/Delete) for cash fence table + */ + +/** + * Class to manage cash fence + */ +class CashControl extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'cashcontrol'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'pos_cash_fence'; + + /** + * @var int Does pos_cash_fence support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does pos_cash_fence support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * @var string String with name of icon for pos_cash_fence. Must be the part after the 'object_' into object_pos_cash_fence.png + */ + public $picto = 'account'; + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18), + 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>19), + 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24), + 'opening' =>array('type'=>'double(24,8)', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25), + 'cash' =>array('type'=>'double(24,8)', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), + 'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33), + 'card' =>array('type'=>'double(24,8)', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36), + 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>50), + 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55), + 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60), + 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated')), + ); + + public $id; + public $opening; + public $status; + public $year_close; + public $month_close; + public $day_close; + public $posmodule; + public $posnumber; + public $cash; + public $cheque; + public $card; + public $date_valid; + public $date_creation; + public $date_modification; + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } + + + /** + * Create in database + * + * @param User $user User that create + * @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) + { + global $conf; + + $error = 0; + + // Clean data + if (empty($this->cash)) $this->cash=0; + if (empty($this->cheque)) $this->cheque=0; + if (empty($this->card)) $this->card=0; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_cash_fence ("; + $sql .= "entity"; + //$sql .= ", ref"; + $sql .= ", opening"; + $sql .= ", status"; + $sql .= ", date_creation"; + $sql .= ", posmodule"; + $sql .= ", posnumber"; + $sql .= ", day_close"; + $sql .= ", month_close"; + $sql .= ", year_close"; + $sql .= ", cash"; + $sql .= ", cheque"; + $sql .= ", card"; + $sql .= ") VALUES ("; + //$sql .= "'(PROV)', "; + $sql .= $conf->entity; + $sql .= ", ".(is_numeric($this->opening) ? $this->opening : 0); + $sql .= ", 0"; // Draft by default + $sql .= ", '".$this->db->idate(dol_now())."'"; + $sql .= ", '".$this->db->escape($this->posmodule)."'"; + $sql .= ", '".$this->db->escape($this->posnumber)."'"; + $sql .= ", ".($this->day_close > 0 ? $this->day_close : "null"); + $sql .= ", ".($this->month_close > 0 ? $this->month_close : "null"); + $sql .= ", ".$this->year_close; + $sql .= ", ".$this->cash; + $sql .= ", ".$this->cheque; + $sql .= ", ".$this->card; + $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) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence"); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'pos_cash_fence SET ref = rowid where rowid = '.$this->id; + $this->db->query($sql); + } + + // 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; + } + } + + /** + * Validate cash fence + * + * @param User $user User + * @param number $notrigger No trigger + * @return int <0 if KO, >0 if OK + */ + public function valid(User $user, $notrigger = 0) + { + global $conf,$langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) + { + dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING); + return 0; + } + + /* + $posmodule = $this->posmodule; + if (! empty($user->rights->$posmodule->use)) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + } + */ + + $now=dol_now(); + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence"; + $sql.= " SET status = ".self::STATUS_VALIDATED.","; + $sql.= " date_valid='".$this->db->idate($now)."',"; + $sql.= " fk_user_valid = ".$user->id; + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::close", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + if (!$error) { + $this->status = self::STATUS_VALIDATED; + $this->date_valid = $now; + $this->fk_user_valid = $user->id; + } + + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('CASHCONTROL_VALIDATE', $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 $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Return label of the 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 of status + */ + public function getLibStatut($mode=0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @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 of status + */ + public function LibStatut($status, $mode=0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelstatus[0] = $langs->trans('Draft'); + $this->labelstatus[1] = $langs->trans('Closed'); + } + + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut6', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut0', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status],'statut6', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status],'statut0', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut6', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut0', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut6', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut0', '', false, 0, 0, '', 'valignmiddle'); + } + } + + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') + * @param int $maxlength Maxlength of ref + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip No tooltip + * @return string String with URL + */ + public function getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1, $notooltip=0) + { + global $conf, $langs, $hookmanager; + include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + + $result=''; + $newref=($this->ref?$this->ref:$this->id); + if ($maxlength) { $newref=dol_trunc($newref, $maxlength, 'middle'); } + + $label = '' . $langs->trans("ShowCashFence") . ''; + $label .= '
' . $langs->trans('ProductRef') . ': ' . ($this->ref?$this->ref:$this->id); + + $linkclose=''; + if (empty($notooltip)) { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label=$langs->trans("ShowCashFence"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + + $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose.= ' class="classfortooltip"'; + + /* + $hookmanager->initHooks(array('productdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + + $url = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id; + + 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'; + } + } + + $linkstart = ''; + $linkend=''; + + $result.=$linkstart; + if ($withpicto) { + $result.=(img_object(($notooltip?'':$label), 'bank', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); + } + $result.= $newref; + $result.= $linkend; + + global $action; + $hookmanager->initHooks(array('cashfencedao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $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; + } + + return $result; + } +} \ No newline at end of file diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php new file mode 100644 index 00000000000..749d112f711 --- /dev/null +++ b/htdocs/compta/cashcontrol/report.php @@ -0,0 +1,286 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2012 Vinícius Nogueira + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2018 Andreu Bisquerra + * + * 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/compta/cashcontrol/report.php + * \ingroup cashdesk|takepos + * \brief List of bank transactions + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +$id = GETPOST('id','int'); + +$_GET['optioncss']="print"; +include_once 'class/cashcontrol.class.php'; +$cashcontrol= new CashControl($db); +$cashcontrol->fetch($id); + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortorder='ASC'; +$sortfield='b.datev,b.dateo,b.rowid'; + +$arrayfields=array( + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), + 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), +); + +$syear = $cashcontrol->year_close; +$smonth = $cashcontrol->month_close; +$sday = $cashcontrol->day_close; + +$posmodule = $cashcontrol->posmodule; +$terminalid = $cashcontrol->posnumber; + + +/* + * View + */ + +llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $param); + +/*$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; +$sql.= " b.fk_account, b.fk_type,"; +$sql.= " ba.rowid as bankid, ba.ref as bankref,"; +$sql.= " bu.url_id,"; +$sql.= " f.module_source, f.facnumber as facnumber"; +$sql.= " FROM "; +//if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +$sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; +$sql.= " ".MAIN_DB_PREFIX."bank as b"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'payment'"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON bu.url_id = f.rowid"; +$sql.= " WHERE b.fk_account = ba.rowid"; +// Define filter on invoice +$sql.= " AND f.module_source = '".$db->escape($cashcontrol->posmodule)."'"; +$sql.= " AND f.pos_source = '".$db->escape($cashcontrol->posnumber)."'"; +$sql.= " AND f.entity IN (".getEntity('facture').")"; +// Define filter on data +if ($syear && ! $smonth) $sql.= " AND dateo BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; +elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; +elseif ($syear && $smonth && $sday) $sql.= " AND dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; +else dol_print_error('', 'Year not defined'); +// Define filter on bank account +$sql.=" AND (b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; +$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CB; +$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; +$sql.=")"; +*/ +$sql = "SELECT f.rowid as facid, f.facnumber, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code"; +$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b"; +$sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid"; +$sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; +$sql.= " AND f.pos_source = '".$db->escape($terminalid)."'"; +$sql.= " AND f.paye = 1"; +$sql.= " AND p.entity IN (".getEntity('facture').")"; +/*if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; +elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; +elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; +else +{ + dol_print_error('Value for key = '.$key.' not supported'); + exit; +}*/ +if ($syear && ! $smonth) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; +elseif ($syear && $smonth && ! $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; +elseif ($syear && $smonth && $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; +else dol_print_error('', 'Year not defined'); + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + print "

"; + if ($cashcontrol->status==2) print $langs->trans("CashControl")." ".$cashcontrol->id; + else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); + print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."

"; + + $invoicetmp = new Facture($db); + + + print "

"; + print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); + print "

"; + + print '
'; + print ''."\n"; + + // Fields title + print ''; + print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($arrayfields['b.debit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($arrayfields['b.credit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder); + print "\n"; + + $posconciliatecol = 0; + + // Loop on each record + $sign = 1; + $cash=$bank=$cheque=$other=0; + + $totalarray=array(); + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($resql); + + if (empty($cachebankaccount[$objp->bankid])) + { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid]=$bankaccounttmp; + $bankaccount = $bankaccounttmp; + } + else + { + $bankaccount = $cachebankaccount[$objp->bankid]; + } + + /*if ($first == "yes") + { + print ''; + print ''; + print ''; + print ''; + $first = "no"; + }*/ + + print ''; + + // Ref + print ''; + if (! $i) $totalarray['nbfield']++; + + + // Date ope + print '\n"; + if (! $i) $totalarray['nbfield']++; + + // Bank account + print '\n"; + if (! $i) $totalarray['nbfield']++; + + // Debit + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; + + // Credit + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; + + print ""; + + $i++; + } + + // Show total line + if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totaldebfield'] == $i) print ''; + elseif ($totalarray['totalcredfield'] == $i) print ''; + else print ''; + } + print ''; + } + + print "
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''.price($cashcontrol->opening).'
'; + $invoicetmp->fetch($objp->facid); + print $invoicetmp->getNomUrl(1); + print ''; + print ''.dol_print_date($db->jdate($objp->do),"day").""; + print "'; + print $bankaccount->getNomUrl(1); + if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount; + elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount; + elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount; + else $other+=$objp->amount; + print "'; + if ($objp->amount < 0) + { + print price($objp->amount * -1); + $totalarray['totaldeb'] += $objp->amount; + } + print "'; + if ($objp->amount > 0) + { + print price($objp->amount); + $totalarray['totalcred'] += $objp->amount; + } + print "
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price(-1 * $totalarray['totaldeb']).''.price($totalarray['totalcred']).'
"; + + $cash=$cash+$cashcontrol->opening; + print "

"; + print $langs->trans("Cash").": ".price($cash)."

"; + print $langs->trans("PaymentTypeCB").": ".price($bank)."

"; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."

"; + if ($other) print $langs->trans("Other").": ".price($other)."

"; + print "

"; + + //save totals to DB + /* + $sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence "; + $sql .= "SET"; + $sql .= " cash='".$cash."'"; + $sql .= ", card='".$bank."'"; + $sql .= " where rowid=".$id; + $db->query($sql); + */ + + print "
"; + + print ''; + + $db->free($resql); +} +else +{ + dol_print_error($db); +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cafd59569bb..8480d8af3cf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1699,7 +1699,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not '' + if (($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) // Unit price can be 0 but not '' { if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { @@ -2161,7 +2161,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); $error++; } - if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') // Unit price can be 0 but not '' + if ((empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) // Unit price can be 0 but not '' { if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { @@ -3900,7 +3900,7 @@ else if ($id > 0 || ! empty($ref)) print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 5075d9d8cb7..6fe44440ff5 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -454,7 +454,7 @@ class Invoices extends DolibarrApi } } - if($this->invoice->update($id, DolibarrApiAccess::$user)) + if($this->invoice->update(DolibarrApiAccess::$user)) return $this->get($id); return false; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f980266226c..2fb31440e56 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -951,8 +951,6 @@ class Facture extends CommonInvoice $error=0; - $this->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // get extrafields so they will be clone @@ -962,8 +960,6 @@ class Facture extends CommonInvoice // Load source object $objFrom = clone $this; - - // Change socid if needed if (! empty($socid) && $socid != $this->socid) { @@ -1008,6 +1004,7 @@ class Facture extends CommonInvoice } // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result=$this->create($user); if ($result < 0) $error++; else { diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index a3168db40d2..55a3e40b55f 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -178,7 +178,7 @@ class PaymentTerm // extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - $sql.= " t.entity"; + $sql.= " t.entity,"; $sql.= " t.code,"; $sql.= " t.sortorder,"; @@ -404,8 +404,6 @@ class PaymentTerm // extends CommonObject $object=new PaymentTerm($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -417,6 +415,7 @@ class PaymentTerm // extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -430,7 +429,7 @@ class PaymentTerm // extends CommonObject //{ //} - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 856433173ad..8ab4fa6f80f 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1335,11 +1335,11 @@ else print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none'); } print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6b0164058c2..f83b024e6ed 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -50,7 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; // Load translation files required by the page -$langs->loadLangs(array('bills', 'companies', 'products')); +$langs->loadLangs(array('bills', 'companies', 'products', 'categories')); $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $projectid=(GETPOST('projectid')?GETPOST('projectid','int'):0); @@ -753,7 +753,7 @@ if ($resql) if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($search_year_lim?$search_year_lim:-1,'search_year_lim',1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); - print '
'.$langs->trans("Late"); + print '
'.$langs->trans("Alert"); print ''; } // Project @@ -1015,7 +1015,7 @@ if ($resql) print ''.dol_print_date($datelimit,'day'); if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Late')); + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); } print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 2ed8b081ceb..d57d594beac 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -47,8 +47,8 @@ foreach($linkedObjectBlock as $key => $objectlink) if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - trans("CustomerInvoice"); ?> - getNomUrl(1); ?> + trans("CustomerInvoice"); ?> + getNomUrl(1); ?> ref_client; ?> date,'day'); ?> $objectlink) if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - trans("RepeatableInvoice"); ?> - getNomUrl(1); ?> - - date_when,'day'); ?> - trans("RepeatableInvoice"); ?> + getNomUrl(1); ?> + + date_when,'day'); ?> + rights->facture->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - - getLibStatut(3); - ?> - - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + getLibStatut(3); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> 1) +{ + ?> + + trans("Total"); ?> + + + + + + + + \ No newline at end of file diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index ea54e66747f..53a5c047790 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -221,7 +221,12 @@ print ''; // Payment type (VIR, LIQ, ...) $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle; -print ''.$langs->trans('PaymentMode').''.$labeltype.''; +print ''.$langs->trans('PaymentMode').''.$labeltype; +print $object->num_paiement?' - '.$object->num_paiement:''; +print ''; + +// Amount +print ''.$langs->trans('Amount').''.price($object->amount,'',$langs,0,-1,-1,$conf->currency).''; $disable_delete = 0; // Bank account @@ -302,9 +307,6 @@ print ''.$form->editfieldkey("Comments",'note',$object->no print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea:'.ROWS_3.':90%'); print ''; -// Amount -print ''.$langs->trans('Amount').''.price($object->amount,'',$langs,0,-1,-1,$conf->currency).''; - print ''; print '
'; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index a712d90b29c..e17ae65750f 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -804,23 +804,55 @@ class Paiement extends CommonObject function update_date($date) { // phpcs:enable - if (!empty($date) && $this->statut!=1) + $error=0; + + if (!empty($date) && $this->statut != 1) { + $this->db->begin(); + + dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql.= " SET datep = '".$this->db->idate($date)."'"; $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update_date", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) + if (! $result) { - $this->datepaye = $date; + $error++; + $this->error='Error -1 '.$this->db->error(); + } + + $type = $this->element; + + $sql = "UPDATE ".MAIN_DB_PREFIX.'bank'; + $sql.= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'"; + $sql.= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")"; + $sql.= " AND rappro = 0"; + + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->error='Error -1 '.$this->db->error(); + } + + if (! $error) + { + + } + + if (! $error) + { + $this->datepaye = $date; $this->date = $date; + + $this->db->commit(); return 0; } else { - $this->error='Error -1 '.$this->db->error(); + $this->db->rollback(); return -2; } } @@ -1139,7 +1171,9 @@ class Paiement extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result=''; - $label = $langs->trans("ShowPayment").': '.$this->ref; + $label = ''.$langs->trans("ShowPayment").'
'; + $label.= ''.$langs->trans("Ref").': '.$this->ref; + $label.= '
'.$langs->trans("Date").': '.dol_print_date($this->date, 'dayhour'); if ($mode == 'withlistofinvoices') { $arraybill = $this->getBillsArray(); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4089ffd76e2..2187b99eaf3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1591,6 +1591,7 @@ class BonPrelevement extends CommonObject function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) { // phpcs:enable + global $conf; $CrLf = "\n"; $Rowing = sprintf("%06d", $row_idfac); diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 710bea7def2..9e13ffcd8a5 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -369,6 +369,7 @@ class Cchargesociales // ... // Create clone + $this->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -378,6 +379,8 @@ class Cchargesociales dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + unset($this->context['createfromclone']); + // End if (!$error) { $this->db->commit(); @@ -386,7 +389,7 @@ class Cchargesociales } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index d3c265150d4..74ddce68230 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -459,8 +459,6 @@ class PaymentSocialContribution extends CommonObject $object=new PaymentSocialContribution($this->db); - $object->context['createfromclone'] = 'createfromclone'; - $this->db->begin(); // Load source object @@ -472,6 +470,7 @@ class PaymentSocialContribution extends CommonObject // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result=$object->create($user); // Other options @@ -488,7 +487,7 @@ class PaymentSocialContribution extends CommonObject } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 636cb92978a..be3e7ea5791 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/compta/list/index.php + * \file htdocs/compta/sociales/list.php * \ingroup tax * \brief Page to list all social contributions */ diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 4691b577368..514f2030065 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -257,7 +257,8 @@ $mend = $tmp['mon']; //var_dump($m); $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; -while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop + +while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; @@ -562,12 +563,11 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; + $sql1 = "SELECT SUM(amount) as mm"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; $sql1 .= " WHERE f.entity = " . $conf->entity; $sql1 .= " AND f.datev >= '" . $db->idate($date_start) . "'"; $sql1 .= " AND f.datev <= '" . $db->idate($date_end) . "'"; - $sql1 .= " GROUP BY dm ORDER BY dm ASC"; $result = $db->query($sql1); if ($result) { diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 7c0d813c2cb..f0bb433c65c 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -166,7 +166,7 @@ if ($result) print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit); print '
'; - print ''; + print '
'."\n"; print ''; print ''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 770b19e5b75..9289c156fdb 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Josep Lluís Amador * * 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 @@ -40,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'users', 'other', 'commercial')); @@ -376,28 +377,22 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - $result = $object->update($contactid, $user); + $result = $object->update($contactid, $user); if ($result > 0) { // Categories association - // First we delete all categories association - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_contact'; - $sql .= ' WHERE fk_socpeople = ' . $object->id; - $db->query( $sql ); - - // Then we add the associated categories - $categories = GETPOST( 'contcats', 'array'); + $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); - $object->old_lastname=''; - $object->old_firstname=''; - $action = 'view'; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } + $object->old_lastname=''; + $object->old_firstname=''; + $action = 'view'; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } } if (! $error && empty($errors)) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 237b82f78d5..bb8f9497969 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies", "suppliers")); +$langs->loadLangs(array("companies", "suppliers", "categories")); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c543e8a0720..5929ec034d1 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2388,8 +2388,6 @@ class Contrat extends CommonObject dol_include_once('/projet/class/project.class.php'); - $this->context['createfromclone'] = 'createfromclone'; - $error = 0; $this->fetch($this->id); @@ -2440,6 +2438,7 @@ class Contrat extends CommonObject } // Create clone + $clonedObj->context['createfromclone'] = 'createfromclone'; $result = $clonedObj->create($user); if ($result < 0) { $error ++; @@ -2479,7 +2478,7 @@ class Contrat extends CommonObject } } - unset($this->context['createfromclone']); + unset($clonedObj->context['createfromclone']); // End if (! $error) { diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 31a6549cc27..63fc671d797 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -149,6 +149,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) if ($action == "update_extras" && ! empty($permissiontoadd)) { $object->fetch(GETPOST('id','int')); + $attributekey = GETPOST('attribute','alpha'); $attributekeylong = 'options_'.$attributekey; $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha'); @@ -169,6 +170,12 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && ! empty($permissiontodelete)) { + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + $result=$object->delete($user); if ($result > 0) { @@ -195,7 +202,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd) { if ($object->id > 0) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later + // Because createFromClone modifies the object, we must clone it so that we can restore it later if error $orig = clone $object; $result=$object->createFromClone($user, $object->id); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 58f96b7faf1..f23844e5d3d 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -217,11 +217,14 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) { // Define if we have to generate thumbs or not $generatethumbs = 1; - if (GETPOST('section_dir')) $generatethumbs=0; + // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) + // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) + // but when we rename from a tab "Documents", we must regenerate thumbs + if (GETPOST('modulepart') == 'medias') $generatethumbs=0; if ($generatethumbs) { - if ($object->id) + if ($object->id) { $object->addThumbs($destpath); } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b56f40c269d..5b4f0c28d0e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -2,6 +2,7 @@ /* Copyright (C) 2015-2017 Laurent Destailleur * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2019 Ferran Marcet * * 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 @@ -423,6 +424,8 @@ if (! $error && $massaction == 'confirm_presend') // Insert logs into agenda foreach($listofqualifiedobj as $objid => $objectobj) { + dol_syslog("Try to insert email event into agenda for objid=".$objid." => objectobj=".get_class($objectobj)); + /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; @@ -448,14 +451,14 @@ if (! $error && $massaction == 'confirm_presend') $objectobj->elementtype = $objectobj->element; $triggername = strtoupper(get_class($objectobj)) .'_SENTBYMAIL'; - if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL'; - if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL'; - if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL'; + if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; + if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL'; + if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL'; if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL'; - if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL'; + if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL'; if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL'; - if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL'; - if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL'; + if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; + if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; if (! empty($triggername)) { @@ -539,7 +542,9 @@ if ($massaction == 'confirm_createbills') $objecttmp = new Facture($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { - + // Load extrafields of order + $cmd->fetch_optionals(); + $objecttmp->socid = $cmd->socid; $objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; @@ -556,6 +561,8 @@ if ($massaction == 'confirm_createbills') $objecttmp->origin = 'commande'; $objecttmp->origin_id = $id_order; + $objecttmp->array_options = $cmd->array_options; // Copy extrafields + $res = $objecttmp->create($user); if($res > 0) $nb_bills_created++; @@ -705,6 +712,7 @@ if ($massaction == 'confirm_createbills') if (! $error && $validate_invoices) { $massaction = $action = 'builddoc'; + foreach($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); @@ -716,12 +724,18 @@ if ($massaction == 'confirm_createbills') } $id = $objecttmp->id; // For builddoc action + $object = $objecttmp; // Builddoc $donotredirect = 1; $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; + + // Call action to build doc + $savobject = $object; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $object = $savobject; } $massaction = $action = 'confirm_createbills'; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9ffaceadb26..e60ef4fdbfd 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -1,6 +1,7 @@ - * +* Copyright (C) 2013 Juanjo Menent +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 24699f0e9f6..3dd66eb1da2 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -42,7 +42,7 @@ class box_produits extends ModeleBoxes * @var DoliDB Database handler. */ public $db; - + var $param; var $info_box_head = array(); @@ -135,13 +135,13 @@ class box_produits extends ModeleBoxes $productstatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'text' => $productstatic->getNomUrl(1), 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'text' => $objp->label, ); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 6a74cd005ab..708b781f092 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -190,7 +190,7 @@ class box_services_contracts extends ModeleBoxes } - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'text' => $s, 'asis' => 1 ); @@ -200,7 +200,7 @@ class box_services_contracts extends ModeleBoxes 'asis' => 1 ); - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', 'text' => $thirdpartytmp->getNomUrl(1), 'asis' => 1 ); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e4bee78afb..bc414ed722c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1777,7 +1777,7 @@ abstract class CommonObject if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) @@ -1962,7 +1962,7 @@ abstract class CommonObject if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) @@ -4940,6 +4940,7 @@ abstract class CommonObject if ($this->array_options[$key] === '') $mandatorypb=true; if ($mandatorypb) { + dol_syslog($this->error); $this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel); return -1; } @@ -5023,8 +5024,6 @@ abstract class CommonObject $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $new_array_options[$key] = $this->db->idate($this->array_options[$key]); - break; case 'datetime': // If data is a string instead of a timestamp, we convert it if (! is_int($this->array_options[$key])) { @@ -6270,7 +6269,7 @@ abstract class CommonObject $e = 0; foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) { - //Show only the key field in params + // Show only the key field in params if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) continue; $enabled = 1; diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index f4e74128747..95c642772e2 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -427,6 +427,7 @@ class Ctyperesource // ... // Create clone + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options @@ -436,6 +437,8 @@ class Ctyperesource dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); @@ -444,7 +447,7 @@ class Ctyperesource } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index b30f79f0bba..3a1fba460c4 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -207,6 +207,8 @@ class EmailSenderProfile extends CommonObject $this->errors = $object->errors; } + unset($object->context['createfromclone']); + // End if (!$error) { $this->db->commit(); diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 78439af1134..68e029dae4b 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -76,9 +76,9 @@ class Events // extends CommonObject // List of all Audit/Security events supported by triggers public $eventstolog=array( - /*array('id'=>'USER_LOGIN', 'test'=>1), + array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1),*/ + array('id'=>'USER_LOGOUT', 'test'=>1), array('id'=>'USER_CREATE', 'test'=>1), array('id'=>'USER_MODIFY', 'test'=>1), array('id'=>'USER_NEW_PASSWORD', 'test'=>1), diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8ba38b81edb..4c4e51c4b13 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -450,7 +450,7 @@ class Form if ($notabs == 2) $tag='div'; if ($notabs == 3) $tag='span'; // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); + //$htmltext=str_replace("\\","\\\\",$htmltext); $htmltext=str_replace("\r","",$htmltext); $htmltext=str_replace("\n","",$htmltext); @@ -516,7 +516,7 @@ class Form * @param string $text Text to show * @param string $htmltext Content of tooltip * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon - * @param string $type Type of picto ('info', 'help', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath + * @param string $type Type of picto ('info', 'help', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none' * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span @@ -557,12 +557,13 @@ class Form if ($type == 'info' || $type == 'help') return $text; } + $img=''; if ($type == 'info') $img = img_help(0, $alt); elseif ($type == 'help') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); elseif ($type == 'superadmin') $img = img_picto($alt, 'redstar'); elseif ($type == 'admin') $img = img_picto($alt, 'star'); elseif ($type == 'warning') $img = img_warning($alt); - else $img = img_picto($alt, $type); + elseif ($type != 'none') $img = img_picto($alt, $type); // $type can be an image path return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap); } @@ -1141,8 +1142,8 @@ class Form $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $sql .= " ,s.address, s.zip, s.town"; - $sql .= " , dictp.code as country_code"; + $sql .= ", s.address, s.zip, s.town"; + $sql .= ", dictp.code as country_code"; } $sql.= " FROM (".MAIN_DB_PREFIX ."societe as s"; @@ -1441,9 +1442,10 @@ class Form $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); } - if ($htmlname != 'none' || $options_only) $out.= ''; if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out.= ''; if ($showempty == 2) $out.= ''; + $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -1504,7 +1506,7 @@ class Form $out.= ($socid != -1) ? ($langs->trans($socid?"NoContactDefinedForThirdParty":"NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst'); $out.= ''; } - if ($htmlname != 'none' || $options_only) + if ($htmlname != 'none' && ! $options_only) { $out.= ''; } @@ -2491,9 +2493,10 @@ class Form * @param array $ajaxoptions Options for ajax_autocompleter * @param int $hidelabel Hide label (0=no, 1=yes) * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss More CSS * @return void */ - function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0, $alsoproductwithnosupplierprice=0) + function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0, $alsoproductwithnosupplierprice=0, $morecss='') { // phpcs:enable global $langs,$conf; @@ -2518,7 +2521,7 @@ class Form } else { - print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice); + print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice, $morecss); } } @@ -2536,9 +2539,10 @@ class Form * @param int $outputmode 0=HTML select string, 1=Array * @param int $limit Limit of line number * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss Add more CSS * @return array Array of keys for json */ - function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100,$alsoproductwithnosupplierprice=0) + function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100,$alsoproductwithnosupplierprice=0,$morecss='') { // phpcs:enable global $langs,$conf,$db; @@ -2593,7 +2597,7 @@ class Form $num = $this->db->num_rows($result); //$out.=''; + $out.=''; print ''; - $this->select_types_paiements($selected,$htmlname,$filtertype,0,0,0,0,$active); + $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active); print ''; print ''; } @@ -5671,7 +5676,7 @@ class Form * @param int $disablebademail Check if an email is found into value and if not disable and colorize entry * @param int $nohtmlescape No html escaping. * @return string HTML select string. - * @see multiselectarray + * @see multiselectarray, selectArrayAjax, selectArrayFilter */ static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='',$disablebademail=0, $nohtmlescape=0) { @@ -6001,14 +6006,18 @@ class Form * @param string $placeholder String to use as placeholder * @param int $addjscombo Add js combo * @return string HTML multiselect string - * @see selectarray + * @see selectarray, selectArrayAjax, selectArrayFilter */ - static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=1) + static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1) { global $conf, $langs; $out = ''; + if ($addjscombo < 0) { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1; + else $addjscombo = 0; + } // Add code for jquery to use multiselect if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) @@ -6254,7 +6263,7 @@ class Form $hookmanager->initHooks(array('commonobject')); $parameters=array( 'morehtmlright' => $morehtmlright, - 'compatibleImportElementsList' =>& $compatibleImportElementsList, + 'compatibleImportElementsList' => &$compatibleImportElementsList, ); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -6431,6 +6440,7 @@ class Form $hookmanager->initHooks(array('commonobject')); $parameters=array('listofidcompanytoscan' => $listofidcompanytoscan); $reshook=$hookmanager->executeHooks('showLinkToObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) @@ -6454,7 +6464,7 @@ class Form if (! empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || ! in_array($key, $excludelinksto))) { - print '
global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>'; + print '
use_javascript_ajax)?'':' style="display:none"').'>'; $sql = $possiblelink['sql']; $resqllist = $this->db->query($sql); @@ -6463,9 +6473,11 @@ class Form $num = $this->db->num_rows($resqllist); $i = 0; - print '
'; - print ''; + print '
'; + print ''; print ''; + print ''; + print ''; print ''; print '
'; print ''; @@ -6514,8 +6526,9 @@ class Form { $linktoelem=' '; // Ref - print ''; + print ''; // Onwer print ''; + print ''; } // Background color THEME_ELDY_BACKBODY @@ -513,6 +514,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // TopMenuBackgroundColor @@ -561,6 +563,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // LeftMenuBackgroundColor @@ -609,6 +612,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // TextTitleColor for title of Pages @@ -719,6 +723,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // BackgroundTableLineEvenColor @@ -748,6 +753,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // Text LinkColor @@ -798,6 +804,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print ''; + print ''; } // Use Hover @@ -888,5 +895,38 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print ''; } + // Use MAIN_OPTIMIZEFORTEXTBROWSER + if ($foruserprofile) + { + $default=$langs->trans('No'); + print ''; + print ''; + print ''; + print ''; + } + else + { + // TODO + } + print '
'.$ref.''.$ref.''; if (! empty($action->userownerid)) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 60017d82570..9d0bded74b6 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -622,8 +622,8 @@ class FormCompany runJsCodeForEvent'.$htmlname.'(values); } }); - /* Clean contact */ - $("div#s2id_contactid>a>span").html(\'\'); + + $(this).trigger("blur"); }); // Function used to execute events when search_htmlname change diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index be9993a74b5..da2f697d5d4 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -307,8 +307,10 @@ class FormFile return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } - // Add entity in $param - $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + // Add entity in $param if not already exists + if (!preg_match('/entity\=[0-9]+/', $param)) { + $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + } $printer=0; if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison'))) // The direct print feature is implemented only for such elements diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 1b6efe56820..35b3e52d154 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -334,7 +334,7 @@ class FormProjets $out=''; $hideunselectables = false; - if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (empty($projectsListId)) { @@ -346,11 +346,11 @@ class FormProjets } // Search all projects - $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,'; + $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,'; $sql.= ' s.nom as name'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,'; + $sql.= ' '.MAIN_DB_PREFIX.'projet_task as t'; $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND t.fk_projet = p.rowid"; if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")"; @@ -393,7 +393,7 @@ class FormProjets } else { - if ($discard_closed == 1 && $obj->fk_statut == 2) + if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) { $i++; continue; @@ -411,12 +411,12 @@ class FormProjets if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; $disabled=0; - if ($obj->fk_statut == 0) + if ($obj->fk_statut == Project::STATUS_DRAFT) { $disabled=1; $labeltoshow.=' - '.$langs->trans("Draft"); } - else if ($obj->fk_statut == 2) + else if ($obj->fk_statut == Project::STATUS_CLOSED) { if ($discard_closed == 2) $disabled=1; $labeltoshow.=' - '.$langs->trans("Closed"); diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index abcf2132efa..6f43643eeb7 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -61,7 +61,7 @@ class Interfaces * @param string $action Trigger event code * @param object $object Objet concerned. Some context information may also be provided into array property object->context. * @param User $user Objet user - * @param Lang $langs Objet lang + * @param Translate $langs Objet lang * @param Conf $conf Objet conf * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. */ @@ -86,6 +86,7 @@ class Interfaces global $db; $user = new User($db); } + //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG); $nbfile = $nbtotal = $nbok = $nbko = 0; @@ -94,6 +95,7 @@ class Interfaces $orders = array(); $i=0; + $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 7f4ab7c6d4a..86b27948389 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -589,7 +589,6 @@ class Menubase $a = 0; $b = 0; - $oldrowid=0; while ($a < $numa) { //$objm = $this->db->fetch_object($resql); diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 1a58e14796a..90986e7b6da 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -384,16 +384,16 @@ abstract class Stats $row = $this->db->fetch_object($resql); $result[$i]['year'] = $row->year; $result[$i]['nb'] = $row->nb; - if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; + if($i>0 && $row->nb>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; $result[$i]['total'] = $row->total; - if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; + if($i>0 && $row->total>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; $result[$i]['avg'] = $row->avg; - if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; + if($i>0 && $row->avg>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; // For some $sql only if (isset($row->weighted)) { $result[$i]['weighted'] = $row->weighted; - if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; + if($i>0 && $row->weighted>0) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; } $i++; } diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index cc08af7431f..cfa05289f4b 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -29,14 +29,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -session_cache_limiter(false); +session_cache_limiter('public'); require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); +if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); else header('Cache-Control: no-cache'); //var_dump($conf); diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php index 485a57ede88..dad6482460a 100644 --- a/htdocs/core/js/lib_gravatar.js.php +++ b/htdocs/core/js/lib_gravatar.js.php @@ -33,14 +33,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -session_cache_limiter(false); +session_cache_limiter('public'); require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); +if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); else header('Cache-Control: no-cache'); ?> diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index f2aa6fc521f..5b909c6e148 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -32,14 +32,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -session_cache_limiter(false); +session_cache_limiter('public'); require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); +if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); else header('Cache-Control: no-cache'); diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 6900e9b03e7..fa7095c65ac 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -40,7 +40,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H // TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when. /* session already started into main - session_cache_limiter(false); + session_cache_limiter('public'); header('Cache-Control: no-cache'); session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie session_start();*/ diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php index 8e67f517b44..38c450b8e23 100644 --- a/htdocs/core/js/timepicker.js.php +++ b/htdocs/core/js/timepicker.js.php @@ -29,14 +29,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -session_cache_limiter(false); +session_cache_limiter('public'); require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); +if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); else header('Cache-Control: no-cache'); ?> diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index e3a0f44c9ac..1fcda0e34d2 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -382,6 +382,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return ''; + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e06e071ee89..3f1efad3bce 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1341,6 +1341,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (is_object($objcon) && $objcon->id) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; + $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id; } if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; @@ -1373,13 +1374,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; } - // Work with new table actioncomm_resources and multiple contact affectation. - if (is_object($objcon) && $objcon->id) - { - $sql.= " AND r.element_type = '" . $objcon->table_element . "'" . - " AND r.fk_element = " . $objcon->id; - } - // Condition on actioncode if (! empty($actioncode)) { @@ -1403,7 +1397,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); - + //TODO Add limit for thirdparty in contexte very all result $sql.= $db->order($sortfield, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1bca14827e6..964e368c4e3 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2119,6 +2119,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (empty($conf->multicompany->enabled)) $entity=1; else $entity=0; } + // Fix modulepart + if ($modulepart == 'users') $modulepart='user'; + dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); // We define $accessallowed and $sqlprotectagainstexternals $accessallowed=0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9cc9f315e82..fffe95cbb0c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -321,13 +321,18 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu } } } - if (! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) // If there is saved contextpage + // If there is saved contextpage, page or limit + if ($paramname == 'contextpage' && ! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) { - if ($paramname == 'contextpage') - { - $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring]; - //var_dump($paramname.' '.$out); - } + $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring]; + } + elseif ($paramname == 'page' && ! empty($_SESSION['lastsearch_page_'.$relativepathstring])) + { + $out = $_SESSION['lastsearch_page_'.$relativepathstring]; + } + elseif ($paramname == 'limit' && ! empty($_SESSION['lastsearch_limit_'.$relativepathstring])) + { + $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; } } // Else, retreive default values if we are not doing a sort @@ -611,7 +616,7 @@ if (! function_exists('dol_getprefix')) /** * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. * The prefix for session is unique in a web context only and is unique for instance and avoid conflict - * between multi-instances, even when having two instances with one root dir or two instances in virtual servers. + * between multi-instances, even when having two instances with same root dir or two instances in same virtual servers. * The prefix for email is unique if MAIL_PREFIX_FOR_EMAIL_ID is set to a value, otherwise value may be same than other instance. * * @param string $mode '' (prefix for session name) or 'email' (prefix for email id) @@ -629,16 +634,16 @@ if (! function_exists('dol_getprefix')) if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; } - return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); + return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); } if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) { - return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); - // Use this for a "readable" cookie name + return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); + // Use this for a "readable" key //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); } - return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); + return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); } } @@ -1437,6 +1442,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here. { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $ret = dol_convert_file($file, 'png', $fileimage); if ($ret < 0) $error++; } @@ -3009,8 +3015,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'note','switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', - 'skype','twitter','facebook' + 'note', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', + 'jabber','skype','twitter','facebook' ) )) { $fakey = $pictowithoutext; @@ -3097,16 +3103,23 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-play'; $facolor = '#444'; } + elseif ($pictowithoutext == 'jabber') { + $fakey = 'fa-comment-o'; + } + elseif ($pictowithoutext == 'split') { + $fakey = 'fa-code-fork'; + } else { $fakey = 'fa-'.$pictowithoutext; $facolor = '#444'; $marginleftonlyshort=0; } + $reg=array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.= ($morecss?' ':'').$reg[1]; } - $enabledisablehtml = ''; + $enabledisablehtml = ''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $enabledisablehtml.= $titlealt; } @@ -3122,11 +3135,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme } else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { - $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module } // If we ask an image into $url/$mymodule/img (instead of default path) - if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { + if (preg_match('/^([^@]+)@([^@]+)$/i', $picto, $regs)) { $picto = $regs[1]; $path = $regs[2]; // $path is $mymodule } @@ -4337,7 +4350,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) * @return string Chaine avec montant formate * - * @see price2num Revert function of price + * @see price2num() Revert function of price */ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='') { @@ -4400,7 +4413,11 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou if ($currency_code == 'auto') $currency_code=$conf->currency; $listofcurrenciesbefore=array('USD','GBP','AUD','MXN','PEN','CNY'); - if (in_array($currency_code,$listofcurrenciesbefore)) $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); + $listoflanguagesbefore=array('nl_NL'); + if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) + { + $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); + } else { $tmpcur=$outlangs->getCurrencySymbol($currency_code); @@ -4506,37 +4523,49 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) * Output a dimension with best unit * * @param float $dimension Dimension - * @param int $unit Unit of dimension (0, -3, ...) + * @param int $unit Unit of dimension (Example: 0=kg, -3=g, 98=ounce, 99=pound, ...) * @param string $type 'weight', 'volume', ... * @param Translate $outputlangs Translate language object * @param int $round -1 = non rounding, x = number of decimal - * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit + * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT) * @return string String to show dimensions */ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no') { require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) + if (($forceunitoutput == 'no' && $dimension < 1/10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) { $dimension = $dimension * 1000000; $unit = $unit - 6; } - elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) + elseif (($forceunitoutput == 'no' && $dimension < 1/10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) { $dimension = $dimension * 1000; $unit = $unit - 3; } - elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) + elseif (($forceunitoutput == 'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) { $dimension = $dimension / 1000000; $unit = $unit + 6; } - elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) + elseif (($forceunitoutput == 'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) { $dimension = $dimension / 1000; $unit = $unit + 3; } + // Special case when we want output unit into pound or ounce + /* TODO + if ($unit < 90 && $type == 'weight' && is_numeric($forceunitoutput) && (($forceunitoutput == 98) || ($forceunitoutput == 99)) + { + $dimension = // convert dimension from standard unit into ounce or pound + $unit = $forceunitoutput; + } + if ($unit > 90 && $type == 'weight' && is_numeric($forceunitoutput) && $forceunitoutput < 90) + { + $dimension = // convert dimension from standard unit into ounce or pound + $unit = $forceunitoutput; + }*/ $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type); @@ -5838,7 +5867,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; - if (is_object($object) && $object->element == 'member') + if (! empty($conf->adherent->enabled)) { $substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__'; $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; @@ -5866,9 +5895,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = 'Direct download url of an order'; $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = 'Direct download url of an invoice'; - if (is_object($object) && $object->element == 'shipping') + if (! empty($conf->expedition->enabled)) { - $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; + $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; } } @@ -5876,38 +5905,41 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__ID__'] = $object->id; $substitutionarray['__REF__'] = $object->ref; - $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '')); - $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : ''); + $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); + $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); // TODO Remove this $msgishtml = 0; $birthday = dol_print_date($object->birth,'day'); - $substitutionarray['__MEMBER_ID__']=$object->id; - if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); - $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; - $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); - $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; - $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; - $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; - $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town; - $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country; - $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email; - $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday; - $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo; - $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login; - $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass; - $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; - $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; - $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; - $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); - $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); - $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); - $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc'); - $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc'); - $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc'); + if ($object->id > 0) + { + $substitutionarray['__MEMBER_ID__']=$object->id; + if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); + $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; + $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); + $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; + $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; + $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; + $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town; + $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country; + $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email; + $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday; + $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo; + $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login; + $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass; + $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; + $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; + $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc'); + } if (is_object($object) && $object->element == 'societe') { @@ -5939,17 +5971,20 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) { - $dateplannedstart=''; - $datenextexpiration=''; - foreach($object->lines as $line) + if ($object->id > 0) { - if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue; - if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue; + $dateplannedstart=''; + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue; + if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue; + } + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } - $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); - $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); - $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); - $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } // Create dynamic tags for __EXTRAFIELD_FIELD__ @@ -5988,30 +6023,33 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $paymenturl=$url; } - $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):''); - $substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl; + if ($object->id > 0) + { + $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):''); + $substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') - { - $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; + if (! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; + if (! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; } - else $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; - if (! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') - { - $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); - } - else $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; - if (! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') - { - $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); - } - else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; } } if (empty($exclude) || ! in_array('objectamount', $exclude)) { - $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : ''; - $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : ''; + $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : ''; + $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : null) : ''; $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:''; @@ -6019,11 +6057,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?$object->total_localtax1:''; if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?$object->total_localtax2:''; - $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency):''; - $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency):''; - $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency)):''; - if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)?price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency):''; - if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)?price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency):''; + $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?($object->total_ttc ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?($object->total_ht ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency): ($object->total_tva ? price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency) : null)):''; + if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)? ($object->total_localtax1 ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)? ($object->total_localtax2 ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; // TODO Add keys for foreign multicurrency @@ -6134,10 +6172,12 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) // Make substitition for array $substitutionarray foreach ($substitutionarray as $key => $value) { + if (! isset($value)) continue; // If value is null, it same than not having substitution key at all into array, we do not replace. + if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection - $text=str_replace("$key","$value",$text); // We must keep the " to work when value is 123.5 for example + $text=str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example } return $text; @@ -7145,7 +7185,7 @@ function printCommonFooter($zone='private') if ($zone == 'private' && empty($conf->dol_use_jmobile)) { print "\n"; - print '/* JS CODE TO ENABLE to enable handler to switch left menu page (menuhider) */'."\n"; + print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; print 'jQuery(".menuhider").click(function() {'; print ' console.log("We click on .menuhider");'."\n"; //print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md @@ -7155,9 +7195,9 @@ function printCommonFooter($zone='private') } // Management of focus and mandatory for fields - if ($action == 'create' || $action == 'edit') + if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"])))) { - print '/* Code js to manage focus and mandatory form fields */'."\n"; + print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n"; $relativepathstring = $_SERVER["PHP_SELF"]; // Clean $relativepathstring if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); @@ -7186,8 +7226,10 @@ function printCommonFooter($zone='private') { foreach($defval as $paramkey => $paramval) { - // Add property 'required' on input + // Set focus on field print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n"; + print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n"; + print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really usefull, but we keep it in case of. } } } @@ -7216,6 +7258,7 @@ function printCommonFooter($zone='private') { // Add property 'required' on input print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; + print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 247fbb20c14..4490a59d055 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -728,7 +728,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $cury+=3; } - if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enought for them + if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them { // Note: // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 84d32725682..8b6ca6a5ca3 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -52,9 +52,44 @@ function project_prepare_head($object) $head[$h][2] = 'contact'; $h++; + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + // Then tab for sub level of projet, i mean tasks + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; + $head[$h][1] = $langs->trans("Tasks"); + + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + $taskstatic=new Task($db); + $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); + if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; + $head[$h][2] = 'tasks'; + $h++; + + $nbTimeSpent=0; + $sql = "SELECT t.rowid"; + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE t.fk_task = pt.rowid"; + $sql .= " AND pt.fk_projet =".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbTimeSpent=1; + } + else dol_print_error($db); + + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; + $head[$h][1] = $langs->trans("TimeSpent"); + if ($nbTimeSpent > 0) $head[$h][1].= ' ...'; + $head[$h][2] = 'timespent'; + $h++; + } + if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) + || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) + || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) { $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; $head[$h][1] = $langs->trans("ProjectOverview"); @@ -92,41 +127,6 @@ function project_prepare_head($object) $head[$h][2] = 'document'; $h++; - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { - // Then tab for sub level of projet, i mean tasks - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id; - $head[$h][1] = $langs->trans("Tasks"); - - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $taskstatic=new Task($db); - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); - if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; - $head[$h][2] = 'tasks'; - $h++; - - $nbTimeSpent=0; - $sql = "SELECT t.rowid"; - //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; - //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; - $sql .= " WHERE t.fk_task = pt.rowid"; - $sql .= " AND pt.fk_projet =".$object->id; - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $nbTimeSpent=1; - } - else dol_print_error($db); - - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; - $head[$h][1] = $langs->trans("TimeSpent"); - if ($nbTimeSpent > 0) $head[$h][1].= ' ...'; - $head[$h][2] = 'timespent'; - $h++; - } - // Manage discussion if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) { @@ -1205,7 +1205,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ { continue; } - + // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 83e90114bb6..e98484707c0 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -483,9 +483,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND (ug.fk_user = dbt.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; - $sql.= " OR dbt.entity = 0"; // Show always superadmin + $sql.= " AND ((ug.fk_user = dbt.rowid"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; + $sql.= " OR dbt.entity = 0)"; // Show always superadmin } } else { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 033d4eb37fe..5747c0a5c0e 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -467,6 +467,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; print '
'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").''; + if ($edit) + { + print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1); + } + else + { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + print yn($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER); + } + else + { + print yn(1); + if (empty($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) print ' ('.$langs->trans("ForcedByGlobalSetup").')'; + } + } + print '   ('.$langs->trans("Default").': '.yn(0).') '; + print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORTEXTBROWSERDesc")); + print '
'; } diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 70f61055689..da16b0846c5 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -212,6 +212,10 @@ function dolWebsiteOutput($content) $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + $content=preg_replace('/(]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); } else @@ -222,6 +226,10 @@ function dolWebsiteOutput($content) $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep); + $content=preg_replace('/(]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); } } @@ -733,15 +741,9 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); dol_delete_file($filewrapper); - $wrappercontent = 'mycompany->dir_output."/".$original_file));'."\n"; - $wrappercontent.= "else print 'Bad value for modulepart or file';\n"; - $wrappercontent.= 'if (is_object($db)) $db->close();'."\n"; - $wrappercontent.= '// END PHP ?>'."\n"; + + $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); + $result2 = file_put_contents($filewrapper, $wrappercontent); if (! empty($conf->global->MAIN_UMASK)) @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index b2bf32bf8c2..1ca94b38106 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -153,7 +153,7 @@ function print_start_menu_array_auguria() global $conf; print '
'; - print '
    global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>'; + print '