diff --git a/COPYRIGHT b/COPYRIGHT index 9704c857ed3..aedcb1be614 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -12,41 +12,41 @@ Dolibarr uses some external libraries released under different licenses. This is Component Version License GPL Compatible Usage ------------------------------------------------------------------------------------- PHP libraries: -AdoDb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) +ADOdb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers -GeoIP2 0.2.0 LGPL-2.1+ Yes Lib to make geoip convert +GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files -PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers +PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests -PSR/Logs 1.0 Library for logs (used by DebugBar) -PSR/simple-cache ? Library for cache (used by PHPSpreadSheet) +PSR/Logs 1.0 Library for logs (used by DebugBar) +PSR/simple-cache ? MIT License Yes Library for cache (used by PHPSpreadSheet) Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Sabre 3.2.2 BSD Yes DAV support -Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP -Stripe 7.67.0 MIT licence Yes Library for Stripe module +Swift Mailer 5.4.2-DEV MIT License Yes Comprehensive mailing tools for PHP +Stripe 7.67.0 MIT Licence Yes Library for Stripe module TCPDF 6.3.2 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement JS libraries: Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. -ChartJS 2.9.4 MIT License Yes JS library for graph +ChartJS 2.9.4 MIT License Yes JS library for graph jQuery 3.5.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI -jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css +jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images) jQuery Jeditable 1.7.1 GPL and MIT License Yes JS library plugin jeditable (to edit in place) -jQuery jNotify 1.1.00 Apache Software License 2.0 Yes JS library plugin jNotify (to use ajax popups) +jQuery jNotify 1.1.00 Apache License 2.0 Yes JS library plugin jNotify (to use ajax popups) jQuery jPicker 1.1.6 GPL and MIT License Yes JS library for color picker with not defined list of colors jQuery jqueryFileTree 1.0.1 GPL and MIT License Yes JS library for filetree jQuery jquerytreeview 1.4.1 MIT License Yes JS library for filetree @@ -54,13 +54,13 @@ jQuery TableDnD 0.6 GPL and MIT License Yes jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker jsGanttImproved 2.7.3 BSD License Yes JS library (to build Gantt reports) JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone -SwaggerUI 2.2.10 GPL-2+ Yes JS library to offer the REST API explorer +SwaggerUI 2.2.10 GPL-2+ Yes JS library to offer the REST API explorer Image libraries: Octicons 8.1 MIT Yes Font libraries: -Fontawesome 5.13 Font Awesome Free licence Yes +Fontawesome 5.13 Font Awesome Free Licence Yes For licenses compatibility informations: diff --git a/build/debian/README.howto b/build/debian/README.howto index c38a53718ae..45df1e9df70 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -51,16 +51,17 @@ export DEBEMAIL="eldy@destailleur.fr" export QUILT_PATCHES=debian/patches -# To use Alioth.debian.org -* Create an account login -* Update your ~/.ssh/config file to add: -Host svn.debian.org git.debian.org bzr.debian.org hg.debian.org darcs.debian.org arch.debian.org + +# Note: alioth.debian.org is outdated --> https://alioth-archive.debian.org/ --> https://salsa.debian.org/public + * Create an account login + * Update your ~/.ssh/config file to add: + Host svn.debian.org git.debian.org bzr.debian.org hg.debian.org darcs.debian.org arch.debian.org User eldy-guest IdentityFile ~/.ssh/id_rsa -* Check login on page https://alioth.debian.org/users/login -Ex: https://alioth.debian.org/users/eldy-guest -* Setup your ssh as described into page: http://wiki.debian.org/Alioth/SSH -* Ask to be included into project collab-maint: http://alioth.debian.org/projects/collab-maint/ + * Check login on page https://alioth.debian.org/users/login + Ex: https://alioth.debian.org/users/eldy-guest + * Setup your ssh as described into page: http://wiki.debian.org/Alioth/SSH + * Ask to be included into project collab-maint: http://alioth.debian.org/projects/collab-maint/ @@ -82,7 +83,7 @@ Ex: https://alioth.debian.org/users/eldy-guest # dpkg -c package.deb List content of package # dpkg -I package.deb Give informations on package # dpkg -i package.deb Install a package -# dpkg-reconfigure -plow package Reconfigure package +# dpkg-reconfigure -plow package Reconfigure package # dpkg -L packagename List content of installed package # dpkg -r packagename Remove config files and interactive saved answers # dpkg -s packagename Give status of installed package @@ -90,7 +91,7 @@ Ex: https://alioth.debian.org/users/eldy-guest # # dpkg-buildpackage -us -uc Build a source and binary package # -# gdebi package.deb Install a package + dependencies +# gdebi package.deb Install a package + dependencies @@ -98,21 +99,21 @@ Ex: https://alioth.debian.org/users/eldy-guest - Post an ITP with reportbugs : > reportbug -B debian --email username@domain.tld wnpp -See page http://www.debian.org/devel/wnpp/#l1 for example of ITP requests contents. +See page https://www.debian.org/devel/wnpp/#l1 for example of ITP requests contents. - Wait until you received bug number. For first ITP submission of Dolibarr, bug id was 634783. - Check bug is into database by searching with id on - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634783 + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634783 - Add a line for upstream into file changelog with bug number - Call for a mentor on ML debian-mentors to upload packages - Once package is uploaded, following URL are available: -http://packages.qa.debian.org/package.html -http://bugs.debian.org/package +https://packages.qa.debian.org/package.html +https://bugs.debian.org/package ##### Modify severity of a bug ticket diff --git a/build/phpstan/README b/build/phpstan/README new file mode 100644 index 00000000000..4ecde9baca5 --- /dev/null +++ b/build/phpstan/README @@ -0,0 +1,9 @@ +PHPStan + +https://phpstan.org + +PHPStan requires PHP >= 7.1 + +Install: composer require --dev phpstan/phpstan + +Config File: phpstan.neon diff --git a/build/rpm/README b/build/rpm/README index 99f871e882a..ab7be252ccb 100644 --- a/build/rpm/README +++ b/build/rpm/README @@ -3,48 +3,54 @@ README (English) RPM Package tools ################################################## -This directory contains files used by makepack-dolibarr.pl -script to build a package, ready to be distributed, -with format RPM (for Redhat, OpenSuse, Mandriva, ...). +This directory contains files used by makepack-dolibarr.pl script to build a package, +ready to be distributed with format RPM (https://rpm.org) +for Linux Distributions like Redhat, Fedora, CentOS, OpenSuse, OpenMandriva, Mageia ... # This is standard command to work on RPM packaging: -# + # To install all packagers tools: -# Fedora: yum -y install rpmlint fedora-packager mock koji hunspell-en hunspell-es hunspell-fr hunspell-it -# OpenSuse: yast --install update-desktop-files -# + - Fedora: yum -y install rpmlint fedora-packager mock koji hunspell-en hunspell-es hunspell-fr hunspell-it + - OpenSuse: yast --install update-desktop-files + # rpmlint file.rpm Test a package # mock -r fedora-15-i386 --rebuild ../SRPMS/hello-2.7-1.fc15.src.rpm -# + + # On Fedora -# rpm -i --test dolibarr-...rpm To list dependencies of RPM -# yum -v install dolibarr-...rpm To install package and dependencies -# yum -v erase dolibarr To remove package -# chcon -R -h -t httpd_sys_script_rw_t /file To add temporary context rw for httpd on /file -# semanage fcontext -a -t httpd_sys_script_rw_t "/dir/(.*)?" To add persistent context rw for httpd on /dir (this add file_contexts.local) -# restorecon -R -v /file Restore values into files (cancel chcon, validate semanage) -# +# ========= +# rpm -i --test dolibarr-...rpm to list dependencies of RPM +# yum -v install dolibarr-...rpm to install package and dependencies +# yum -v erase dolibarr to remove package +# chcon -R -h -t httpd_sys_script_rw_t /file to add temporary context rw for httpd on /file +# restorecon -R -v /file to restore values into files (cancel chcon, validate semanage) +# semanage fcontext -a -t httpd_sys_script_rw_t "/dir/(.*)?" to add persistent context rw for httpd on /dir (this add file_contexts.local) + + # On OpenSuse -# zypper install dolibarr-...rpm To install package and dependencies -# zypper remove dolibarr To remove package -# zypper search xxx To search a package -# +# =========== +# zypper install dolibarr-...rpm to install package and dependencies +# zypper remove dolibarr to remove package +# zypper search xxx to search a package + + # On Mageia (after su - root) -# urpmi dolibarr-...rpm To install package and dependencies -# urpme dolibarr To remove package +# =========================== +# urpmi dolibarr-...rpm to install package and dependencies +# urpme dolibarr to remove package # -# More on rpm on page http://www.trustonme.net/didactels/273.html To submit a package to Fedora: -- Create account on bugzilla.redhat.com -- Create account on fedoraproject.org -- Create SRPMS package. -- Upload package onf http://fedorapeople.org -- Create a bug with form https://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Fedora&format=fedora-review +- Create account on https://bugzilla.redhat.com +- Create account on https://developer.fedoraproject.org/ +- Create SRPMS package +- Upload package on https://fedorapeople.org +- Create a bug with form https://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Fedora&format=fedora-review + This is example of content of review field (used for Bug 723326 - https://bugzilla.redhat.com/show_bug.cgi?id=723326): -SRPMS URL: http://www.dolibarr.org/files/fedora/dolibarr-x.y.z-xxx.src.rpm +SRPMS URL: https://www.dolibarr.org/files/fedora/dolibarr-x.y.z-xxx.src.rpm Description: Dolibarr ERP & CRM is an easy to use open source/free software for small and medium companies, foundations or freelances. It includes different features for Enterprise Resource Planning (ERP) and Customer @@ -56,4 +62,4 @@ is my first package to maintain myself. So i'm seeking a sponsor. - Install fedora packager tools: yum install fedora-packager - Setup fedora packagers tools: fedora-packager-setup - Send your package: koji build --scratch f16 path_to_source_RPM -- Check if package is available: http://koji.fedoraproject.org/koji/ \ No newline at end of file +- Check if package is available: https://koji.fedoraproject.org/koji/ diff --git a/dev/resources/iso-normes/EORI.txt b/dev/resources/iso-normes/EORI.txt new file mode 100644 index 00000000000..13ff095c693 --- /dev/null +++ b/dev/resources/iso-normes/EORI.txt @@ -0,0 +1,6 @@ +EORI + +https://en.wikipedia.org/wiki/EORI_number + +in Dolibarr avaiable since v13 +- it is set to field 'profid5' diff --git a/dev/translation/README b/dev/translation/README index 8d6954878b5..3ceedcd4b82 100644 --- a/dev/translation/README +++ b/dev/translation/README @@ -17,3 +17,7 @@ for Linux OS to install or to update transifex client: sudo pip install --upgrade transifex-client + +Comparison of Terms between ERPs +--------------------------------- +https://wiki.dolibarr.org/index.php?title=Comparison_of_Terms_between_ERPs diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 59aeaae06f0..79a5c0975b7 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -169,7 +169,7 @@ foreach ($list_account_main as $key) { print ''; // Value print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accountsmain'); print ''; print ''; } @@ -186,7 +186,7 @@ foreach ($list_account as $key) { print ''.$label.''; // Value print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts'); print ''; print ''; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index a0764a97af2..24d31acddd6 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -302,7 +302,9 @@ if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print ''; print ''; -print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; +print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX"); +print ' - '.$langs->trans("NotRecommended").''; +print ''; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e03790a8995..75283667fcb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2020 Alexandre Spangaro + * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -30,6 +30,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; @@ -38,9 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "compta")); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$sortorder = GETPOST("sortorder", 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); $action = GETPOST('action', 'aZ09'); // Load variable for pagination @@ -60,7 +58,7 @@ $pagenext = $page + 1; $show_subgroup = GETPOST('show_subgroup', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); - +$search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -134,6 +132,12 @@ if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; } +if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]='.urlencode($code); + } +} if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -157,6 +161,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_end = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; + $search_ledger_code = array(); $filter = array(); } @@ -249,6 +254,12 @@ if ($action != 'export_csv') { $moreforfilter .= ': '; $moreforfilter .= ''; + $moreforfilter .= ''; + + $moreforfilter .= '
'; + + $moreforfilter .= $langs->trans("Journal"); + $moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); $moreforfilter .= '
'; @@ -261,17 +272,16 @@ if ($action != 'export_csv') { print ''; } + $colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4); print ''; print ''; print ''; print ''; } - print ''; print "\n"; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 498c513b761..a8a24e67d9d 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -72,7 +72,7 @@ if ($search_accountancy_code_end == - 1) { $search_accountancy_code_end = ''; } -$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code"); +$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha'); $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); if ($search_accountancy_aux_code_start == - 1) { $search_accountancy_aux_code_start = ''; @@ -457,12 +457,14 @@ if (count($filter) > 0) { $sqlwhere[] = $key.'=\''.$db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=') { $sqlwhere[] = $key.'\''.$db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key.'='.$value; - } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { + } elseif ($key == 't.numero_compte') { $sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\''; + } elseif ($key == 't.subledger_account') { + $sqlwhere[] = natural_search($key, $value, 0, 1); } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { @@ -750,36 +752,29 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.numero_compte']['checked'])) { print ''; } // Subledger account if (!empty($arrayfields['t.subledger_account']['checked'])) { print ''; } // Label operation diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a93b36cf2b4..3594bb26fc8 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -129,13 +129,13 @@ class BookKeeping extends CommonObject /** * @var float FEC:Amount (Not necessary) - * @deprecated Use $amount + * @deprecated No more used (we have info into debit/credit and sens) */ public $montant; /** * @var float FEC:Amount (Not necessary) - * @deprecated No more used + * @deprecated No more used (we have info into debit/credit and sens) */ public $amount; @@ -287,34 +287,38 @@ class BookKeeping extends CommonObject $this->piece_num = 0; // First check if line not yet already in bookkeeping. - // Note that we must include doc_type - fk_doc - numero_compte - label to be sure to have unicity of line (we may have several lines + // Note that we must include 'doc_type - fk_doc - numero_compte - label' to be sure to have unicity of line (because we may have several lines // with same doc_type, fk_doc, numero_compte for 1 invoice line when using localtaxes with same account) // WARNING: This is not reliable, label may have been modified. This is just a small protection. - // The page to make journalization make the test on couple doc_type - fk_doc only. + // The page that make transfer make the test on couple (doc_type - fk_doc) only. $sql = "SELECT count(*) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; $sql .= " AND fk_doc = ".$this->fk_doc; if (!empty($conf->global->ACCOUNTANCY_ENABLE_FKDOCDET)) { - // DO NOT USE THIS IN PRPDUCTION. This will generate a lot of trouble into reports and will corrupt database (by generating duplicate entries. - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines + // DO NOT USE THIS IN PRODUCTION. This will generate a lot of trouble into reports and will corrupt database (by generating duplicate entries. + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines } $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; $sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'"; - $sql .= " AND entity IN (".getEntity('accountancy').")"; + $sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_object($resql); - if ($row->nb == 0) { - // Determine piece_num + if ($row->nb == 0) { // Not already into bookkeeping + // Check to know if piece_num already exists for data we try to insert to reuse the same value $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sqlnum .= " WHERE doc_type = '".$this->db->escape($this->doc_type)."'"; // For example doc_type = 'bank' - $sqlnum .= " AND fk_docdet = ".$this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... + $sqlnum .= " AND fk_doc = ".$this->fk_doc; + if (!empty($conf->global->ACCOUNTANCY_ENABLE_FKDOCDET)) { + // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... + $sqlnum .= " AND fk_docdet = ".((int) $this->fk_docdet); + } $sqlnum .= " AND doc_ref = '".$this->db->escape($this->doc_ref)."'"; // ref of source object - $sqlnum .= " AND entity IN (".getEntity('accountancy').")"; + $sqlnum .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -327,15 +331,14 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; - $sqlnum .= " WHERE entity IN (".getEntity('accountancy').")"; + $sqlnum .= " WHERE entity = ".$conf->entity; // Do not use getEntity for accounting features - dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { $objnum = $this->db->fetch_object($resqlnum); $this->piece_num = $objnum->maxpiecenum; } - dol_syslog(get_class($this).":: create this->piece_num=".$this->piece_num, LOG_DEBUG); + dol_syslog(get_class($this).":: create now this->piece_num=".$this->piece_num, LOG_DEBUG); } if (empty($this->piece_num)) { $this->piece_num = 1; @@ -1121,6 +1124,12 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.subledger_label') { $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + } elseif ($key == 't.code_journal' && !empty($value)) { + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 6874aacb58a..d33f5e12312 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -170,7 +170,7 @@ if ($action == 'validatehistory') { while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); - $isBuyerInEEC = isInEEC($objp); + $isBuyerInEEC = isInEEC($objp); // This make a database request but there is a cache into $conf->cache['country_code_in_EEC'] // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding) $suggestedaccountingaccountfor = ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b8cc34c3cae..68d49793553 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -53,9 +53,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day = GETPOST("search_day", "int"); -$search_month = GETPOST("search_month", "int"); -$search_year = GETPOST("search_year", "int"); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -109,9 +114,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_amount = ''; $search_account = ''; $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_country = ''; $search_tvaintra = ''; } @@ -240,7 +250,12 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } -$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +if ($search_date_start) { + $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +} if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; @@ -315,14 +330,23 @@ if ($result) { if ($search_vat) { $param .= "&search_vat=".urlencode($search_vat); } - if ($search_day) { - $param .= '&search_day='.urlencode($search_day); + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); } - if ($search_month) { - $param .= '&search_month='.urlencode($search_month); + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } - if ($search_year) { - $param .= '&search_year='.urlencode($search_year); + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); } if ($search_country) { $param .= "&search_country=".urlencode($search_country); @@ -357,12 +381,13 @@ if ($result) { print ''; print ''; print ''; - print ''; print ''; //print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 678e5081937..4df8d6b9b15 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -59,9 +59,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day = GETPOST("search_day", "int"); -$search_month = GETPOST("search_month", "int"); -$search_year = GETPOST("search_year", "int"); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -135,9 +140,14 @@ if (empty($reshook)) { $search_amount = ''; $search_account = ''; $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_country = ''; $search_tvaintra = ''; } @@ -289,7 +299,12 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +if ($search_date_start) { + $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +} if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; @@ -368,14 +383,23 @@ if ($result) { if ($search_lineid) { $param .= '&search_lineid='.urlencode($search_lineid); } - if ($search_day) { - $param .= '&search_day='.urlencode($search_day); + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); } - if ($search_month) { - $param .= '&search_month='.urlencode($search_month); + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } - if ($search_year) { - $param .= '&search_year='.urlencode($search_year); + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); } if ($search_invoice) { $param .= '&search_invoice='.urlencode($search_invoice); @@ -436,12 +460,13 @@ if ($result) { print ''; print ''; print ''; - print ''; print ''; //print ''; @@ -450,7 +475,7 @@ if ($result) { print ''; print ''; print ''; print ''; @@ -687,8 +712,8 @@ if ($result) { print ''; // Found accounts - print ''; print ''; print ''; - print ''; print ''; print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index dda111856d3..63dd996a546 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s @@ -60,9 +60,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day = GETPOST("search_day", "int"); -$search_month = GETPOST("search_month", "int"); -$search_year = GETPOST("search_year", "int"); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -140,9 +145,14 @@ if (empty($reshook)) { $search_amount = ''; $search_account = ''; $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_country = ''; $search_tvaintra = ''; } @@ -293,7 +303,12 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +if ($search_date_start) { + $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +} if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; @@ -372,14 +387,23 @@ if ($result) { if ($search_lineid) { $param .= '&search_lineid='.urlencode($search_lineid); } - if ($search_day) { - $param .= '&search_day='.urlencode($search_day); + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); } - if ($search_month) { - $param .= '&search_month='.urlencode($search_month); + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } - if ($search_year) { - $param .= '&search_year='.urlencode($search_year); + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); } if ($search_invoice) { $param .= '&search_invoice='.urlencode($search_invoice); @@ -444,12 +468,13 @@ if ($result) { print ''; print ''; //print ''; - print ''; print ''; print ''; @@ -671,8 +696,8 @@ if ($result) { print ''; // Found accounts - print ''; } else { print ''; print ''; print ''; + print ''; print ''; print ''; print ''; @@ -283,6 +288,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->label = $objp->rowid; $membertype->status = $objp->status; $membertype->subscription = $objp->subscription; + $membertype->amount = $objp->amount; print ''; print ''; print ''; + print ''; print ''; print ''; if ($user->rights->adherent->configurer) { @@ -358,6 +365,10 @@ if ($action == 'create') { print $form->selectyesno("subscription", 1, 1); print ''; + print ''; + print ''; @@ -434,6 +445,10 @@ if ($rowid > 0) { print yn($object->subscription); print ''; + print ''; + print ''; @@ -496,13 +511,13 @@ if ($rowid > 0) { $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,"; $sql .= " d.datefin,"; $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut as status,"; - $sql .= " t.libelle as type, t.subscription"; + $sql .= " t.libelle as type, t.subscription, t.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid "; $sql .= " AND d.entity IN (".getEntity('adherent').")"; $sql .= " AND t.rowid = ".((int) $object->id); if ($sall) { - $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); + $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { $sql .= natural_search('d.statut', $status, 2); @@ -702,7 +717,7 @@ if ($rowid > 0) { print ''; } else { print ''; + print ''; + print ''; diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index e9e7f971575..5bc994bb086 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -210,7 +210,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = knowledgemanagementAdminPrepareHead(); -print dol_get_fiche_head($head, 'knowledgemanagement', $langs->trans('ModuleKnowledgeManagementName'), -1, "knowledgemanagement"); +print dol_get_fiche_head($head, 'setup', $langs->trans('ModuleKnowledgeManagementName'), -1, "knowledgemanagement"); // Setup page goes here echo ''.$langs->trans("KnowledgeManagementSetupPage").'

'; diff --git a/htdocs/admin/knowledgerecord_extrafields.php b/htdocs/admin/knowledgerecord_extrafields.php index 34d3b4858e9..823366e1fbe 100644 --- a/htdocs/admin/knowledgerecord_extrafields.php +++ b/htdocs/admin/knowledgerecord_extrafields.php @@ -103,7 +103,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); $head = knowledgemanagementAdminPrepareHead(); -print dol_get_fiche_head($head, 'knowledgerecord_extrafields', $langs->trans("KnowledgeRecordExtraFields"), -1, 'knowledgemanagement'); +print dol_get_fiche_head($head, 'extra', $langs->trans("KnowledgeRecordExtraFields"), -1, 'knowledgemanagement'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 3a479480812..373ab0e0f48 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -156,8 +156,9 @@ if ($resql) { $form = new Form($db); $page_name = "MultiCurrencySetup"; +$help_url = ''; -llxHeader('', $langs->trans($page_name)); +llxHeader('', $langs->trans($page_name), $help_url); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; @@ -165,7 +166,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = multicurrencyAdminPrepareHead(); -print dol_get_fiche_head($head, 'settings', $langs->trans("ModuleSetup"), -1, "multicurrency"); +print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "multicurrency"); print '
'; - print $langs->trans('From'); - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, '', 'accounts'); print ' '; - print $langs->trans('to'); - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, '', 'accounts'); print ''; $searchpicto = $form->showFilterButtons(); @@ -415,7 +425,8 @@ if ($action != 'export_csv') { } else { print ''.price(price2num($line->debit - $line->credit, 'MT')).''.$link; + print ''; + print $link; print '
'; print '
'; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 1); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 'account'); print '
'; print '
'; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 1); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 'account'); print '
'; print '
'; - print '
'; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $langs->trans('From').' '; - print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); + print '
'; + //print $langs->trans('From').' '; + print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount'); + print '
'; + print '
'; + print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount'); + print '
'; } else { - print ''; + print ''; } - print '
'; - print '
'; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not - // use setup of keypress to select thirdparty and this hang browser on large database. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $langs->trans('to').' '; - print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - } else { - print ''; - } - print '
'; print '
'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - $formother->select_year($search_year, 'search_year', 1, 20, 5); + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print '
'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - $formother->select_year($search_year, 'search_year', 1, 20, 5); + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print '
'; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); + print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1, null, 1); //print ''; print ''.$objp->tva_intra.''; - $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + print ''; + $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); @@ -699,7 +724,7 @@ if ($result) { print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountfor == 'eec') { $shelp = $langs->trans("SaleEEC"); @@ -716,7 +741,7 @@ if ($result) { } else { if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; $s .= $langs->trans("NotDefined"); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); @@ -724,7 +749,7 @@ if ($result) { } if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { print '
'; - $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; + $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; $shelp = ''; $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").''); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index e3e2a308cf9..76984d55fba 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -120,7 +120,8 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; -$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,"; +$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, u.statut as userstatus,"; +$sql .= " bu2.type as typeop_user,"; $sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " JOIN ".MAIN_DB_PREFIX."bank_account as ba on b.fk_account=ba.rowid"; @@ -259,7 +260,8 @@ if ($result) { 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'email' => $obj->useremail, - 'accountancy_code' => $compta_user + 'accountancy_code' => $compta_user, + 'status' => $obj->userstatus ); // Variable bookkeeping ($obj->rowid is Bank Id) @@ -328,8 +330,10 @@ if ($result) { $userstatic->email = $tabuser[$obj->rowid]['email']; $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; + $userstatic->statut = $tabuser[$obj->rowid]['status']; + $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; if ($userstatic->id > 0) { - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); } else { $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. } @@ -507,6 +511,18 @@ var_dump($tabtype);*/ if (!$error && $action == 'writebookkeeping') { $now = dol_now(); + $accountingaccountcustomer = new AccountingAccount($db); + $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); + + $accountingaccountsupplier = new AccountingAccount($db); + $accountingaccountsupplier->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); + + $accountingaccountpayment = new AccountingAccount($db); + $accountingaccountpayment->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); + + $accountingaccountsuspense = new AccountingAccount($db); + $accountingaccountsuspense->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE, true); + $error = 0; foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank $date = dol_print_date($db->jdate($val["date"]), 'day'); @@ -530,6 +546,9 @@ if (!$error && $action == 'writebookkeeping') { // Line into bank account foreach ($tabbq[$key] as $k => $mt) { if ($mt) { + $accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch + $account_label = $accountingaccount->label; + $reflabel = ''; if (!empty($val['lib'])) { $reflabel .= dol_string_nohtmltag($val['lib'])." - "; @@ -545,10 +564,9 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->doc_type = 'bank'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->numero_compte = $k; - $accountingaccount->fetch(null, $k, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $account_label; $bookkeeping->label_operation = $reflabel; $bookkeeping->montant = $mt; @@ -606,6 +624,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->doc_type = 'bank'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->label_operation = $reflabel; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; @@ -620,78 +639,63 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - - $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $accountingaccountcustomer->label; } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - - $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $accountingaccountsupplier->label; } elseif ($tabtype[$key] == 'payment_expensereport') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - - $accountingaccount->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $accountingaccountpayment->label; } elseif ($tabtype[$key] == 'payment_salary') { $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - - $accountingaccount->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $accountingaccountpayment->label; } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_vat') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_donation') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'member') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_loan') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = $k; $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; - - $accountingaccount->fetch(null, $bookkeeping->numero_compte, true); $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'banktransfert') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $accountingaccount->fetch(null, $k, true); // TODO Use a cache $bookkeeping->numero_compte = $k; - - $accountingaccount->fetch(null, $k, true); $bookkeeping->label_compte = $accountingaccount->label; } else { if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. @@ -699,9 +703,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; - - $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = $accountingaccountsuspense->label; } } $bookkeeping->label_operation = $reflabel; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 2916d4d1fca..0273690ae81 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -206,6 +206,9 @@ if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; + $accountingaccountexpense = new AccountingAccount($db); + $accountingaccountexpense->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); + foreach ($taber as $key => $val) { // Loop on each expense report $errorforline = 0; @@ -225,12 +228,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $accountingaccount->fetch(null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = $accountingaccountexpense->label; $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->montant = $mt; @@ -274,10 +277,13 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_operation = $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -322,6 +328,9 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { + $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $account_label = $accountingaccount->label; + // get compte id and label $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -330,12 +339,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $account_label; $bookkeeping->label_operation = $langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'; $bookkeeping->montant = $mt; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 018cba4ca89..2677f8569f2 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -248,7 +248,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; - $sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key; + $sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".((int) $key); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -270,6 +270,9 @@ if ($action == 'writebookkeeping') { $companystatic = new Societe($db); $invoicestatic = new FactureFournisseur($db); + $accountingaccountsupplier = new AccountingAccount($db); + + $accountingaccountsupplier->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -331,12 +334,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; - $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + $bookkeeping->label_compte = $accountingaccountsupplier->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount"); $bookkeeping->montant = $mt; @@ -371,8 +374,11 @@ if ($action == 'writebookkeeping') { // Product / Service if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { + $resultfetch = $accountingaccount->fetch(null, $k, true); // TODO Use a cache + $label_account = $accountingaccount->label; + // get compte id and label - if ($accountingaccount->fetch(null, $k, true)) { + if ($resultfetch > 0) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; @@ -382,11 +388,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$accountingaccount->label; + $bookkeeping->label_compte = $label_account; + + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$label_account; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -432,6 +441,9 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { + $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $label_account = $accountingaccount->label; + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; @@ -441,12 +453,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $label_account; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); $bookkeeping->montant = $mt; @@ -494,9 +506,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' NPR'; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index a9b6f17a9bd..d147186a8d8 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -148,7 +148,7 @@ if ($in_bookkeeping == 'notyet') { // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } $sql .= " ORDER BY f.datef"; -//print $sql; +//print $sql; exit; dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); $result = $db->query($sql); @@ -264,7 +264,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; - $sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key; + $sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".((int) $key); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -285,6 +285,9 @@ if ($action == 'writebookkeeping') { $companystatic = new Societe($db); $invoicestatic = new Facture($db); + $accountingaccountcustomer = new AccountingAccount($db); + + $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -344,12 +347,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $accountingaccount->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = $accountingaccountcustomer->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount"); $bookkeeping->montant = $mt; @@ -384,8 +387,11 @@ if ($action == 'writebookkeeping') { // Product / Service if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { + $resultfetch = $accountingaccount->fetch(null, $k, true); // TODO Use a cache + $label_account = $accountingaccount->label; + // get compte id and label - if ($accountingaccount->fetch(null, $k, true)) { + if ($resultfetch > 0) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; @@ -395,11 +401,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $accountingaccount->label; - $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$accountingaccount->label; + $bookkeeping->label_compte = $label_account; + + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$label_account; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? -$mt : 0; @@ -444,6 +453,9 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { + $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $label_account = $accountingaccount->label; + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->date_lim_reglement = $val["datereg"]; @@ -453,12 +465,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; + $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->numero_compte = $k; - $accountingaccount->fetch($k, null, true); - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $label_account; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); $bookkeeping->montant = $mt; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index deed1299fd5..90e7213c8f9 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -54,9 +54,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day = GETPOST("search_day", "int"); -$search_month = GETPOST("search_month", "int"); -$search_year = GETPOST("search_year", "int"); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -112,9 +117,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_amount = ''; $search_account = ''; $search_vat = ''; - $search_day = ''; - $search_month = ''; - $search_year = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_country = ''; $search_tvaintra = ''; } @@ -234,7 +244,12 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +if ($search_date_start) { + $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'"; +} if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; @@ -315,14 +330,23 @@ if ($result) { if ($search_vat) { $param .= "&search_vat=".urlencode($search_vat); } - if ($search_day) { - $param .= '&search_day='.urlencode($search_day); + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); } - if ($search_month) { - $param .= '&search_month='.urlencode($search_month); + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } - if ($search_year) { - $param .= '&search_year='.urlencode($search_year); + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); } if ($search_country) { $param .= "&search_country=".urlencode($search_country); @@ -359,12 +383,13 @@ if ($result) { print '
'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - $formother->select_year($search_year, 'search_year', 1, 20, 5); + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print '
'; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - $formother->select_year($search_year, 'search_year', 1, 20, 5); + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; print '
'.$objp->tva_intra.''; - $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + print ''; + $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); @@ -683,7 +708,7 @@ if ($result) { print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') { $shelp = $langs->trans("SaleEEC"); @@ -694,13 +719,13 @@ if ($result) { print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } else { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; $s .= $langs->trans("NotDefined"); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '
'; - $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; + $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; $shelp = ''; $s .= ($objp->code_buy_t > 0 ? length_accountg($objp->code_buy_t) : ''.$langs->trans("NotDefined").''); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 62291791fc5..32476f137a8 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -9,7 +9,6 @@ * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2020-2021 Frédéric France - * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +33,6 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "members")); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index d051c40810b..2ffc1e2c9fd 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * 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 @@ -89,6 +89,11 @@ class AdherentType extends CommonObject */ public $subscription; + /** + * @var float amount for subscription + */ + public $amount; + /** @var string Public note */ public $note; @@ -361,6 +366,7 @@ class AdherentType extends CommonObject $sql .= "libelle = '".$this->db->escape($this->label)."',"; $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; + $sql .= "amount = '".$this->db->escape($this->amount)."',"; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; $sql .= "note = '".$this->db->escape($this->note)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; @@ -455,7 +461,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -475,6 +481,7 @@ class AdherentType extends CommonObject $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; + $this->amount = $obj->amount; $this->mail_valid = $obj->mail_valid; $this->note = $obj->note; $this->vote = $obj->vote; @@ -535,6 +542,45 @@ class AdherentType extends CommonObject return $adherenttypes; } + /** + * Return list of amount by type id + * + * @param int $status Filter on status of type + * @return array List of types of members + */ + public function amountByType($status = null) + { + + global $conf, $langs; + + $amountbytype = array(); + + $sql = "SELECT rowid, amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql .= " WHERE entity IN (".getEntity('member_type').")"; + if ($status !== null) { + $sql .= " AND statut = ".((int) $status); + } + + $resql = $this->db->query($sql); + if ($resql) { + $nump = $this->db->num_rows($resql); + + if ($nump) { + $i = 0; + while ($i < $nump) { + $obj = $this->db->fetch_object($resql); + + $amountbytype[$obj->rowid] = $obj->amount; + $i++; + } + } + } else { + print $this->db->error(); + } + return $amountbytype; + } + /** * Return array of Member objects for member type this->id (or all if this->id not defined) * diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 68d161d0cf1..5573961456f 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -240,7 +240,7 @@ class Members extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 5ab9ad8eead..b02a81dc5c9 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -105,7 +105,7 @@ class MembersTypes extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 3758885c4a3..831be2882f1 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -103,7 +103,7 @@ class Subscriptions extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index b713362912e..775c0d25c81 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1063,7 +1063,7 @@ while ($i < min($num, $limit)) { print '
'; - if ($obj->subscription == 'yes') { + if (!empty($obj->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($obj->statut > 0) { print " ".img_warning(); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c9b98784142..6c4f63725e1 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -7,6 +7,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2019 Thibault Foucart * Copyright (C) 2020 Josep Lluís Amador + * Copyright (C) 2021 Waël Almoman * * 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 @@ -70,6 +71,7 @@ $label = GETPOST("label", "alpha"); $morphy = GETPOST("morphy", "alpha"); $status = GETPOST("status", "int"); $subscription = GETPOST("subscription", "int"); +$amount = price2num(GETPOST('amount', 'alpha'), 'MT'); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); $vote = GETPOST("vote", "int"); @@ -114,14 +116,15 @@ if ($cancel) { if ($action == 'add' && $user->rights->adherent->configurer) { $object->label = trim($label); - $object->morphy = trim($morphy); - $object->status = (int) $status; - $object->subscription = (int) $subscription; - $object->duration_value = $duration_value; - $object->duration_unit = $duration_unit; - $object->note = trim($comment); + $object->morphy = trim($morphy); + $object->status = (int) $status; + $object->subscription = (int) $subscription; + $object->amount = $amount; + $object->duration_value = $duration_value; + $object->duration_unit = $duration_unit; + $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (int) $vote; + $object->vote = (int) $vote; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -164,15 +167,16 @@ if ($action == 'update' && $user->rights->adherent->configurer) { $object->oldcopy = clone $object; - $object->label = trim($label); - $object->morphy = trim($morphy); - $object->status = (int) $status; + $object->label= trim($label); + $object->morphy = trim($morphy); + $object->status = (int) $status; $object->subscription = (int) $subscription; - $object->duration_value = $duration_value; - $object->duration_unit = $duration_unit; - $object->note = trim($comment); + $object->amount = $amount; + $object->duration_value = $duration_value; + $object->duration_unit = $duration_unit; + $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -222,7 +226,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), $help_url); if (!$rowid && $action != 'create' && $action != 'edit') { //print dol_get_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -268,6 +272,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''.$langs->trans("Label").''.$langs->trans("MembersNature").''.$langs->trans("SubscriptionRequired").''.$langs->trans("Amount").''.$langs->trans("VoteAllowed").''.$langs->trans("Status").' 
'; @@ -300,6 +306,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { } print ''.yn($objp->subscription).''.price($objp->amount).''.yn($objp->vote).''.$membertype->getLibStatut(5).'
'.$langs->trans("Amount").''; + print ''; + print '
'.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1); print '
'.$langs->trans("Amount").''; + print price($object->amount); + print '
'.$langs->trans("VoteAllowed").''; print yn($object->vote); print '
'; - if ($objp->subscription == 'yes') { + if (!empty($objp->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($objp->status > 0) { print " ".img_warning(); @@ -781,6 +796,10 @@ if ($rowid > 0) { print $form->selectyesno("subscription", $object->subscription, 1); print '
'.$langs->trans("Amount").''; + print ''; + print '
'.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote", $object->vote, 1); print '
'; @@ -303,7 +304,7 @@ print ''; print ''; print ''; print ''; print ''; @@ -328,7 +329,7 @@ foreach ($TCurrency as &$currency) { print ''; print ''; print '1 '.$conf->currency.' = '; - print ' '.$currency->code.' '; + print ' '.$currency->code.' '; print ' '; print ''; print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index a5c2770a9c4..7d7b5e36a40 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks')); +$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips')); if (!$user->admin) { accessforbidden(); @@ -161,6 +161,10 @@ if (class_exists('TCPDI')) { print load_fiche_titre($langs->trans("PDF"), '', 'title_setup'); +$head = pdf_admin_prepare_head(); + +print dol_get_fiche_head($head, 'general', $langs->trans("PDF"), -1, 'pdf'); + print ''.$form->textwithpicto($langs->trans("PDFDesc"), $s)."
\n"; print "
\n"; @@ -178,7 +182,7 @@ print load_fiche_titre($langs->trans("DictionaryPaperFormat"), '', ''); print '
'; print '
'.$form->selectCurrency('', 'code', 1).''; -print ' '; +print ' '; print ''; print '
'; -print ''; +print ''; $selected = (isset($conf->global->MAIN_PDF_FORMAT) ? $conf->global->MAIN_PDF_FORMAT : ''); if (empty($selected)) { @@ -215,12 +219,16 @@ print load_fiche_titre($langs->trans("PDFAddressForging"), '', ''); print '
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; -print ''; +print ''; // Hide VAT Intra on address print ''; // Show prof id in address into pdf @@ -236,7 +244,11 @@ for ($i = 1; $i <= 6; $i++) { if ($pid) { print ''; } } @@ -254,16 +266,24 @@ $text = ''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1", $mysoc->country_code); - $text = ''; } if ($mysoc->useLocalTax(2)) { $locales .= ($locales ? ' & ' : '').$langs->transcountry("LT2", $mysoc->country_code); - $text .= ''; } } @@ -273,15 +293,20 @@ if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { $title .= ' - '.$langs->trans("PDFLocaltax", $locales); } + print load_fiche_titre($title, '', ''); print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("ShowVATIntaInAddress").''; -print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_TVAINTRA_NOT_IN_ADDRESS'); +} else { + print $form->selectyesno('MAIN_TVAINTRA_NOT_IN_ADDRESS', (!empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) ? $conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS : 0, 1); +} print '
'.$langs->trans("ShowProfIdInAddress").' - '.$pid.''; $keyforconstant = 'MAIN_PROFID'.$i.'_IN_ADDRESS'; - print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); + if ($conf->use_javascript_ajax) { + print ajax_constantonoff($keyforconstant); + } else { + print $form->selectyesno($keyforconstant, isset($conf->global->$keyforconstant) ? $conf->global->$keyforconstant : 0, 1, $noCountryCode); + } print '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).''; - $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); + $text = '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT1", $mysoc->country_code)).''; + if ($conf->use_javascript_ajax) { + $text .= ajax_constantonoff('MAIN_PDF_MAIN_HIDE_SECOND_TAX'); + } else { + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_SECOND_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX : 0, 1); + } $text .= '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).''; - $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); + $text .= '
'.$langs->trans("HideLocalTaxOnPDF", $langs->transcountry("LT2", $mysoc->country_code)).''; + if ($conf->use_javascript_ajax) { + $text .= ajax_constantonoff('MAIN_PDF_MAIN_HIDE_THIRD_TAX'); + } else { + $text .= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); + } $text .= '
'; -print ''; +print ''; // Hide any information on Sale tax / VAT print ''; // Locataxes @@ -317,13 +342,21 @@ if (!empty($conf->projet->enabled)) { //Invert sender and recipient print ''; // Place customer adress to the ISO location print ''; // Use 2 languages into PDF @@ -341,25 +374,41 @@ print ''; //Desc print ''; //Ref print ''; //Details print ''; // SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits. print ''; // Show more details in footer diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php new file mode 100644 index 00000000000..8a757a7d34c --- /dev/null +++ b/htdocs/admin/pdf_other.php @@ -0,0 +1,125 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2012-2107 Juanjo Menent + * Copyright (C) 2019 Ferran Marcet + * Copyright (C) 2021 Anthony Berton + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/admin/pdf.php + * \brief Page to setup PDF options + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'stocks', 'Trips')); + +if (!$user->admin) { + accessforbidden(); +} + +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); + + +/* + * Actions + */ + +if ($cancel) { + $action = ''; +} + +if ($action == 'update') { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); + exit; +} + + + +/* + * View + */ + +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +llxHeader('', $langs->trans("Setup"), $wikihelp); + +$form = new Form($db); +$formother = new FormOther($db); +$formadmin = new FormAdmin($db); + +print load_fiche_titre($langs->trans("PDF"), '', 'title_setup'); + +$head = pdf_admin_prepare_head(); + +print dol_get_fiche_head($head, 'other', $langs->trans("other"), -1, 'pdf'); + +print ''.$form->textwithpicto($langs->trans("PDFOtherDesc"), $s)."
\n"; +print "
\n"; + +print load_fiche_titre($langs->trans("Proposal"), '', ''); + +print '
'; +print ''; +print ''; + +print '
'; +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT'); +} else { + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT : 0, 1); +} print '
'.$langs->trans("SwapSenderAndRecipientOnPDF").''; -print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_INVERT_SENDER_RECIPIENT'); +} else { + print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1); +} print '
'.$langs->trans("PlaceCustomerAddressToIsoLocation").''; -print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_USE_ISO_LOCATION'); +} else { + print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1); +} print '
'.$langs->trans("HideDescOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_HIDE_DESC'); +} else { + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC : 0, 1); +} print '
'.$langs->trans("HideRefOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_HIDE_REF'); +} else { + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF : 0, 1); +} print '
'.$langs->trans("HideDetailsOnPDF").''; -print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS'); +} else { + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS)) ? $conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS : 0, 1); +} print '
'.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).''; -print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SHOW_SUBPRODUCT_REF_IN_PDF'); +} else { + print $form->selectyesno('SHOW_SUBPRODUCT_REF_IN_PDF', (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) ? $conf->global->SHOW_SUBPRODUCT_REF_IN_PDF : 0, 1); +} print '
'; +print ''; + +print ''; + +print ''; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_GENERATE_PROPOSALS_WITH_PICTURE", $arrval, $conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE); +} +print '
'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING", $arrval, $conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING); +} +print '
'; +print ''; + + +print '
'; +print ''; +print '
'; + +print ''; + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 2796f09fbfd..f3892e105bb 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -134,7 +134,7 @@ foreach ($modules as $key => $module) { $newModule->name = $module->getName(); $newModule->version = $module->getVersion(); $newModule->id = $key; - $newModule->module_position = $module->module_position; + $newModule->module_position = $module->getModulePosition(); $alt = $module->name.' - '.$modules_files[$key]; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index c760903aca4..7a9dd908a59 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -309,8 +309,9 @@ class DolibarrApi /** * Function to forge a SQL criteria * - * @param array $matches Array of found string by regex search. Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.nature:is:NULL" - * @return string Forged criteria. Example: "t.field like 'abc%'" + * @param array $matches Array of found string by regex search. + * Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.date_creation:<:'2016-01-01 12:30:00'" or "t.nature:is:NULL" + * @return string Forged criteria. Example: "t.field like 'abc%'" */ protected static function _forge_criteria_callback($matches) { @@ -321,18 +322,26 @@ class DolibarrApi if (empty($matches[1])) { return ''; } - $tmp = explode(':', $matches[1]); + $tmp = explode(':', $matches[1], 3); + if (count($tmp) < 3) { return ''; } - $tmpescaped = $tmp[2]; + $operand = preg_replace('/[^a-z0-9\._]/i', '', trim($tmp[0])); + + $operator = strtoupper(preg_replace('/[^a-z<>=]/i', '', trim($tmp[1]))); + + $tmpescaped = trim($tmp[2]); $regbis = array(); - if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { + if ($operator == 'IN') { + $tmpescaped = "(".$db->sanitize($tmpescaped, 1).")"; + } elseif (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { $tmpescaped = "'".$db->escape($regbis[1])."'"; } else { - $tmpescaped = $db->escape($tmpescaped); + $tmpescaped = $db->sanitize($db->escape($tmpescaped)); } - return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + + return $db->escape($operand).' '.$db->escape($operator)." ".$tmpescaped; } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index ceaf5f8f7d8..acd39361842 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -79,7 +79,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -142,7 +142,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -206,7 +206,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -270,7 +270,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -370,7 +370,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -545,7 +545,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -660,7 +660,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -723,7 +723,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -790,7 +790,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -852,7 +852,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -924,7 +924,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -994,7 +994,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1067,7 +1067,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1131,7 +1131,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1189,7 +1189,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1248,7 +1248,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1313,7 +1313,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1371,7 +1371,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1429,7 +1429,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1489,7 +1489,7 @@ class Setup extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index cc91182293e..ba164e3e715 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -55,8 +55,10 @@ $blocks = $block_static->getLog('just_certified', 0, 0, 'rowid', 'ASC'); $auth->signature = $block_static->getSignature(); -foreach ($blocks as &$b) { - $auth->blockchain .= $b->signature; +if (is_array($bocks)) { + foreach ($blocks as &$b) { + $auth->blockchain .= $b->signature; + } } $hash = $auth->getBlockchainHash(); diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 2071eb03c47..4ec3fc6d07e 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -71,8 +71,10 @@ class BlockedLogAuthority $this->blockchain = ''; - foreach ($blocks as &$b) { - $this->blockchain .= $b->signature; + if (is_array($bocks)) { + foreach ($blocks as &$b) { + $this->blockchain .= $b->signature; + } } return $this->blockchain; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index ae35eae14f4..ebc2045aca3 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -572,10 +572,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); } } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 1fe104987a3..0eeefda9b3d 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -151,7 +151,7 @@ class Boms extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 65483a561af..158627e274c 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -148,7 +148,7 @@ class Categories extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 322a688bd45..f368378a281 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1170,6 +1170,7 @@ if ($action == 'create') { if (GETPOST('contactid', 'int')) { $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); } + if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); print img_picto('', 'contact', 'class="paddingrightonly"'); print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index c2961db7bbb..fd57dd3c81b 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -161,7 +161,7 @@ class AgendaEvents extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 44e2ad8a4cd..229303849f0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -302,9 +302,26 @@ if (empty($reshook)) { } } elseif ($action == 'setecheance' && $usercancreate) { $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) { - dol_print_error($db, $object->error); + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + if ($ret > 0) { + $object->fetch_thirdparty(); + } + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setdate_livraison' && $usercancreate) { $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); @@ -2457,10 +2474,12 @@ if ($action == 'create') { if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } else { $parameters = array(); $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 3c3447f3697..e4b9a266198 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -199,7 +199,7 @@ class Proposals extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1b82bc0c20f..f63b02c035e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2442,11 +2442,13 @@ if ($action == 'create' && $usercancreate) { if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } } print ''; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 763fb061446..745fea5ab76 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -202,7 +202,7 @@ class Orders extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 762bcc506da..10357155295 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -84,7 +84,7 @@ class BankAccounts extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -441,7 +441,7 @@ class BankAccounts extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index c607f0f922c..f45d2a64af4 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -179,8 +179,8 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank'; - $sqlupdate .= ' SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.((int) $id); + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."bank SET num_releve = '".$db->escape($newbankreceipt)."'"; + $sqlupdate .= " WHERE num_releve = '".$db->escape($oldbankreceipt)."' AND fk_account = ".((int) $id); $result = $db->query($sqlupdate); if ($result < 0) { dol_print_error($db); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 203ed7002be..9341197c312 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1620,10 +1620,12 @@ if ($action == 'create') { if ($object->statut == $object::STATUS_DRAFT && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8164ece1327..252b8ac65a2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5193,10 +5193,12 @@ if ($action == 'create') { if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') { if ($action != 'editline' && $action != 'selectlines') { // Add free products/services - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index a8f640a61ec..84b4df207a5 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -224,7 +224,7 @@ class Invoices extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index cbe9f7e0a42..e33ddc35610 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -102,9 +102,11 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); print '
'; -print getCustomerInvoicePieChart($socid); +//print getCustomerInvoicePieChart($socid); +print getNumberInvoicesPieChart('customers'); print '
'; -print getPurchaseInvoicePieChart($socid); +print getNumberInvoicesPieChart('fourn'); +//print getPurchaseInvoicePieChart($socid); print '
'; print getCustomerInvoiceDraftTable($max, $socid); print '
'; diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index ba8c9b2a82f..492404a9380 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -111,31 +111,14 @@ print '
'; clearstatcache(); // Show link on other years -$linkforyear = array(); -$found = 0; -if (is_dir($dir)) { - $handle = opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) { - $found = 1; - $linkforyear[] = $file; - } - } - } -} -asort($linkforyear); -foreach ($linkforyear as $cursoryear) { - print ''.$cursoryear.'  '; +$year_dirs = dol_dir_list($dir, 'directories', 0, '^[0-9]{4}$', '', 'DESC'); +foreach ($year_dirs as $d) { + print ''.$d['name'].'  '; } if ($year) { if (is_dir($dir.'/'.$year)) { - $handle = opendir($dir.'/'.$year); - - if ($found) { - print '
'; - } + if (!empty($year_dirs)) print '
'; print '
'; print ''; print ''; @@ -144,19 +127,14 @@ if ($year) { print ''; print ''; - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^payment/i', $file)) { - $tfile = $dir.'/'.$year.'/'.$file; - $relativepath = $year.'/'.$file; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - closedir($handle); + $files = (dol_dir_list($dir.'/'.$year, 'files', 0, '^payments-[0-9]{4}-[0-9]{2}\.pdf$', '', 'name', 'DESC', 1)); + foreach ($files as $f) { + $relativepath = $f['level1name'].'/'.$f['name']; + print ''; + print ''; + print ''; + print ''; + print ''; } print '
'.$langs->trans("Date").'
'.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''.dol_print_size(dol_filesize($tfile)).''.dol_print_date(dol_filemtime($tfile), "dayhour").'
'.img_pdf().' '.$f['name'].''.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).''.dol_print_size($f['size']).''.dol_print_date($f['date'], "dayhour").'
'; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c925dea94bf..05c7436c22e 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1981,10 +1981,12 @@ if ($action == 'create') { } // Add free products/services - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } print ''; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index c52aeeb30e8..ea7886f022c 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -150,7 +150,7 @@ class Contracts extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index f47e8d40238..d7ae1566a44 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -198,7 +198,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text' => price2num($objp->total_stock, 'MS').' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2ca0bf6b439..49c7d728f3b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1345,7 +1345,10 @@ class ExtraFields } $out .= ''; } elseif ($type == 'checkbox') { - $value_arr = explode(',', $value); + $value_arr = $value; + if (!is_array($value)) { + $value_arr = explode(',', $value); + } $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') { $out = ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 044ba439922..625e8e23d57 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -868,9 +868,10 @@ class Form * @param int $disablefavorites 1=Disable favorites, * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) * @param array $exclude_country_code Array of country code (iso2) to exclude + * @param int $hideflags Hide flags * @return string HTML string with select */ - public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array()) + public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array(), $hideflags = 0) { // phpcs:enable global $conf, $langs, $mysoc; @@ -955,8 +956,10 @@ class Form } if ($row['code_iso']) { $labeltoshow .= ' ('.$row['code_iso'].')'; - $tmpflag = picto_from_langcode($row['code_iso'], 'class="saturatemedium marginrightonly"'); - $labeltoshow = $tmpflag.' '.$labeltoshow; + if (empty($hideflags)) { + $tmpflag = picto_from_langcode($row['code_iso'], 'class="saturatemedium marginrightonly"'); + $labeltoshow = $tmpflag.' '.$labeltoshow; + } } if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label'])) { @@ -6791,7 +6794,7 @@ class Form { throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter); }*/ - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")"; } } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index afbda03be8e..a57e39f1779 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -32,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; */ class FormAccounting extends Form { - private $options_cache = array(); /** @@ -87,7 +86,7 @@ class FormAccounting extends Form $sql .= " WHERE active = 1"; $sql .= " AND entity = ".$conf->entity; if ($nature && is_numeric($nature)) { - $sql .= " AND nature = ".$nature; + $sql .= " AND nature = ".((int) $nature); } $sql .= " ORDER BY code"; @@ -167,7 +166,7 @@ class FormAccounting extends Form $sql .= " WHERE active = 1"; $sql .= " AND entity = ".$conf->entity; if ($nature && is_numeric($nature)) { - $sql .= " AND nature = ".$nature; + $sql .= " AND nature = ".((int) $nature); } $sql .= " ORDER BY code"; @@ -435,67 +434,77 @@ class FormAccounting extends Form /** * Return list of auxilary accounts. Cumulate list from customers, suppliers and users. * - * @param string $selectid Preselected pcg_type - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param string $morecss More css - * @return string String with HTML select + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int|string $showempty Add an empty field + * @param string $morecss More css + * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. + * @return string String with HTML select */ - public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250') + public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250', $usecache = '') { // phpcs:enable $aux_account = array(); - // Auxiliary thirdparties account - $sql = "SELECT code_compta, code_compta_fournisseur, nom as name"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE entity IN (".getEntity('societe').")"; - $sql .= " AND client IN (1,3) OR fournisseur = 1"; - - dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - if (!empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->name.')'; - } - if (!empty($obj->code_compta_fournisseur)) { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->name.')'; - } - } + if ($usecache && !empty($this->options_cache[$usecache])) { + $aux_account = $aux_account + $this->options_cache[$usecache]; // We use + instead of array_merge because we don't want to reindex key from 0 } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); - return -1; - } + dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); - ksort($aux_account); + // Auxiliary thirdparties account + $sql = "SELECT code_compta, code_compta_fournisseur, nom as name"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE entity IN (".getEntity('societe').")"; + $sql .= " AND client IN (1,3) OR fournisseur = 1"; - $this->db->free($resql); - - // Auxiliary user account - $sql = "SELECT DISTINCT accountancy_code, lastname, firstname "; - $sql .= " FROM ".MAIN_DB_PREFIX."user"; - $sql .= " WHERE entity IN (".getEntity('user').")"; - $sql .= " ORDER BY accountancy_code"; - dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - if (!empty($obj->accountancy_code)) { - $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->code_compta)) { + $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->name.')'; + } + if (!empty($obj->code_compta_fournisseur)) { + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->name.')'; + } } + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); + return -1; + } + + ksort($aux_account); + + $this->db->free($resql); + + // Auxiliary user account + $sql = "SELECT DISTINCT accountancy_code, lastname, firstname "; + $sql .= " FROM ".MAIN_DB_PREFIX."user"; + $sql .= " WHERE entity IN (".getEntity('user').")"; + $sql .= " ORDER BY accountancy_code"; + + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->accountancy_code)) { + $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; + } + } + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); + return -1; + } + $this->db->free($resql); + + if ($usecache) { + $this->options_cache[$usecache] = $aux_account; } - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); - return -1; } - $this->db->free($resql); // Build select - $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, ($showempty ? (is_numeric($showempty) ? 1 : $showempty): 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index b9ba7b96efc..66ceae8a198 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -519,7 +519,7 @@ function dolibarr_del_const($db, $name, $entity = 1) } $sql .= ")"; if ($entity >= 0) { - $sql .= " AND entity = ".$entity; + $sql .= " AND entity = ".((int) $entity); } dol_syslog("admin.lib::dolibarr_del_const", LOG_DEBUG); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index d197b687876..99bcd2c3921 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -754,7 +754,7 @@ function isInEEC($object) return false; } - $country_code_in_EEC = getCountriesInEEC(); + $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC'] //print "dd".$object->country_code; return in_array($object->country_code, $country_code_in_EEC); @@ -939,11 +939,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.email', ); //Social media - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; - } - } + // foreach ($socialnetworks as $key => $value) { + // if ($value['active']) { + // $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; + // } + // } if (!$sortorder) { $sortorder = "ASC"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4239ff4bafe..e5d7acbd250 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3517,7 +3517,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'folder-plus', 'globe', 'globe-americas', 'graph', 'grip', 'grip_title', 'group', 'help', 'holiday', - 'images', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement', + 'images', 'incoterm', 'info', 'intervention', 'inventory', 'intracommreport', 'knowledgemanagement', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'off', 'on', 'order', @@ -3553,7 +3553,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'search-dollar', 'category'=>'tag', 'dollyrevert'=>'dolly', - 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', + 'hrm'=>'user-tie', 'incoterm'=>'truck-loading', + 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', 'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'generic'=>'file', 'holiday'=>'umbrella-beach', @@ -3635,9 +3636,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande', 'conferenceorbooth'=>'infobox-project', 'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'collab'=>'infobox-action', 'conversation'=>'infobox-contrat', - 'donation'=>'infobox-commande', 'dollyrevert'=>'flip', + 'donation'=>'infobox-commande', 'dolly'=>'infobox-commande', 'dollyrevert'=>'flip infobox-order_supplier', 'ecm'=>'infobox-action', 'eventorganization'=>'infobox-project', 'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat', + 'incoterm'=>'infobox-supplier_proposal', 'multicurrency'=>'infobox-bank_account', 'members'=>'infobox-adherent', 'member'=>'infobox-adherent', 'money-bill-alt'=>'infobox-bank_account', 'order'=>'infobox-commande', @@ -3648,7 +3650,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', 'reception'=>'flip', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', - 'salary'=>'infobox-bank_account', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', + 'salary'=>'infobox-bank_account', 'shipment'=>'infobox-commande', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier', 'supplier_order'=>'infobox-order_supplier', 'supplier_proposal'=>'infobox-supplier_proposal', 'ticket'=>'infobox-contrat', 'title_accountancy'=>'infobox-bank_account', 'title_hrm'=>'infobox-holiday', 'expensereport'=>'infobox-expensereport', 'trip'=>'infobox-expensereport', 'title_agenda'=>'infobox-action', //'title_setup'=>'infobox-action', 'tools'=>'infobox-action', @@ -3664,11 +3666,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'cron'=>'#555', 'dynamicprice'=>'#a69944', 'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555', - 'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', 'lot'=>'#a69944', + //'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', + 'lot'=>'#a69944', 'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'inventory'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944', 'other'=>'#ddd', 'partnership'=>'#6c6aa8', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'reception'=>'#a69944', 'resize'=>'#444', 'rss'=>'#cba', - 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', + //'shipment'=>'#a69944', + 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uncheck'=>'#800', 'uparrow'=>'#555', 'user-cog'=>'#999', 'country'=>'#aaa', 'globe-americas'=>'#aaa', 'website'=>'#304', 'workstation'=>'#a69944' ); diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 25833df624f..0a0ebe3ce02 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -182,10 +182,13 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image + $infoImg = getimagesize($filetoread); // Get data about src image $imgWidth = $infoImg[0]; // Largeur de l'image $imgHeight = $infoImg[1]; // Hauteur de l'image + $imgTargetName = ($filetowrite ? $filetowrite : $file); + $newExt = strtolower(pathinfo($imgTargetName, PATHINFO_EXTENSION)); + if ($mode == 0) { // If resize, we check parameters if (!empty($filetowrite) && $filetowrite != $file && $newWidth <= 0 && $newHeight <= 0) { $newWidth = $imgWidth; @@ -200,6 +203,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } } + // Test function to read source image exists $imgfonction = ''; switch ($infoImg[2]) { case 1: // IMG_GIF @@ -214,116 +218,140 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, case 4: // IMG_WBMP $imgfonction = 'imagecreatefromwbmp'; break; - case 17: // IMG_WBMP + case 18: // IMG_WEBP $imgfonction = 'imagecreatefromwebp'; break; } if ($imgfonction) { if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP - return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; + return 'Read of image not possible. This PHP does not support GD functions '.$imgfonction; } } - // Initialisation des variables selon l'extension de l'image + // Test function to write target image exists + if ($filetowrite) { + $imgfonction = ''; + switch ($newExt) { + case 'gif': // IMG_GIF + $imgfonction = 'imagecreatefromgif'; + break; + case 'jpg': // IMG_JPG + $imgfonction = 'imagecreatefromjpeg'; + break; + case 'png': // IMG_PNG + $imgfonction = 'imagecreatefrompng'; + break; + case 'bmp': // IMG_WBMP + $imgfonction = 'imagecreatefromwbmp'; + break; + case 'webp': // IMG_WEBP + $imgfonction = 'imagecreatefromwebp'; + break; + } + if ($imgfonction) { + if (!function_exists($imgfonction)) { + // Fonctions de conversion non presente dans ce PHP + return 'Write of image not possible. This PHP does not support GD functions '.$imgfonction; + } + } + } + + // Read source image file switch ($infoImg[2]) { case 1: // Gif $img = imagecreatefromgif($filetoread); $extImg = '.gif'; // File name extension of image - $newquality = 'NU'; // Quality is not used for this format break; case 2: // Jpg $img = imagecreatefromjpeg($filetoread); $extImg = '.jpg'; - $newquality = ($newquality ? $newquality : '100'); // % quality maximum break; case 3: // Png $img = imagecreatefrompng($filetoread); $extImg = '.png'; - $newquality = 0; // No compression (0-9) break; case 4: // Bmp $img = imagecreatefromwbmp($filetoread); $extImg = '.bmp'; - $newquality = 'NU'; // Quality is not used for this format break; case 18: // Webp $img = imagecreatefromwebp($filetoread); $extImg = '.webp'; - $newquality = ($newquality ? $newquality : '100'); // % quality maximum break; } - // Create empty image - if ($infoImg[2] == 1) { - // Compatibilite image GIF - $imgThumb = imagecreate($newWidth, $newHeight); + // Create empty image for target + if ($newExt == 'gif') { + // Compatibility image GIF + $imgTarget = imagecreate($newWidth, $newHeight); } else { - $imgThumb = imagecreatetruecolor($newWidth, $newHeight); + $imgTarget = imagecreatetruecolor($newWidth, $newHeight); } // Activate antialiasing for better quality if (function_exists('imageantialias')) { - imageantialias($imgThumb, true); + imageantialias($imgTarget, true); } // This is to keep transparent alpha channel if exists (PHP >= 4.2) if (function_exists('imagesavealpha')) { - imagesavealpha($imgThumb, true); + imagesavealpha($imgTarget, true); } - // Initialisation des variables selon l'extension de l'image - switch ($infoImg[2]) { - case 1: // Gif - $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF - imagecolortransparent($imgThumb, $trans_colour); + // Set transparent color according to image extension + switch ($newExt) { + case 'gif': // Gif + $trans_colour = imagecolorallocate($imgTarget, 255, 255, 255); // On procede autrement pour le format GIF + imagecolortransparent($imgTarget, $trans_colour); break; - case 2: // Jpg - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); + case 'jpg': // Jpg + $trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 0); break; - case 3: // Png - imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel + case 'png': // Png + imagealphablending($imgTarget, false); // Pour compatibilite sur certain systeme + $trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 127); // Keep transparent channel break; - case 4: // Bmp - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); + case 'bmp': // Bmp + $trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 0); break; - case 18: // Webp - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); + case 'webp': // Webp + $trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 127); break; } if (function_exists("imagefill")) { - imagefill($imgThumb, 0, 0, $trans_colour); + imagefill($imgTarget, 0, 0, $trans_colour); } - dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); - //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee - - $imgTargetName = ($filetowrite ? $filetowrite : $file); + dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg"); + //imagecopyresized($imgTarget, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee + imagecopyresampled($imgTarget, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee // Check if permission are ok //$fp = fopen($imgTargetName, "w"); //fclose($fp); - $newExt = strtolower(pathinfo($imgTargetName, PATHINFO_EXTENSION)); - // Create image on disk (overwrite file if exists) switch ($newExt) { case 'gif': // Gif - imagegif($imgThumb, $imgTargetName); + $newquality = 'NU'; // Quality is not used for this format + imagegif($imgTarget, $imgTargetName); break; case 'jpg': // Jpg - imagejpeg($imgThumb, $imgTargetName, $newquality); + $newquality = ($newquality ? $newquality : '100'); // % quality maximum + imagejpeg($imgTarget, $imgTargetName, $newquality); break; case 'png': // Png - imagepng($imgThumb, $imgTargetName, $newquality); + $newquality = 0; // No compression (0-9) + imagepng($imgTarget, $imgTargetName, $newquality); break; case 'bmp': // Bmp - imagewbmp($imgThumb, $imgTargetName); + $newquality = 'NU'; // Quality is not used for this format + imagewbmp($imgTarget, $imgTargetName); break; case 'webp': // Webp - imagewebp($imgThumb, $imgTargetName, $newquality); + $newquality = ($newquality ? $newquality : '100'); // % quality maximum + imagewebp($imgTarget, $imgTargetName, $newquality); break; } @@ -334,7 +362,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, // Free memory. This does not delete image. imagedestroy($img); - imagedestroy($imgThumb); + imagedestroy($imgTarget); clearstatcache(); // File was replaced by a modified one, so we clear file caches. diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index ece491d2c69..6862b6d59e9 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -456,6 +456,105 @@ function getPurchaseInvoicePieChart($socid = 0) return $result; } +/** + * Return an HTML table that contains a pie chart of the number of customers or supplier invoices + * @param string $mode Can be customer or fourn + * @return string A HTML table that contains a pie chart of customers or supplier invoices + */ +function getNumberInvoicesPieChart($mode) +{ + global $conf, $db, $langs, $user; + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $now = date_create(date('Y-m-d', dol_now())); + $datenowsub30 = date_create(date('Y-m-d', dol_now())); + $datenowsub15 = date_create(date('Y-m-d', dol_now())); + $datenowadd30 = date_create(date('Y-m-d', dol_now())); + $datenowadd15 = date_create(date('Y-m-d', dol_now())); + $interval30days = date_interval_create_from_date_string('30 days'); + $interval15days = date_interval_create_from_date_string('15 days'); + date_sub($datenowsub30, $interval30days); + date_sub($datenowsub15, $interval15days); + date_add($datenowadd30, $interval30days); + date_add($datenowadd15, $interval15days); + + $sql = "SELECT sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", 1, 0).") as nblate30"; + $sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub15, 'Y-m-d')."'", 1, 0).") as nblate15"; + $sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($now, 'Y-m-d')."'", 1, 0).") as nblatenow"; + $sql .= ", sum(".$db->ifsql("f.date_lim_reglement > '".date_format($datenowadd30, 'Y-m-d')."'", 1, 0).") as nbnotlate30"; + $sql .= ", sum(".$db->ifsql("f.date_lim_reglement > '".date_format($datenowadd15, 'Y-m-d')."'", 1, 0).") as nbnotlate15"; + $sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($now, 'Y-m-d')."'", 1, 0).") as nbnotlatenow"; + if ($mode == 'customers') { + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + } elseif ($mode == 'fourn') { + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + } else { + return ''; + } + $sql .= " WHERE f.type <> 2"; + $sql .= " AND f.fk_statut = 1"; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $dataseries = array(); + while ($i < $num) { + $obj = $db->fetch_object($resql); + $dataseries = array(array($langs->trans('InvoiceLate30Days'),$obj->nblate30) + ,array($langs->trans('InvoiceLate15Days'),$obj->nblate15-$obj->nblate30) + ,array($langs->trans('InvoiceLateMinus15Days'),$obj->nblatenow-$obj->nblate15) + ,array($langs->trans('InvoiceNotLate'),$obj->nbnotlatenow-$obj->nbnotlate15) + ,array($langs->trans('InvoiceNotLate15Days'),$obj->nbnotlate15-$obj->nbnotlate30) + ,array($langs->trans('InvoiceNotLate30Days'),$obj->nbnotlate30)); + $i++; + } + foreach ($dataseries as $key=>$value) { + $total+=$value[1]; + } + $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus2, $badgeStatus4, $badgeStatus11); + if ($conf->use_javascript_ajax) { + $result = '
'; + $result .= ''; + $result .= ''; + $result .= ''; + } elseif ($mode == 'fourn') { + $result .= $langs->trans("SupplierInvoice").''; + } else { + return ''; + } + $result .= ''; + + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(['pie']); + $dolgraph->setHeight('150'); + $dolgraph->setWidth('300'); + if ($mode == 'customers') { + $dolgraph->draw('idgraphcustomerinvoices'); + } elseif ($mode == 'fourn') { + $dolgraph->draw('idgraphfourninvoices'); + } else { + return ''; + } + $result .= ''; + $result .= ''; + $result .= ''; + $result .= '
'.$langs->trans("Statistics").' - '; + if ($mode == 'customers') { + $result .= $langs->trans("CustomerInvoice").'
'.$dolgraph->show($total ? 0 : 1).'
'; + $result .= '
'; + } + return $result; + } else { + dol_print_error($db); + } + } +} /** * Return a HTML table that contains a list with customer invoice drafts * diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 529355b94b2..086152a974b 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -12,6 +12,7 @@ * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2019 Lenin Rivas * Copyright (C) 2020 Nicolas ZABOURI + * Copyright (C) 2021 Anthony Berton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +36,42 @@ */ +/** + * Return array head with list of tabs to view object informations. + * + * @return array head array with tabs + */ +function pdf_admin_prepare_head() +{ + global $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/pdf.php'; + $head[$h][1] = $langs->trans("Common"); + $head[$h][2] = 'general'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin'); + + if (!empty($conf->propal->enabled)) { + $head[$h][0] = DOL_URL_ROOT.'/admin/pdf_other.php'; + $head[$h][1] = $langs->trans("Other"); + $head[$h][2] = 'other'; + $h++; + } + + complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin', 'remove'); + + return $head; +} + + /** * Return array with format properties of default PDF format * diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 30ee2bb72be..5fbfc05a9fb 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -800,6 +800,23 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $ret; } + /** + * Gives the module position + * + * @return int Module position (an external module should never return a value lower than 100000. 1-100000 are reserved for core) + */ + public function getModulePosition() + { + if (in_array($this->version, array('dolibarr', 'experimental', 'development'))) { // core module + return $this->module_position; + } else { // external module + if ($this->module_position >= 100000) { + return $this->module_position; + } else { + return $this->module_position + 100000; + } + } + } /** * Tells if module is core or external diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 42a777a196f..97777adc4cd 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -318,13 +318,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->useTemplate($tplidx); } $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10); $tab_height = 130; $tab_height_newpage = 150; @@ -361,17 +361,14 @@ class pdf_espadon extends ModelePdfExpedition } if (!empty($notetoshow) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms; - $tab_top_alt = $tab_top; - - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); - - $tab_top_alt = $pdf->GetY(); - //$tab_top_alt += 1; + $tab_top -= 2; // Tracking number if (!empty($object->tracking_number)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber") . " : " . $object->tracking_number, 0, 1, false, true, 'L'); + + $tab_top_alt = $pdf->GetY(); $object->getUrlTrackingStatus($object->tracking_number); if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { @@ -390,28 +387,124 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); + $tab_top = $pdf->GetY(); } } } + // Notes + $pagenb = $pdf->getPage(); if (!empty($notetoshow)) { - $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1); + $tab_top -= 2; + + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $pageposbeforenote = $pagenb; + + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + + $pdf->startTransaction(); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + // Description + $pageposafternote = $pdf->getPage(); + $posyafter = $pdf->GetY(); + + if ($pageposafternote > $pageposbeforenote) { + $pdf->rollbackTransaction(true); + + // prepare pages to receive notes + while ($pagenb < $pageposafternote) { + $pdf->AddPage(); + $pagenb++; + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + // $this->_pagefoot($pdf,$object,$outputlangs,1); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + } + + // back to start + $pdf->setPage($pageposbeforenote); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); + + $posyafter = $pdf->GetY(); + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + //$posyafter = $tab_top_newpage; + } + + + // apply note frame to previous pages + $i = $pageposbeforenote; + while ($i < $pageposafternote) { + $pdf->setPage($i); + + + $pdf->SetDrawColor(128, 128, 128); + // Draw note frame + if ($i > $pageposbeforenote) { + $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + } + + // Add footer + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $this->_pagefoot($pdf, $object, $outputlangs, 1); + + $i++; + } + + // apply note frame to last page + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else // No pagebreak + { + $pdf->commitTransaction(); + $posyafter = $pdf->GetY(); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { + // not enough space, need to add page + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + + $posyafter = $tab_top_newpage; + } + } + + $tab_height = $tab_height - $height_note; + $tab_top = $posyafter + 6; + } else { + $height_note = 0; } - - $nexY = $pdf->GetY(); - $height_note = $nexY - $tab_top; - - // Rect takes a length in 3rd parameter - $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - - $tab_height = $tab_height - $height_note; - $tab_top = $nexY + 6; - } else { - $height_note = 0; } @@ -420,13 +513,15 @@ class pdf_espadon extends ModelePdfExpedition // Table simulation to know the height of the title line $pdf->startTransaction(); - $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs); $pdf->rollbackTransaction(true); $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines + $pageposbeforeprintlines = $pdf->getPage(); + $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage @@ -590,7 +685,7 @@ class pdf_espadon extends ModelePdfExpedition // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); - if ($pagenb == 1) { + if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index a7a260dba6e..9ef50fe3aac 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -56,7 +56,7 @@ class modIncoterm extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->picto = 'generic'; + $this->picto = 'incoterm'; $this->module_parts = array(); $this->dirs = array(); diff --git a/htdocs/core/modules/modKnowledgeManagement.class.php b/htdocs/core/modules/modKnowledgeManagement.class.php index 47c25232d67..504c363b648 100644 --- a/htdocs/core/modules/modKnowledgeManagement.class.php +++ b/htdocs/core/modules/modKnowledgeManagement.class.php @@ -45,7 +45,7 @@ class modKnowledgeManagement extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 57000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + $this->numero = 57000; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'knowledgemanagement'; @@ -260,26 +260,21 @@ class modKnowledgeManagement extends DolibarrModules $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of Knowledge Management'; // Permission label $this->rights[$r][4] = 'knowledgerecord'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of Knowledge Management'; // Permission label $this->rights[$r][4] = 'knowledgerecord'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero + $r + 1; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of Knowledge Management'; // Permission label $this->rights[$r][4] = 'knowledgerecord'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Reply to objects of Knowledge Management'; // Permission label - $this->rights[$r][4] = 'knowledgerecord'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) - $this->rights[$r][5] = 'reply'; // In php code, permission will be checked by test if ($user->rights->knowledgemanagement->level1->level2) - $r++; /* END MODULEBUILDER PERMISSIONS */ // Main menu entries to add diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 1165461368b..8b3b0cdb2c4 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -48,7 +48,7 @@ class modPartnership extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + $this->numero = 58000; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'partnership'; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index ea9f9548cb7..048f8fcb508 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -157,7 +157,8 @@ class modPropale extends DolibarrModules $this->rights[$r][1] = 'Close commercial proposals'; // Set proposal to signed or refused $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'cloturer'; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'close'; $r++; $this->rights[$r][0] = 27; // id de la permission diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 363d3984516..56c5b8e8885 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -207,7 +207,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) { $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); - while ($disponibility <> 0 && $i < 100) { + while ($disponibility <> 0 && $i < 1000) { $widthsupplier = $this->supplieraccountancycodecharacternumber; $widthcustomer = $this->customeraccountancycodecharacternumber; @@ -217,6 +217,9 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode if ($i >= 10 && $i <= 99) { $a = 2; } + if ($i >= 100 && $i <= 999) { + $a = 3; + } if ($type == 'supplier') { $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i; diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index c98dcec2a43..d8bbe0c7cc0 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -171,6 +171,8 @@ if ($action == 'delete_section') { // Ask confirmation to build webp images if ($action == 'confirmconvertimgwebp') { + $langs->load("ecm"); + $section_dir=GETPOST('section_dir', 'alpha'); $section=GETPOST('section', 'alpha'); $form = new Form($db); @@ -195,19 +197,23 @@ if ($action == 'convertimgwebp' && $permtoadd) { $regeximgext = getListOfPossibleImageExt(); - $filelist = dol_dir_list($imagefolder, "all", 0, $regeximgext); + $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext); + + $nbconverted = 0; foreach ($filelist as $filename) { $filepath = $filename['fullname']; if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { if (image_format_supported($filepath) == 1) { - $filepathnoext = preg_replace("/\..*/", "", $filepath); + $filepathnoext = preg_replace("/\.[a-z0-9]+$/i", "", $filepath); if (! dol_is_file($filepathnoext.'.webp')) { // If file does not exists yet $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp', 90); if (!dol_is_file($result)) { $error++; setEventMessages($result, null, 'errors'); + } else { + $nbconverted++; } } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 7f7cd5a77be..8e98030b484 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -108,6 +108,17 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name); + $object->sendtoid = 0; + $object->socid = $object->id; + } elseif ($action == 'COMPANY_MODIFY') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "companies")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + } + $object->actionmsg = $langs->transnoentities("COMPANY_MODIFYInDolibarr", $object->name); + $object->sendtoid = 0; $object->socid = $object->id; } elseif ($action == 'COMPANY_SENTBYMAIL') { @@ -129,6 +140,17 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->actionmsg = $langs->transnoentities("CONTACT_CREATEInDolibarr", $object->getFullName($langs)); + $object->sendtoid = array($object->id => $object->id); + $object->socid = $object->socid; + } elseif ($action == 'CONTACT_MODIFY') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "companies")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); + } + $object->actionmsg = $langs->transnoentities("CONTACT_MODIFYInDolibarr", $object->name); + $object->sendtoid = array($object->id => $object->id); $object->socid = $object->socid; } elseif ($action == 'CONTRACT_VALIDATE') { diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index e5d779d8e10..2132cbc141b 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -68,7 +68,7 @@ $mode = GETPOST('mode', 'aZ09'); $search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int')); $search_label = GETPOST("search_label", 'alpha'); $search_module_name = GETPOST("search_module_name", 'alpha'); -$search_lastresult = GETPOST("search_lastresult", "alpha"); +$search_lastresult = GETPOST("search_lastresult", "alphawithlgt"); $securitykey = GETPOST('securitykey', 'alpha'); $outputdir = $conf->cron->dir_output; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 2773ab62c14..b960a2fdb8f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -131,7 +131,7 @@ class Donations extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index 68f6c4eef13..8a3767f0606 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -595,10 +595,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 1d47921e423..dcd619da76e 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -147,7 +147,7 @@ class Shipments extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 027bb148b3c..907e1001439 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -120,7 +120,7 @@ class ExpenseReports extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 423bb31f348..0c03da526a8 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -154,7 +154,7 @@ class Interventions extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 55518997d5e..34939bb599a 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -162,7 +162,7 @@ class SupplierInvoices extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index c20efa2e651..09c9209629f 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -178,7 +178,7 @@ class SupplierOrders extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e33b9de48c1..cc2cdc9fb86 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2309,10 +2309,12 @@ if ($action == 'create') { if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $usercancreate) { if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(1, $societe, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $societe, $mysoc); } } print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 801abaa7407..fc18bbc5501 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2257,6 +2257,10 @@ if ($action == 'create') { print ''; } + if (empty($reshook)) { + print $object->showOptionals($extrafields, 'edit'); + } + // Public note print ''.$langs->trans('NotePublic').''; print ''; @@ -2275,9 +2279,6 @@ if ($action == 'create') { // print ''; print ''; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); - } if (is_object($objectsrc)) { print "\n"; @@ -3327,10 +3328,12 @@ if ($action == 'create') { if ($object->statut == FactureFournisseur::STATUS_DRAFT && $usercancreate) { if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(1, $societe, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $societe, $mysoc); } } diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index b0d578829b9..88df2349391 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -35,17 +35,17 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (4, INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (5,'DE','DEU','Germany',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (6,'CH','CHE','Switzerland',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (7,'GB','GBR','United Kingdom',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (8,'IE','IRL','Irland',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (8,'IE','IRL','Ireland',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (9,'CN','CHN','China',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (10,'TN','TUN','Tunisia',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (11,'US','USA','United States',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (12,'MA','MAR','Maroc',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (12,'MA','MAR','Morocco',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (13,'DZ','DZA','Algeria',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (14,'CA','CAN','Canada',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (15,'TG','TGO','Togo',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (16,'GA','GAB','Gabon',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (17,'NL','NLD','Nederland',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (18,'HU','HUN','Hongrie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (17,'NL','NLD','Netherlands',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (18,'HU','HUN','Hungary',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (19,'RU','RUS','Russia',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (20,'SE','SWE','Sweden',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (21,'CI','CIV','Côte d''Ivoire',1,0); diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index d55455a215a..daf6e16ea9e 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -327,7 +327,22 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1 insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 154, 15401, '', 0, 'Mexique'); --- Morocco / Maroc - Regions (id country=12) +-- Morocco / Maroc - Regions since 2015 (id country=12) +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1201, '', 0, 'Tanger-Tétouan-Al Hoceima'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1202, '', 0, 'Oriental'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1203, '', 0, 'Fès-Meknès'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1204, '', 0, 'Rabat-Salé-Kénitra'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1205, '', 0, 'Béni Mellal-Khénifra'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1206, '', 0, 'Casablanca-Settat'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1207, '', 0, 'Marrakech-Safi'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1208, '', 0, 'Drâa-Tafilalet'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1209, '', 0, 'Souss-Massa'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1210, '', 0, 'Guelmim-Oued Noun'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1211, '', 0, 'Laâyoune-Sakia El Hamra'); +-- INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1212, '', 0, 'Dakhla-Oued Ed Dahab'); + + +-- Morocco / Maroc - History 1997-2015 - Regions 13 +3 of Moroccan Sahara (id country=12) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1201, '', 0, 'Tanger-Tétouan'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1202, '', 0, 'Gharb-Chrarda-Beni Hssen'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1203, '', 0, 'Taza-Al Hoceima-Taounate'); @@ -346,6 +361,7 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 12, 1216, '', 0, 'Oued Ed-Dahab Lagouira'); + -- Netherlands Regions (id country=17) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 17, 1701, '', 0,'Provincies van Nederland '); diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index fd60de31aa3..1dfb11db9c5 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -54,7 +54,7 @@ -- Italy -- Luxembourg -- Netherlands --- (Moroco) +-- Morocco -- Panama -- Portugal -- Romania @@ -663,6 +663,91 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0012', '', 0, '', 'Mersch'); +-- Morocco/Maroc Provinces (62) & Prefectures (13) (id country=12) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1209, 'MA', '', 0, '', 'Province de Benslimane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1209, 'MA1', '', 0, '', 'Province de Berrechid'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1209, 'MA2', '', 0, '', 'Province de Khouribga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1209, 'MA3', '', 0, '', 'Province de Settat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1210, 'MA4', '', 0, '', 'Province d''El Jadida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1210, 'MA5', '', 0, '', 'Province de Safi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1210, 'MA6', '', 0, '', 'Province de Sidi Bennour'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1210, 'MA7', '', 0, '', 'Province de Youssoufia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA6B', '', 0, '', 'Préfecture de Fès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA7B', '', 0, '', 'Province de Boulemane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA8', '', 0, '', 'Province de Moulay Yacoub'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA9', '', 0, '', 'Province de Sefrou'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1202, 'MA8A', '', 0, '', 'Province de Kénitra'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1202, 'MA9A', '', 0, '', 'Province de Sidi Kacem'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1202, 'MA10', '', 0, '', 'Province de Sidi Slimane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1208, 'MA11', '', 0, '', 'Préfecture de Casablanca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1208, 'MA12', '', 0, '', 'Préfecture de Mohammédia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1208, 'MA13', '', 0, '', 'Province de Médiouna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1208, 'MA14', '', 0, '', 'Province de Nouaceur'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA15', '', 0, '', 'Province d''Assa-Zag'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA16', '', 0, '', 'Province d''Es-Semara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA17A','', 0, '', 'Province de Guelmim'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA18', '', 0, '', 'Province de Tata'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA19', '', 0, '', 'Province de Tan-Tan'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1215, 'MA15', '', 0, '', 'Province de Boujdour'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1215, 'MA16', '', 0, '', 'Province de Lâayoune'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1215, 'MA17', '', 0, '', 'Province de Tarfaya'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA18', '', 0, '', 'Préfecture de Marrakech'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA19', '', 0, '', 'Province d''Al Haouz'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA20', '', 0, '', 'Province de Chichaoua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA21', '', 0, '', 'Province d''El Kelâa des Sraghna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA22', '', 0, '', 'Province d''Essaouira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA23', '', 0, '', 'Province de Rehamna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA24', '', 0, '', 'Préfecture de Meknès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA25', '', 0, '', 'Province d’El Hajeb'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA26', '', 0, '', 'Province d''Errachidia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA27', '', 0, '', 'Province d’Ifrane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA28', '', 0, '', 'Province de Khénifra'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1206, 'MA29', '', 0, '', 'Province de Midelt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA30', '', 0, '', 'Préfecture d''Oujda-Angad'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA31', '', 0, '', 'Province de Berkane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA32', '', 0, '', 'Province de Driouch'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA33', '', 0, '', 'Province de Figuig'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA34', '', 0, '', 'Province de Jerada'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA35', '', 0, '', 'Province de Nador'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1204, 'MA36', '', 0, '', 'Province de Taourirt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1216, 'MA37', '', 0, '', 'Province d''Aousserd'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1216, 'MA38', '', 0, '', 'Province d''Oued Ed-Dahab'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1207, 'MA39', '', 0, '', 'Préfecture de Rabat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1207, 'MA40', '', 0, '', 'Préfecture de Skhirat-Témara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1207, 'MA41', '', 0, '', 'Préfecture de Salé'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1207, 'MA42', '', 0, '', 'Province de Khémisset'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA43', '', 0, '', 'Préfecture d''Agadir Ida-Outanane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA44', '', 0, '', 'Préfecture d''Inezgane-Aït Melloul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA45', '', 0, '', 'Province de Chtouka-Aït Baha'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA46', '', 0, '', 'Province d''Ouarzazate'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA47', '', 0, '', 'Province de Sidi Ifni'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA48', '', 0, '', 'Province de Taroudant'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA49', '', 0, '', 'Province de Tinghir'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA50', '', 0, '', 'Province de Tiznit'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1213, 'MA51', '', 0, '', 'Province de Zagora'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1212, 'MA52', '', 0, '', 'Province d''Azilal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1212, 'MA53', '', 0, '', 'Province de Beni Mellal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1212, 'MA54', '', 0, '', 'Province de Fquih Ben Salah'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA55', '', 0, '', 'Préfecture de M''diq-Fnideq'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA56', '', 0, '', 'Préfecture de Tanger-Asilah'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA57', '', 0, '', 'Province de Chefchaouen'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA58', '', 0, '', 'Province de Fahs-Anjra'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA59', '', 0, '', 'Province de Larache'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA60', '', 0, '', 'Province d''Ouezzane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1201, 'MA61', '', 0, '', 'Province de Tétouan'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1203, 'MA62', '', 0, '', 'Province de Guercif'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1203, 'MA63', '', 0, '', 'Province d''Al Hoceïma'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1203, 'MA64', '', 0, '', 'Province de Taounate'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1203, 'MA65', '', 0, '', 'Province de Taza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA6A', '', 0, '', 'Préfecture de Fès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1205, 'MA7A', '', 0, '', 'Province de Boulemane'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA15A','', 0, '', 'Province d''Assa-Zag'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA16A','', 0, '', 'Province d''Es-Semara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1211, 'MA18A','', 0, '', 'Préfecture de Marrakech'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA19A','', 0, '', 'Province de Tan-Tan'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1214, 'MA19B','', 0, '', 'Province de Tan-Tan'); + + -- Netherlands/Nederland Provinces (id country=17) INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'GR', NULL, NULL, NULL, 'Groningen'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'FR', NULL, NULL, NULL, 'Friesland'); @@ -678,91 +763,6 @@ INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'LB', NULL, NULL, NULL, 'Limburg'); --- Provinces Maroc - Moroco (id country=12) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA', 1209, '', 0, '', 'Province de Benslimane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA1', 1209, '', 0, '', 'Province de Berrechid', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA2', 1209, '', 0, '', 'Province de Khouribga', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA3', 1209, '', 0, '', 'Province de Settat', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA4', 1210, '', 0, '', 'Province d''El Jadida', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA5', 1210, '', 0, '', 'Province de Safi', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA6', 1210, '', 0, '', 'Province de Sidi Bennour', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA7', 1210, '', 0, '', 'Province de Youssoufia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA6B', 1205, '', 0, '', 'Préfecture de Fès', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA7B', 1205, '', 0, '', 'Province de Boulemane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA8', 1205, '', 0, '', 'Province de Moulay Yacoub', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA9', 1205, '', 0, '', 'Province de Sefrou', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA8A', 1202, '', 0, '', 'Province de Kénitra', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA9A', 1202, '', 0, '', 'Province de Sidi Kacem', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA10', 1202, '', 0, '', 'Province de Sidi Slimane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA11', 1208, '', 0, '', 'Préfecture de Casablanca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA12', 1208, '', 0, '', 'Préfecture de Mohammédia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA13', 1208, '', 0, '', 'Province de Médiouna', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA14', 1208, '', 0, '', 'Province de Nouaceur', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA15', 1214, '', 0, '', 'Province d''Assa-Zag', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA16', 1214, '', 0, '', 'Province d''Es-Semara', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA17A', 1214, '', 0, '', 'Province de Guelmim', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA18', 1214, '', 0, '', 'Province de Tata', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19', 1214, '', 0, '', 'Province de Tan-Tan', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA15', 1215, '', 0, '', 'Province de Boujdour', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA16', 1215, '', 0, '', 'Province de Lâayoune', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA17', 1215, '', 0, '', 'Province de Tarfaya', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA18', 1211, '', 0, '', 'Préfecture de Marrakech', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19', 1211, '', 0, '', 'Province d''Al Haouz', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA20', 1211, '', 0, '', 'Province de Chichaoua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA21', 1211, '', 0, '', 'Province d''El Kelâa des Sraghna', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA22', 1211, '', 0, '', 'Province d''Essaouira', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA23', 1211, '', 0, '', 'Province de Rehamna', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA24', 1206, '', 0, '', 'Préfecture de Meknès', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA25', 1206, '', 0, '', 'Province d’El Hajeb', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA26', 1206, '', 0, '', 'Province d''Errachidia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA27', 1206, '', 0, '', 'Province d’Ifrane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA28', 1206, '', 0, '', 'Province de Khénifra', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA29', 1206, '', 0, '', 'Province de Midelt', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA30', 1204, '', 0, '', 'Préfecture d''Oujda-Angad', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA31', 1204, '', 0, '', 'Province de Berkane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA32', 1204, '', 0, '', 'Province de Driouch', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA33', 1204, '', 0, '', 'Province de Figuig', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA34', 1204, '', 0, '', 'Province de Jerada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA35', 1204, '', 0, '', 'Province de Nador', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA36', 1204, '', 0, '', 'Province de Taourirt', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA37', 1216, '', 0, '', 'Province d''Aousserd', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA38', 1216, '', 0, '', 'Province d''Oued Ed-Dahab', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA39', 1207, '', 0, '', 'Préfecture de Rabat', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA40', 1207, '', 0, '', 'Préfecture de Skhirat-Témara', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA41', 1207, '', 0, '', 'Préfecture de Salé', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA42', 1207, '', 0, '', 'Province de Khémisset', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA43', 1213, '', 0, '', 'Préfecture d''Agadir Ida-Outanane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA44', 1213, '', 0, '', 'Préfecture d''Inezgane-Aït Melloul', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA45', 1213, '', 0, '', 'Province de Chtouka-Aït Baha', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA46', 1213, '', 0, '', 'Province d''Ouarzazate', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA47', 1213, '', 0, '', 'Province de Sidi Ifni', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA48', 1213, '', 0, '', 'Province de Taroudant', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA49', 1213, '', 0, '', 'Province de Tinghir', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA50', 1213, '', 0, '', 'Province de Tiznit', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA51', 1213, '', 0, '', 'Province de Zagora', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA52', 1212, '', 0, '', 'Province d''Azilal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA53', 1212, '', 0, '', 'Province de Beni Mellal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA54', 1212, '', 0, '', 'Province de Fquih Ben Salah', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA55', 1201, '', 0, '', 'Préfecture de M''diq-Fnideq', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA56', 1201, '', 0, '', 'Préfecture de Tanger-Asilah', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA57', 1201, '', 0, '', 'Province de Chefchaouen', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA58', 1201, '', 0, '', 'Province de Fahs-Anjra', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA59', 1201, '', 0, '', 'Province de Larache', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA60', 1201, '', 0, '', 'Province d''Ouezzane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA61', 1201, '', 0, '', 'Province de Tétouan', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA62', 1203, '', 0, '', 'Province de Guercif', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA63', 1203, '', 0, '', 'Province d''Al Hoceïma', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA64', 1203, '', 0, '', 'Province de Taounate', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA65', 1203, '', 0, '', 'Province de Taza', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA6A', 1205, '', 0, '', 'Préfecture de Fès', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA7A', 1205, '', 0, '', 'Province de Boulemane', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA15A', 1214, '', 0, '', 'Province d''Assa-Zag', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA16A', 1214, '', 0, '', 'Province d''Es-Semara', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA18A', 1211, '', 0, '', 'Préfecture de Marrakech', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19A', 1214, '', 0, '', 'Province de Tan-Tan', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('MA19B', 1214, '', 0, '', 'Province de Tan-Tan', 1); - - -- Panama - 10 Provinces (id country=178) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES (17801, 'PA-1', '', 0, '', 'Bocas del Toro'); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES (17801, 'PA-2', '', 0, '', 'Coclé'); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 8eebe1db211..af6c2f48f50 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -32,6 +32,16 @@ -- Missing in v13 or lower +ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_numero_compte; +ALTER TABLE llx_accounting_bookkeeping DROP INDEX idx_accounting_bookkeeping_code_journal; + +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte, entity); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal, entity); + +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_piece_num (piece_num, entity); + ALTER TABLE llx_recruitment_recruitmentcandidature MODIFY COLUMN email_msgid VARCHAR(175); ALTER TABLE llx_asset CHANGE COLUMN amount amount_ht double(24,8) DEFAULT NULL; @@ -307,7 +317,8 @@ create table llx_product_perentity accountancy_code_sell_export varchar(32), -- Selling accountancy code for vat export accountancy_code_buy varchar(32), -- Buying accountancy code accountancy_code_buy_intra varchar(32), -- Buying accountancy code for vat intracommunity - accountancy_code_buy_export varchar(32) -- Buying accountancy code for vat import + accountancy_code_buy_export varchar(32), -- Buying accountancy code for vat import + pmp double(24,8) )ENGINE=innodb; ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product); @@ -467,4 +478,7 @@ create table llx_knowledgemanagement_knowledgerecord_extrafields tms timestamp, fk_object integer NOT NULL, import_key varchar(14) -- import key -) ENGINE=innodb; \ No newline at end of file +) ENGINE=innodb; + +-- add default amount by member type +ALTER TABLE llx_adherent_type ADD COLUMN amount DOUBLE(24,8) NULL DEFAULT NULL AFTER subscription; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql index ca71d90aa0b..766de8d6230 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql @@ -16,11 +16,12 @@ -- -- ============================================================================ -ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_doc (fk_doc); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet); -ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte); -ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte, entity); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal, entity); +ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_piece_num (piece_num, entity); -- Current unicity is tested by the journalize page on couple (fk_doc, doc_type) -- TODO Add a key for unicity (not so easy as fk_doc, doc_type may have several lines for one piece) diff --git a/htdocs/install/mysql/tables/llx_adherent_type.sql b/htdocs/install/mysql/tables/llx_adherent_type.sql index bdce18ef0bc..243372c0452 100644 --- a/htdocs/install/mysql/tables/llx_adherent_type.sql +++ b/htdocs/install/mysql/tables/llx_adherent_type.sql @@ -32,6 +32,7 @@ create table llx_adherent_type morphy varchar(3) NOT NULL, duration varchar(6) DEFAULT NULL, subscription varchar(3) NOT NULL DEFAULT '1', + amount double(24,8) DEFAULT NULL, vote varchar(3) NOT NULL DEFAULT '1', note text, mail_valid text diff --git a/htdocs/install/mysql/tables/llx_product_perentity.sql b/htdocs/install/mysql/tables/llx_product_perentity.sql index 6e32e506ddf..495324f9f5b 100644 --- a/htdocs/install/mysql/tables/llx_product_perentity.sql +++ b/htdocs/install/mysql/tables/llx_product_perentity.sql @@ -26,5 +26,6 @@ create table llx_product_perentity accountancy_code_sell_export varchar(32), -- Selling accountancy code for vat export accountancy_code_buy varchar(32), -- Buying accountancy code accountancy_code_buy_intra varchar(32), -- Buying accountancy code for vat intracommunity - accountancy_code_buy_export varchar(32) -- Buying accountancy code for vat import + accountancy_code_buy_export varchar(32), -- Buying accountancy code for vat import + pmp double(24,8) )ENGINE=innodb; diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index 771c8ff241a..f4e949a8603 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -123,7 +123,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $permissiontoread = $user->rights->knowledgemanagement->knowledgerecord->read; -$permissiontoreply = $user->rights->knowledgemanagement->knowledgerecord->reply; +$permissiontovalidate = $user->rights->knowledgemanagement->knowledgerecord->write; $permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->knowledgemanagement->knowledgerecord->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissionnote = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_setnotes.inc.php @@ -461,12 +461,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == $object::STATUS_VALIDATED) { print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); } - if ($object->status == $object::STATUS_VALIDATED && $permissiontoreply) { + if ($object->status == $object::STATUS_VALIDATED && $permissiontovalidate) { print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd); } // Validate if ($object->status == $object::STATUS_DRAFT) { - if ((empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) && $permissiontoreply) { + if ((empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) && $permissiontovalidate) { print dolGetButtonAction($langs->trans('ValidateReply'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); } else { $langs->load("errors"); diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 9f4117d5f7b..bd4c8829be5 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -262,7 +262,7 @@ $sql .= $object->getFieldList('t'); // 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.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key.' as options_'.$key.', ' : ''); } } // Add fields from hooks diff --git a/htdocs/knowledgemanagement/lib/knowledgemanagement.lib.php b/htdocs/knowledgemanagement/lib/knowledgemanagement.lib.php index 15279f01983..ba81dd49057 100644 --- a/htdocs/knowledgemanagement/lib/knowledgemanagement.lib.php +++ b/htdocs/knowledgemanagement/lib/knowledgemanagement.lib.php @@ -37,13 +37,13 @@ function knowledgemanagementAdminPrepareHead() $head[$h][0] = dol_buildpath("/admin/knowledgemanagement.php", 1); $head[$h][1] = $langs->trans("Setup"); - $head[$h][2] = 'settings'; + $head[$h][2] = 'setup'; $h++; $head[$h][0] = dol_buildpath("admin/knowledgerecord_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'settings'; + $head[$h][2] = 'extra'; $h++; /*$head[$h][0] = dol_buildpath("/knowledgemanagement/admin/about.php", 1); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 692c447d610..237c85fe0f9 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -158,7 +158,7 @@ ACCOUNTING_LENGTH_AACCOUNT=Length of the third-party accounting accounts (If you ACCOUNTING_MANAGE_ZERO=Allow to manage different number of zeros at the end of an accounting account. Needed by some countries (like Switzerland). If set to off (default), you can set the following two parameters to ask the application to add virtual zeros. BANK_DISABLE_DIRECT_INPUT=Disable direct recording of transaction in bank account ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL=Enable draft export on journal -ACCOUNTANCY_COMBO_FOR_AUX=Enable combo list for subsidiary account (may be slow if you have a lot of third parties) +ACCOUNTANCY_COMBO_FOR_AUX=Enable combo list for subsidiary account (may be slow if you have a lot of third parties, break ability to search on a part of value) ACCOUNTING_DATE_START_BINDING=Define a date to start binding & transfer in accountancy. Below this date, the transactions will not be transferred to accounting. ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER=On accountancy transfer, select period show by default diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 720532a066e..d803593bc3e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -399,6 +399,7 @@ SecurityToken=Key to secure URLs NoSmsEngine=No SMS sender manager available. A SMS sender manager is not installed with the default distribution because they depend on an external vendor, but you can find some on %s PDF=PDF PDFDesc=Global options for PDF generation +PDFOtherDesc=PDF Option specific to some modules PDFAddressForging=Rules for address section HideAnyVATInformationOnPDF=Hide all information related to Sales Tax / VAT PDFRulesForSalesTax=Rules for Sales Tax / VAT @@ -1979,6 +1980,8 @@ MAIN_PDF_MARGIN_RIGHT=Right margin on PDF MAIN_PDF_MARGIN_TOP=Top margin on PDF MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF MAIN_DOCUMENTS_LOGO_HEIGHT=Height for logo on PDF +MAIN_GENERATE_PROPOSALS_WITH_PICTURE=Add picture on proposal ligne +MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING=Add electronic sign in PDF NothingToSetup=There is no specific setup required for this module. SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous field was set to Yes.
For example:
CODEGRP1+CODEGRP2 @@ -2123,6 +2126,7 @@ YouShouldDisablePHPFunctions=You should disable PHP functions IfCLINotRequiredYouShouldDisablePHPFunctions=Except if you need to run system commands (for the module Scheduled job, or to run the external command line Anti-virus for example), you shoud disable PHP functions NoWritableFilesFoundIntoRootDir=No writable files or directories of the common programs were found into your root directory (Good) RecommendedValueIs=Recommended: %s +NotRecommended=Not recommanded ARestrictedPath=A restricted path CheckForModuleUpdate=Check for external modules updates CheckForModuleUpdateHelp=This action will connect to editors of external modules to check if a new version is available. diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index d16188d40d4..bab409dd036 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -38,6 +38,7 @@ ActionsEvents=Events for which Dolibarr will create an action in agenda automati EventRemindersByEmailNotEnabled=Event reminders by email was not enabled into %s module setup. ##### Agenda event labels ##### NewCompanyToDolibarr=Third party %s created +COMPANY_MODIFYInDolibarr=Third party %s modified COMPANY_DELETEInDolibarr=Third party %s deleted ContractValidatedInDolibarr=Contract %s validated CONTRACT_DELETEInDolibarr=Contract %s deleted @@ -87,6 +88,7 @@ OrderDeleted=Order deleted InvoiceDeleted=Invoice deleted DraftInvoiceDeleted=Draft invoice deleted CONTACT_CREATEInDolibarr=Contact %s created +CONTACT_MODIFYInDolibarr=Contact %s modified CONTACT_DELETEInDolibarr=Contact %s deleted PRODUCT_CREATEInDolibarr=Product %s created PRODUCT_MODIFYInDolibarr=Product %s modified diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 7cae82e6ac7..405689a57e5 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -286,3 +286,9 @@ ReportPurchaseTurnover=Purchase turnover invoiced ReportPurchaseTurnoverCollected=Purchase turnover collected IncludeVarpaysInResults = Include various payments in reports IncludeLoansInResults = Include loans in reports +InvoiceLate30Days = Invoices late 30 days +InvoiceLate15Days = Invoices late 15 days +InvoiceLateMinus15Days = Invoices late +InvoiceNotLate = To pay < 15 days +InvoiceNotLate15Days = To pay > 15 days +InvoiceNotLate30Days = To pay in > 30 days diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9fdaa1a533a..7ba539d3bd4 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -143,3 +143,4 @@ AsciiToHtmlConverter=Ascii to HTML converter AsciiToPdfConverter=Ascii to PDF converter TableNotEmptyDropCanceled=Table not empty. Drop has been canceled. ModuleBuilderNotAllowed=The module builder is available but not allowed to your user. +ImportExportProfiles=Import and export profiles \ No newline at end of file diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 0875be0dc07..9638dfe5a25 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -396,3 +396,5 @@ ActionAvailableOnVariantProductOnly=Action only available on the variant of prod ProductsPricePerCustomer=Product prices per customers ProductSupplierExtraFields=Additional Attributes (Supplier Prices) DeleteLinkedProduct=Delete the child product linked to the combination +PMPValue=Weighted average price +PMPValueShort=WAP diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8654e9c5b11..5960f900cca 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -56,8 +56,6 @@ UnitPurchaseValue=Unit purchase price StockTooLow=Stock too low StockLowerThanLimit=Stock lower than alert limit (%s) EnhancedValue=Value -PMPValue=Weighted average price -PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user AllowAddLimitStockByWarehouse=Manage also value for minimum and desired stock per pairing (product-warehouse) in addition to the value for minimum and desired stock per product diff --git a/htdocs/langs/fa_IR/main.lang b/htdocs/langs/fa_IR/main.lang index e06cabfcf01..9cd002fb039 100644 --- a/htdocs/langs/fa_IR/main.lang +++ b/htdocs/langs/fa_IR/main.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - main -DIRECTION=چپ‌به‌راست +DIRECTION=rtl # Note for Chinese: # msungstdlight or cid0ct are for traditional Chinese (traditional does not render with Ubuntu pdf reader) # stsongstdlight or cid0cs are for simplified Chinese diff --git a/htdocs/langs/zh_CN/main.lang b/htdocs/langs/zh_CN/main.lang index 917bbfefb1c..458863d28bc 100644 --- a/htdocs/langs/zh_CN/main.lang +++ b/htdocs/langs/zh_CN/main.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - main -DIRECTION=升 +DIRECTION=ltr # Note for Chinese: # msungstdlight or cid0ct are for traditional Chinese (traditional does not render with Ubuntu pdf reader) # stsongstdlight or cid0cs are for simplified Chinese diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index dc5a84071d7..35e5e5b81b0 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -726,9 +726,33 @@ if ($dirins && $action == 'initdoc' && !empty($module)) { // add Language if ($dirins && $action == 'addlanguage' && !empty($module)) { $newlangcode = GETPOST('newlangcode', 'aZ09'); - $srcfile = $dirins.'/'.strtolower($module).'/langs/en_US'; - $destfile = $dirins.'/'.strtolower($module).'/langs/'.$newlangcode; - $result = dolCopyDir($srcfile, $destfile, 0, 0); + + if ($newlangcode) { + $modulelowercase = strtolower($module); + + // Dir for module + $diroflang = dol_buildpath($modulelowercase, 0); + + if ($diroflang == $dirread.'/'.$modulelowercase) { + // This is not a custom module, we force diroflang to htdocs root + $diroflang = $dirread; + + $srcfile = $diroflang.'/langs/en_US/'.$modulelowercase.'.lang'; + $destfile = $diroflang.'/langs/'.$newlangcode.'/'.$modulelowercase.'.lang'; + + $result = dol_copy($srcfile, $destfile, 0, 0); + if ($result < 0) { + setEventMessages($langs->trans("ErrorFailToCopyFile", $srcfile, $destfile), null, 'errors'); + } + } else { + $srcfile = $diroflang.'/langs/en_US'; + $destfile = $diroflang.'/langs/'.$newlangcode; + + $result = dolCopyDir($srcfile, $destfile, 0, 0); + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors'); + } } @@ -1448,17 +1472,37 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { $tabobj = 'deleteobject'; } +if ($dirins && $action == 'generatedoc') { + $modulelowercase = strtolower($module); + + // Dir for module + $dirofmodule = dol_buildpath($modulelowercase, 0).'/doc'; + + $FILENAMEDOC = strtolower($module).'.html'; + + $util = new Utils($db); + $result = $util->generateDoc($module); + + if ($result > 0) { + setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null); + } else { + setEventMessages($util->error, $util->errors, 'errors'); + } +} if ($dirins && $action == 'generatepackage') { $modulelowercase = strtolower($module); + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + // Dir for module - $dir = $dirins.'/'.$modulelowercase; + $dir = dol_buildpath($modulelowercase, 0); + // Zip file to build $FILENAMEZIP = ''; // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + dol_include_once($pathtofile); $class = 'mod'.$module; if (class_exists($class)) { @@ -1466,18 +1510,18 @@ if ($dirins && $action == 'generatepackage') { $moduleobj = new $class($db); } catch (Exception $e) { $error++; - dol_print_error($e->getMessage()); + dol_print_error($db, $e->getMessage()); } } else { $error++; $langs->load("errors"); - dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); exit; } $arrayversion = explode('.', $moduleobj->version, 3); if (count($arrayversion)) { - $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2] ? ".".$arrayversion[2] : "").".zip"; + $FILENAMEZIP = "module_".$modulelowercase.'-'.$arrayversion[0].($arrayversion[1] ? '.'.$arrayversion[1] : '').($arrayversion[2] ? '.'.$arrayversion[2] : '').'.zip'; $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; @@ -1504,20 +1548,6 @@ if ($dirins && $action == 'generatepackage') { } } -if ($dirins && $action == 'generatedoc') { - $FILENAMEDOC = strtolower($module).'.html'; - $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc'; - - $util = new Utils($db); - $result = $util->generateDoc($module); - - if ($result > 0) { - setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null); - } else { - setEventMessages($util->error, $util->errors, 'errors'); - } -} - // Save file if ($action == 'savefile' && empty($cancel)) { @@ -2125,11 +2155,26 @@ if ($module == 'initmodule') { print '
'; print '
'; - $langfiles = dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); + $modulelowercase = strtolower($module); + + // Dir for module + $diroflang = dol_buildpath($modulelowercase, 0); + $diroflang .= '/langs'; + $langfiles = dol_dir_list($diroflang, 'files', 1, '\.lang$'); + + if (!preg_match('/custom/', $dirread)) { + // If this is not a module into custom + $diroflang = $dirread; + $diroflang .= '/langs'; + $langfiles = dol_dir_list($diroflang, 'files', 1, $modulelowercase.'\.lang$'); + } print ''; foreach ($langfiles as $langfile) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; + if (!preg_match('/custom/', $dirread)) { // If this is not a module into custom + $pathtofile = 'langs/'.$langfile['relativename']; + } print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; @@ -3812,12 +3857,12 @@ if ($module == 'initmodule') { $moduleobj = new $class($db); } catch (Exception $e) { $error++; - dol_print_error($e->getMessage()); + dol_print_error($db, $e->getMessage()); } } else { $error++; $langs->load("errors"); - dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); exit; } diff --git a/htdocs/modulebuilder/template/.gitignore b/htdocs/modulebuilder/template/.gitignore index 150a55149b6..70479d0eb63 100644 --- a/htdocs/modulebuilder/template/.gitignore +++ b/htdocs/modulebuilder/template/.gitignore @@ -1,5 +1,6 @@ # Generated binaries /build/*.zip +/bin/*.zip # Doxygen generated documentation /build/doxygen/doxygen_warnings.log /doc/code/doxygen diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 769c1529aff..bc52cf7378f 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -158,7 +158,7 @@ class MyModuleApi extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang b/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang deleted file mode 100644 index 20d9cb64259..00000000000 --- a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang +++ /dev/null @@ -1,48 +0,0 @@ -# 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 . - -# -# Générique -# - -# Module label 'ModuleMyModuleName' -ModuleMyModuleName = Mon module -# Module description 'ModuleMyModuleDesc' -ModuleMyModuleDesc = Description de MyModule - -# -# Page d'administration -# -MyModuleSetup = Configuration du module MyModule -Settings = Réglages -MyModuleSetupPage = Page de configuration du module MyModule - -# -# Page À propos -# -About = À propos -MyModuleAbout = À propos de MyModule -MyModuleAboutPage = Page à propos de MyModule - -# -# Page d'exemple -# -MyPageName = Nom de ma page - -# -# Box d'exemple -# -MyWidget = Mon widget -MyWidgetDescription = Description de mon widget diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 89c787e5a01..31bb4fd36ab 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -458,10 +458,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } } diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 48f93976d29..a2558fe6252 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -150,7 +150,7 @@ class Mos extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 8f5336450b8..3a8c1be819e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -46,7 +46,8 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id_rate_selected = GETPOST('id_rate', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_date_sync = GETPOST('search_date_sync', 'alpha'); +$search_date_sync = dol_mktime(0, 0, 0, GETPOST('search_date_syncmonth', 'int'), GETPOST('search_date_syncday', 'int'), GETPOST('search_date_syncyear', 'int')); +$search_date_sync_end = dol_mktime(0, 0, 0, GETPOST('search_date_sync_endmonth', 'int'), GETPOST('search_date_sync_endday', 'int'), GETPOST('search_date_sync_endyear', 'int')); $search_rate = GETPOST('search_rate', 'alpha'); $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -64,12 +65,8 @@ if (empty($page) || $page == -1) { $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) { - $sortfield = "cr.date_sync"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "cr.date_sync"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -199,18 +196,12 @@ if ($action == "confirm_delete") { } -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -219,6 +210,7 @@ if (empty($reshook)) { 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 $sall = ""; $search_date_sync = ""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -240,7 +232,7 @@ if (empty($reshook)) { $htmlother = new FormOther($db); $title = $langs->trans("CurrencyRate"); -$page_name = "ListCurrencyRate"; +$page_name = "MultiCurrencySetup"; $help_url = ''; llxHeader('', $title, $help_url, ''); @@ -254,7 +246,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if ($action != "updateRate") { +if (!in_array($action, array("updateRate", "deleteRate"))) { print ''; print ''; print ''."\n"; @@ -264,18 +256,18 @@ if ($action != "updateRate") { print ''; print ''; - print '
'.$langs->trans("FormCreateRate").'
'; + print '
'; print ' '; print ' '; print ''; - print ''; + print ''; print ' '; - print ' '; + print ' '; print '
'.$langs->trans('Date').''; - print $form->selectDate($dateinput, 'dateinput'); + print $form->selectDate($dateinput, 'dateinput', 0, 0, 1); print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; print ''; @@ -288,54 +280,7 @@ if ($action != "updateRate") { print '
'; } -if ($action == "updateRate") { - $current_rate = new CurrencyRate($db); - $current_rate->fetch(intval($id_rate_selected)); - if ($current_rate) { - $curr = new MultiCurrency($db); - $resultcurrentCurrency = $curr->fetch($current_rate->fk_multicurrency); - - if ($resultcurrentCurrency) { - $currency_code = $curr->code; - } else { - $currency_code = ''; - } - - print ''; - print ''; - print ''."\n"; - print '
'.$langs->trans("FormUpdateRate").'
'; - - $form = new Form($db); - print ''; - print ''; - - print ''; - print ' '; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print '
'.$langs->trans('Date').''; - print $form->selectDate($current_rate->date_sync, 'dateinput'); - print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; - print ''; - print ''; - print ''; - print ''.$langs->trans('CancelUpdate').''; - - print '
'; - print ''; - } else { - dol_syslog("currency_rate:list:update", LOG_WARNING); - } -} $sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; @@ -345,18 +290,14 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); -} -if ($search_date_sync) { - $sql .= natural_search('cr.date_sync', $search_date_sync); -} -if ($search_rate) { - $sql .= natural_search('cr.rate', $search_rate); -} -if ($search_code) { - $sql .= natural_search('m.code', $search_code); +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_date_sync && $search_date_sync_end ) { + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +} elseif ($search_date_sync && !$search_date_sync_end) { + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } +if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); +if ($search_code) $sql .= natural_search('m.code', $search_code); $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; // Add where from hooks @@ -406,15 +347,10 @@ if ($resql) { $param .= "&sall=".urlencode($sall); } - if ($search_date_sync) { - $param = "&search_date_sync=".urlencode($search_date_sync); - } - if ($search_rate) { - $param = "&search_rate=".urlencode($search_rate); - } - if ($search_code != '') { - $param .= "&search_code=".urlencode($search_code); - } + if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; + if ($search_rate) $param = "&search_rate=".urlencode($search_rate); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -475,7 +411,7 @@ if ($resql) { } print '
'; - print ''."\n"; + print '
'."\n"; // Lines with input filters print ''; @@ -483,16 +419,17 @@ if ($resql) { // date if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } - // code + // code if (!empty($arrayfields['m.code']['checked'])) { print ''; } - // rate + // rate if (!empty($arrayfields['cr.rate']['checked'])) { print ''; - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) { - print '\n"; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; + + print ''; + } else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) { + print '\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + + // Fields from hook + $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action + print ''; if (!$i) { $totalarray['nbfield']++; } + + print "\n"; + $i++; } - - // code - if (!empty($arrayfields['m.code']['checked'])) { - print '\n"; - - if (!$i) { - $totalarray['nbfield']++; - } - } - - // rate - if (!empty($arrayfields['cr.rate']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - $i++; } $db->free($resql); @@ -604,5 +551,5 @@ if ($resql) { } -llxFooter(); -$db->close(); + llxFooter(); + $db->close(); diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index aa6c136146e..5c2b46415b6 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -548,10 +548,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); } } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 0c70af86c9c..fbbf17628ba 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -216,7 +216,8 @@ class Products extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + //var_dump($sqlfilters);exit; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; // We must accept datc:<:2020-01-01 10:10:10 $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -849,9 +850,10 @@ class Products extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -975,7 +977,7 @@ class Products extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -1566,7 +1568,8 @@ class Products extends DolibarrApi /** * Get product variants. * - * @param int $id ID of Product + * @param int $id ID of Product + * @param int $includestock Default value 0. If parameter is set to 1 the response will contain stock data of each variant * @return array * * @throws RestException 500 @@ -1574,7 +1577,7 @@ class Products extends DolibarrApi * * @url GET {id}/variants */ - public function getVariants($id) + public function getVariants($id, $includestock = 0) { if (!DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(401); @@ -1587,6 +1590,13 @@ class Products extends DolibarrApi $prodc2vp = new ProductCombination2ValuePair($this->db); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); + + if ($includestock==1) { + $productModel = new Product($this->db); + $productModel->fetch((int) $combination->fk_product_child); + $productModel->load_stock(); + $combinations[$key]->stock_warehouse = $this->_cleanObjectDatas($productModel)->stock_warehouse; + } } return $combinations; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f7275b54570..5d622c05c29 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2183,12 +2183,43 @@ class Product extends CommonObject } else { $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export, ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; } - $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + + //For MultiCompany + //PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity + $separatedEntityPMP = false; + $separatedStock = false; + if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)) { + if (!empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { + $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); + if ($this->db->num_rows($checkPMPPerEntity)>0) { + $separatedEntityPMP = true; + } + } + global $mc; + $separatedStock = true; + $visibleWarehousesEntities = $conf->entity; + if (isset($mc->sharings['stock']) && !empty($mc->sharings['stock'])) { + $visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']); + } + } + if ($separatedStock) { + $sql .= " SUM(sp.reel) as stock,"; + } else { + $sql .= " p.stock,"; + } + if ($separatedEntityPMP) { + $sql .= " pa.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + } else { + $sql .= " p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + } $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) || $separatedEntityPMP) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } + if ($separatedStock) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as sp ON sp.fk_product = p.rowid"; + } if ($id) { $sql .= " WHERE p.rowid = ".((int) $id); } else { @@ -2201,6 +2232,12 @@ class Product extends CommonObject $sql .= " AND p.barcode = '".$this->db->escape($barcode)."'"; } } + if ($separatedStock) { + $sql .= " AND sp.fk_entrepot IN ( + SELECT rowid + FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (" . $this->db->sanitize($visibleWarehousesEntities) ."))"; + } + $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 983e0089fe5..b8698ff7ad3 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -605,7 +605,18 @@ if ($action == 'create') { $totalunit = 0; $totalvalue = $totalvaluesell = 0; - $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; + //For MultiCompany PMP per entity + $separatedPMP = false; + if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { + $separatedPMP = true; + } + + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.price, p.price_ttc, p.entity,"; + if ($separatedPMP) { + $sql .= " pa.pmp as ppmp,"; + } else { + $sql .= " p.pmp as ppmp,"; + } $sql .= " ps.reel as value"; if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ",fk_unit"; @@ -618,9 +629,19 @@ if ($action == 'create') { } $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; + + if ($separatedPMP) { + $sql .= ", ".MAIN_DB_PREFIX."product_perentity as pa"; + } + $sql .= " WHERE ps.fk_product = p.rowid"; $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) $sql .= " AND ps.fk_entrepot = ".$object->id; + + if ($separatedPMP) { + $sql .= " AND pa.fk_product = p.rowid AND pa.entity = ". (int) $conf->entity; + } + $sql .= $db->order($sortfield, $sortorder); dol_syslog('List products', LOG_DEBUG); diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 90b3895c0f2..9b022a840fc 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -112,7 +112,7 @@ class StockMovements extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index 34338232169..806114b73ec 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -119,7 +119,7 @@ class Warehouses extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 8bd250bc76e..dc15e092155 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -610,15 +610,31 @@ class Entrepot extends CommonObject */ public function nb_products() { + global $conf; // phpcs:enable $ret = array(); - $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; + //For MultiCompany PMP per entity + $separatedPMP = false; + if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { + $separatedPMP = true; + } + + if ($separatedPMP) { + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * pa.pmp) as value"; + } else { + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; + } $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= ", ".MAIN_DB_PREFIX."product as p"; + if ($separatedPMP) { + $sql .= ", ".MAIN_DB_PREFIX."product_perentity as pa"; + } $sql .= " WHERE ps.fk_entrepot = ".$this->id; + if ($separatedPMP) { + $sql .= " AND pa.fk_product = p.rowid AND pa.entity = ". (int) $conf->entity; + } $sql .= " AND ps.fk_product = p.rowid"; - //print $sql; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index d49db2f7b02..ae8b13c776f 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -208,7 +208,16 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } } -$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; + +//For Multicompany PMP per entity +$separatedPMP = false; +if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED) && !empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { + $separatedPMP = true; + $sql .= " SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; +} else { + $sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; +} + // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -225,7 +234,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_ent $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays"; +if ($separatedPMP) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = ". (int) $conf->entity; +} + $sql .= " WHERE t.entity IN (".getEntity('stock').")"; + if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "t.rowid", $search_category_list); } @@ -273,6 +287,7 @@ $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $totalnboflines = 0; + $result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index c5430b655b1..b0b94264fb0 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -153,7 +153,7 @@ class Projects extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 2c3fd107d53..e3d6af2de53 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -153,7 +153,7 @@ class Tasks extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 8659b3ca8bd..7007455791a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1444,20 +1444,18 @@ if ($source == 'member' || $source == 'membersubscription') { print '\n"; - } - if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $adht = new AdherentType($db); // Amount by member type - $amountbytype = array(); // TODO Read the amount of subscription into table of types + $amountbytype = $adht->amountByType(1); // Set the member type $member->typeid = (int) (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid); // If we change the type of membership, we set also label of new type $member->type = dol_getIdFromCode($db, $member->typeid, 'adherent_type', 'rowid', 'libelle'); // Set amount for the subscription - $amount = (!empty($member->last_subscription_amount)) ? $member->last_subscription_amount : $amountbytype[$member->typeid]; + $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount; // list member type - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $adht = new AdherentType($db); if ( !$action) { $form = new Form($db); // so we can call method selectarray print ''; print ''; print ''; diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 5a6513ef6e5..f62fb894bd0 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -219,7 +219,7 @@ class Contacts extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 1de2f436ca7..af9122cba9d 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -205,7 +205,7 @@ class Thirdparties extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 2a6dd2176df..7425f094958 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -316,7 +316,7 @@ if ($id > 0 || !empty($ref)) { print ''; } else { print '
'; - print ''; + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; - print ''; + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print ''; print ''; @@ -537,60 +474,70 @@ if ($resql) { print '
'; - print $obj->date_sync; - print "' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; + print $obj->code." ".$obj->name; + print "'; + print $obj->rate; + 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 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print '
'; - print $obj->code." ".$obj->name; - print "'; - print $obj->rate; - 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 'rowid.'">'.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print '
'.$langs->trans("LastMemberType"); print ''.dol_escape_htmltag($member->type); print "
'.$langs->trans("NewSubscription"); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 4fed66d8960..607efb9606b 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -785,7 +785,7 @@ if ($action == 'create') { print '
'.$langs->trans("Project").''; print img_picto('', 'project', 'class="paddingright"'); - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); + print $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); print '   id).'">'; print '
'; - if ($objp->subscription == 'yes') { + if (!empty($objp->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) { print " ".img_warning(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index d5b4974eb83..809e84b29a8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1773,10 +1773,12 @@ if ($action == 'create') { if ($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate) { if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine($dateSelector, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine($dateSelector, $soc, $mysoc); } } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 3e38ac10b41..61ba9c48de3 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -142,7 +142,7 @@ class Supplierproposals extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 9f057fe46c1..6f05daba22f 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -86,7 +86,7 @@ span.butAction, span.butActionDelete { text-align: center; cursor: pointer; color: #444; - border: 1px solid transparent; /* So for buttonRefused with a border, it will not have any flash effect */ + border: 1px solid transparent; /* So for buttonRefused with a border, it will not have any flash effect */ /* border: 1px solid #aaa; */ /* border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25); */ diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index f96844e1655..e026b6d5762 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4420,7 +4420,7 @@ div.backgreypublicpayment { background-color: #f0f0f0; padding: 20px; border-bot color: #222; opacity: 0.3; } -#dolpaymenttable { min-width: 290px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ +#dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } @@ -6735,6 +6735,13 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before font-family: "Font Awesome 5 Free" !important; } +/* ============================================================================== */ +/* CSS style used for jCrop */ +/* ============================================================================== */ + +.jcrop-holder { background: unset !important; } + + /* ============================================================================== */ /* CSS style used for jFlot */ /* ============================================================================== */ diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 82cbf9cf2a9..16d4b58663b 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -115,6 +115,7 @@ $badgeStatus7 = '#25a580'; $badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; $badgeStatus10 = '#993013'; +$badgeStatus11 = '#15a540'; // status color ajustement for color blind $colorblind_deuteranopes_badgeStatus4 = $colorblind_deuteranopes_badgeStatus7 = $colorblind_deuteranopes_badgeSuccess; //! text color black diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 17b166d373c..0b09b141258 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6586,6 +6586,14 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before font-family: "Font Awesome 5 Free" !important; } + +/* ============================================================================== */ +/* CSS style used for jCrop */ +/* ============================================================================== */ + +.jcrop-holder { background: unset !important; } + + /* ============================================================================== */ /* CSS style used for jFlot */ /* ============================================================================== */ diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index 617f9d1301e..9e98a863737 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -98,3 +98,4 @@ $badgeStatus7 = '#277d1e'; $badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; $badgeStatus10 = '#993013'; +$badgeStatus11 = '#15a540'; diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index f814beb3398..7f2d2cf1be0 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -277,7 +277,7 @@ class Tickets extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index f06cf2c09ba..f5f0b73a70f 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -100,7 +100,7 @@ class Users extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -312,7 +312,6 @@ class Users extends DolibarrApi if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { // This properties can't be set/modified with API throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); - continue; } /*if ($field == 'pass') { if (empty(DolibarrApiAccess::$user->rights->user->user->password)) { @@ -366,7 +365,6 @@ class Users extends DolibarrApi if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) { // This properties can't be set/modified with API throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs"); - continue; } if ($field == 'pass') { if ($this->useraccount->id != DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->user->password)) { @@ -537,7 +535,7 @@ class Users extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7de7eb5f0bb..de7fad9f133 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2366,7 +2366,7 @@ class User extends CommonObject * Use this->id,this->lastname, this->firstname * * @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) - * @param string $option On what the link point to ('leave', 'nolink', ) + * @param string $option On what the link point to ('leave', 'accountancy', 'nolink', ) * @param integer $infologin 0=Add default info tooltip, 1=Add complete info tooltip, -1=No info tooltip * @param integer $notooltip 1=Disable tooltip on picto and name * @param int $maxlen Max length of visible user name @@ -2417,6 +2417,9 @@ class User extends CommonObject if (!empty($this->admin)) { $label .= '
'.$langs->trans("Administrator").': '.yn($this->admin); } + if (!empty($this->accountancy_code) || $option == 'accountancy') { + $label .= '
'.$langs->trans("AccountancyCode").': '.$this->accountancy_code; + } $company = ''; if (!empty($this->socid)) { // Add thirdparty for external users $thirdpartystatic = new Societe($db); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index c141588a7f9..db1073c6299 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -199,7 +199,7 @@ class ZapierApi extends DolibarrApi if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index d9ba2e267e9..63b55dd37aa 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -154,6 +154,7 @@ class AdherentTest extends PHPUnit\Framework\TestCase $localobject->statut=1; $localobject->label='Adherent type test'; $localobject->subscription=1; + $localobject->amount=0; $localobject->vote=1; $localobject->company='Old company label'; $result=$localobject->create($user); diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 4835a8afd76..960dd56c4b5 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -29,6 +29,7 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/images.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; @@ -164,8 +165,16 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase $file=dirname(__FILE__).'/img250x20.png'; $filetarget=$conf->admin->dir_temp.'/img250x20.jpg'; + dol_delete_file($filetarget); $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); print __METHOD__." result=".$result."\n"; - $this->assertEquals($filetarget, $result, 'Failed to convert into '.$filetarget); + $this->assertEquals($filetarget, $result, 'Failed to convert PNG '.$file.' into '.$filetarget); + + /*$file=dirname(__FILE__).'/img250x20.png'; + $filetarget=$conf->admin->dir_temp.'/img250x20.webp'; + dol_delete_file($filetarget); + $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($filetarget, $result, 'Failed to convert PNG '.$file.' into WEBP '.$filetarget);*/ } } diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index ad76667d560..99f74dbd4fa 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -184,6 +184,10 @@ class LangTest extends PHPUnit\Framework\TestCase $tmplangs->setDefaultLang($langcode); $tmplangs->load("main"); + $result=$tmplangs->transnoentitiesnoconv("DIRECTION"); + print __METHOD__." DIRECTION=".$result."\n"; + $this->assertTrue(in_array($result, array('rtl', 'ltr')), 'Error for vale of DIRECTION in main.lang file '.$code); + $result=$tmplangs->transnoentitiesnoconv("SeparatorDecimal"); print __METHOD__." SeparatorDecimal=".$result."\n"; $this->assertContains($result, array('.',',','/',' ','','None'), 'Error for decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported