diff --git a/.gitattributes b/.gitattributes index 4b0ed3d14b5..de9ce3303a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,26 +11,31 @@ *.htm text eol=lf *.html text eol=lf *.js text eol=lf +*.json text eol=lf *.css text eol=lf *.lang text eol=lf *.txt text eol=lf *.md text eol=lf *.pp text eol=lf *.sh text eol=lf +*.yml text eol=lf *.yaml text eol=lf +*.conf text eol=lf .bash_aliases text eol=lf # Denote all files that are truly binary and should not be modified. *.bmp binary -*.ico binary -*.png binary -*.jpg binary -*.odt binary -*.odf binary *.frm binary +*.ico binary +*.jpeg binary +*.jpg binary *.MYD binary *.MYI binary +*.odf binary +*.odt binary +*.png binary + # Export ignores to generate clean production tarballs /build export-ignore diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 9a84fdbbda0..1c46e8e2d50 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -77,8 +77,8 @@ contact@dolibarr.org ## 10. License and attribution -This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). +This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](https://creativecommons.org/licenses/by-sa/3.0/). -Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). +Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](https://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). -Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/) +Retrieved on November 22, 2016 from [https://citizencodeofconduct.org/](http://citizencodeofconduct.org/) diff --git a/.travis.yml b/.travis.yml index 733e997bdf3..22d4b2b0827 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ # This script is used by Travis CI to run automatically Continuous test integration # from Dolibarr GitHub repository. -# For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +# For syntax, see https://docs.travis-ci.com/user/languages/php/ # We use dist: xenial to have php 5.6+ available os: linux diff --git a/COPYING b/COPYING index 2a000655e93..e60008693e0 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/COPYRIGHT b/COPYRIGHT index 21e37f39f1d..b133b05b2cf 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -23,7 +23,7 @@ PEAR Mail_MIME 1.8.9 BSD Yes 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 -PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files +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 diff --git a/ChangeLog b/ChangeLog index d4a8b55625f..4734605b7d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,10 +7,13 @@ English Dolibarr ChangeLog For users: ---------- +NEW: Several security issues after a second private bug bounty campaign. + For developers: --------------- +* start new module EventOrganization @@ -19,11 +22,12 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup. * API /setup/shipment_methods has been replaced with API /setup/shipping_methods +* Field "total" renamed into to "total_ht" for table llx_facture, llx_facture_rec for better field name consistency * Field "tva" renamed into "total_tva" for table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency * Field "total" renamed into "total_ttc" for table lx_propal, llx_supplier_proposal for better field name consistency * If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT) * If your database is MySql or MariaDB, you need at least version 5.1 - +* Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules ***** ChangeLog for 13.0.2 compared to 13.0.1 ***** @@ -47,21 +51,21 @@ FIX: #16533 FIX: #16629 FIX: #16671 Can not generate zip file of documents in backup tool FIX: Add "Now" link on social charges creation card -FIX: avoid undefined url and missing token +FIX: avoid undefined URL and missing token FIX: Bad project filter in ticket list FIX: Buttons to disable bindings not working FIX: class not found when creating recuring invoice from invoice+discount -FIX: File attachment on lots +FIX: File attachment on lots/batches FIX: handling $heightforinfotot when he's superior to a page height on Supplier Invoice FIX: hourglass and hide button to pay -FIX: massaction validate invoice do not regenerate pdf +FIX: massaction validate invoice do not regenerate PDF FIX: missing mp4 video mime FIX: picto on shipment to reset qty to 0. Some quantities were not reset. FIX: Protection to avoid #16504 FIX: rounding amount on card updating -FIX: Rounding amount on social charges card updating +FIX: rounding amount on social charges card updating FIX: select list dependencies now work for ModuleBuilder sellist field -FIX: Status in popup of member in widget +FIX: status in popup of member in widget FIX: status on tooltip on widgets FIX: Timezone management for datetime on list of events FIX: Timezone management for datetime with modulebuilder and extrafields @@ -92,9 +96,9 @@ FIX: #16135 FIX: #16143 FIX: #16156 FIX: #16160 -FIX: #16165 Create customer discount without vat +FIX: #16165 Create customer discount without VAT FIX: #16185 -FIX: #16189, fix download/see check deposit PDF +FIX: #16189 fix download/see check deposit PDF FIX: #16215 FIX: Accountancy - label_operation is used instead of label_compte FIX: Add critical price patch @@ -104,7 +108,7 @@ FIX: cash fence for takepos with multientity FIX: CSRF errors on margin forms FIX: encoding status in graph of vendor proposals FIX: Fix detect dispached product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES) -FIX: Hide/Unhide external ICSS calendars +FIX: hide/unhide external ICS calendars FIX: link to create event when task is in a project with a thirdparty FIX: Localtax must be converted with price2num FIX: manage price min for PRODUIT_CUSTOMER_PRICES @@ -125,7 +129,7 @@ FIX: warning when adding a line if $remise_percent is an empty string FIX: status late on purchase orders FIX: ODT generation very slow FIX: amount in summary of report -FIX: vat value when code contains number +FIX: VAT value when code contains number FIX: payment term label on PDF FIX: date selector when using reduced year (like on smartphone) @@ -144,7 +148,7 @@ NEW: Accountancy - add options to disable binding on sales, purchases & expense NEW: Accountancy balance - add a menu entry to show subtotal by group NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default -NEW: Accountancy - Add export for Gestinum (v3 & v5) #15180 +NEW: Accountancy - add export for Gestinum (v3 & v5) #15180 NEW: new currency rate editor NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock. NEW: add a widget to show the customers with outstanding limits reached diff --git a/README.md b/README.md index ad4971f50db..0a3aeecb9f4 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Main application/modules (all optional) - Customers, Prospects (Leads) and/or Suppliers directory + Contacts -- Members management +- Members/Membership management - Products and/or Services catalog - Commercial proposals management - Customer & Supplier Orders management @@ -112,6 +112,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Shared calendar/agenda (with ical and vcal export for third party tools integration) - Opportunities or Leads management - Projects & Tasks management +- Ticket System - Contracts management - Interventions management - Employee's leave requests management @@ -160,7 +161,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Canadian double taxes (federal/province) and other countries using cumulative VAT - Tunisian tax stamp - Argentina invoice numbering using A,B,C... - - Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) + - Compatible with [European directives] (https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - Compatible with European GDPR rules - ... - Flexible PDF & ODT generation for invoices, proposals, orders... diff --git a/SECURITY.md b/SECURITY.md index f63f9c3f277..7d65b7e98e4 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,7 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Reporting a Vulnerability -To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (or alternatively send an email to security@dolibarr.org) +To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) ## Hunting vulnerabilities on Dolibarr @@ -55,7 +55,7 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. * The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be set to 1 soon by default) -* The module DebugBar and ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool) +* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly. @@ -65,12 +65,12 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us Scope is the web application (back office) and the APIs. -## Qualifying vulnerabilities for Bug bounty programs +## Qualifying vulnerabilities for reporting * Remote code execution (RCE) * Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA) * Code injections (HTML, JS, SQL, PHP, ...) -* Cross-Site Scripting (XSS) +* Cross-Site Scripting (XSS), except from setup page of module "External web site" (allowing any content here, editable by admin user only, is accepted on purpose or into module "Web site" when permission to edit website content is allowed). * Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users) * Open redirect * Broken authentication & session management @@ -82,7 +82,7 @@ Scope is the web application (back office) and the APIs. * Stack traces or path disclosure (for non admin users only) -## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting +## Non-qualifying vulnerabilities for reporting * "Self" XSS * SSL/TLS best practices diff --git a/build/pdf/htmldoc_en.book b/build/pdf/htmldoc_en.book index f6c407f1bd2..5757128c7f5 100644 --- a/build/pdf/htmldoc_en.book +++ b/build/pdf/htmldoc_en.book @@ -1,4 +1,4 @@ #HTMLDOC 1.8.27 -t pdf14 -f "../../doc/dolibarr_en.pdf" --webpage --no-title --logoimage "../../doc/images/dolibarr_256x256.png" --linkcolor #2200c0 --linkstyle plain --size Universal --left 0.30in --right 0.30in --top 0.40in --bottom 0.30in --header ... --header1 ... --footer c/d --nup 1 --tocheader ... --tocfooter ... --portrait --color --no-pscommands --no-xrxcomments --compression=9 --jpeg=50 --fontsize 10.0 --fontspacing 1.0 --headingfont Helvetica --bodyfont Helvetica --headfootsize 9.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode document --pagelayout single --firstpage p1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680 --no-strict --no-overflow -http://wiki.dolibarr.org/index.php/Main_Page -http://wiki.dolibarr.org/index.php/What_Dolibarr_Do +https://wiki.dolibarr.org/index.php/Home +https://wiki.dolibarr.org/index.php/What_Dolibarr_Does diff --git a/build/sitemap/README b/build/sitemap/README index b98b5cc48d8..a06bd58f259 100644 --- a/build/sitemap/README +++ b/build/sitemap/README @@ -1,5 +1,5 @@ # Format of sitemap file is available at -# http://www.sitemaps.org/protocol.html +# https://www.sitemaps.org/protocol.html # To build a sitemap from urllist-bing.txt, run # google-sitemapgen --config=config-bing.xml --testing diff --git a/composer.json b/composer.json index bd81e101cfc..130fda34945 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", "mobiledetect/mobiledetectlib" : "2.8.34", - "phpoffice/phpexcel" : "1.8.1", + "phpoffice/phpexcel" : "1.8.2", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", "nnnick/chartjs" : "^2.9", diff --git a/composer.lock b/composer.lock index c588bc7783f..3e867f8f186 100644 --- a/composer.lock +++ b/composer.lock @@ -328,6 +328,63 @@ }, "time": "2020-03-23T09:12:05+00:00" }, + { + "name": "phpoffice/phpexcel", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PHPExcel.git", + "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870", + "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "php": "^5.2|^7.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "http://blog.maartenballiauw.be" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Franck Lefevre", + "homepage": "http://rootslabs.net" + }, + { + "name": "Mark Baker", + "homepage": "http://markbakeruk.net" + } + ], + "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PHPExcel", + "keywords": [ + "OpenXML", + "excel", + "xlsx" + ], + "abandoned": "phpoffice/phpspreadsheet", + "time": "2018-11-22T23:07:24+00:00" + }, { "name": "restler/framework", "version": "3.0.0-RC6", diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index 97b02fa3ac9..ea40710824c 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -102,8 +102,8 @@ for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++) { $produit->ref = ($produit->type?'S':'P').time().$s; $produit->label = 'Label '.time().$s; $produit->description = 'Description '.time().$s; - $produit->price = mt_rand(1, 1000); - $produit->tva_tx = "19.6"; + $produit->price = mt_rand(1, 999.99); + $produit->tva_tx = "20.0"; $ret=$produit->create($user); if ($ret < 0) { print "Error $ret - ".$produit->error."\n"; diff --git a/dev/resources/iso-normes/company_ids.txt b/dev/resources/iso-normes/company_ids.txt index 69c2af1d665..586628a4aac 100644 --- a/dev/resources/iso-normes/company_ids.txt +++ b/dev/resources/iso-normes/company_ids.txt @@ -1,2 +1,2 @@ -Spain https://incwell.eu/en/company-formation-spain/ + France https://www.economie.gouv.fr/entreprises/numeros-identification-entreprise diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf new file mode 100644 index 00000000000..d5922909ba9 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf @@ -0,0 +1,20 @@ +# Fail2Ban configuration file +# +# Regexp to catch known spambots and software alike. Please verify +# that it is your intent to block IPs which were driven by +# above mentioned bots. + + +[Definition] + +# To test, you can inject this example into log +# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 functions_dolibarr::check_user_password_abcd Authentication KO" >> /mypath/documents/dolibarr.log +# +# then +# fail2ban-client status web-dol-bruteforce +# +# To test rule file on a existing log file +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf + +failregex = ^ [A-Z\s]+ \s+functions_dolibarr::check_user_password_.* Authentication KO +ignoreregex = diff --git a/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf new file mode 100644 index 00000000000..edc2ca68092 --- /dev/null +++ b/dev/setup/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf @@ -0,0 +1,20 @@ +# Fail2Ban configuration file +# +# Regexp to catch known spambots and software alike. Please verify +# that it is your intent to block IPs which were driven by +# above mentioned bots. + + +[Definition] + +# To test, you can inject this example into log +# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 --- Access to GET /passwordforgotten.php - action=buildnewpassword, massaction=" >> /mypath/documents/dolibarr.log +# +# then +# fail2ban-client status web-dol-passforgotten +# +# To test rule file on a existing log file +# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf + +failregex = ^ [A-Z\s]+ \s+--- Access to .*/passwordforgotten.php - action=buildnewpassword +ignoreregex = diff --git a/dev/setup/fail2ban/jail.local b/dev/setup/fail2ban/jail.local new file mode 100644 index 00000000000..bd506e20812 --- /dev/null +++ b/dev/setup/fail2ban/jail.local @@ -0,0 +1,28 @@ +# +# Examle of rule you can add to fail2ban to restrict bruteforce attacks. +# + +[web-dol-passforgotten] + +; rule against call of passwordforgottenpage +enabled = true +port = http,https +filter = web-dolibarr-rulespassforgotten +logpath = >> /mypath/documents/documents/dolibarr.log +action = %(action_mw)s +bantime = 4320000 ; 50 days +findtime = 86400 ; 1 day +maxretry = 10 + +[web-dol-bruteforce] + +; rule against bruteforce hacking (login + api) +enabled = true +port = http,https +filter = web-dolibarr-rulesbruteforce +logpath = >> /mypath/documents/documents/dolibarr.log +action = %(action_mw)s +bantime = 86400 ; 1 day +findtime = 3600 ; 1 hour +maxretry = 10 + diff --git a/doc/user/README-DE.md b/doc/user/README-DE.md index ea9458f4563..4c7a635a522 100644 --- a/doc/user/README-DE.md +++ b/doc/user/README-DE.md @@ -6,7 +6,10 @@ Benutzeranleitung -------------------------------- Alle Dolibarr-Informationen sind online verfuegbar ueber die Webseiten: -https://www.dolibarr.de -oder -https://www.dolibarr.org -https://wiki.dolibarr.org + + +https://www.dolibarr.de (de) oder https://www.dolibarr.org (intl) + + +https://wiki.dolibarr.org/index.php/Hauptseite (de) + diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 8982376ded6..0876dd81a19 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -45,9 +45,14 @@ $search_label = GETPOST('search_label', 'alpha'); $search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$confirm = GETPOST('confirm', 'alpha'); $chartofaccounts = GETPOST('chartofaccounts', 'int'); +$permissiontodelete = $user->rights->accounting->chartofaccount; + // Security check if ($user->socid > 0) { accessforbidden(); @@ -104,7 +109,7 @@ if (!GETPOST('confirmmassaction', 'alpha')) { } $parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been monowraponalldified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } @@ -113,7 +118,12 @@ if (empty($reshook)) { if (!empty($cancel)) { $action = ''; } - + $objectclass = 'AccountingAccount'; + $uploaddir = $conf->accounting->multidir_output[$conf->entity]; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + if ($action == "delete") { + $action = ""; + } include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers @@ -218,7 +228,7 @@ if ($db->type == 'pgsql') { } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; } -$sql .= " WHERE asy.rowid = ".$pcgver; +$sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; @@ -279,6 +289,16 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } +// List of mass actions available +if ($user->rights->accounting->chartofaccount) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (in_array($massaction, array('presend', 'predelete', 'closed'))) { + $arrayofmassactions = array(); +} + +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); +$arrayofselected = is_array($toselect) ? $toselect : array(); $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql='.$sql); @@ -338,8 +358,8 @@ if ($resql) { print ''; $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); // Box to select active chart of account print $langs->trans("Selectchartofaccounts")." : "; @@ -349,7 +369,7 @@ if ($resql) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; $sql .= " WHERE a.active = 1"; dol_syslog('accountancy/admin/account.php $sql='.$sql); - print $sql; + $resqlchart = $db->query($sql); if ($resqlchart) { $numbis = $db->num_rows($resqlchart); @@ -376,9 +396,9 @@ if ($resql) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); $moreforfilter = ''; - $massactionbutton = ''; print '
'; print ''."\n"; @@ -411,34 +431,41 @@ if ($resql) { print ''; } print ''; print ''; - + $totalarray = array(); print ''; if (!empty($arrayfields['aa.account_number']['checked'])) { print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.label']['checked'])) { print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.labelshort']['checked'])) { print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_parent']['checked'])) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.pcg_type']['checked'])) { - print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); + print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); + $totalarray['nbfield']++; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } } if (!empty($arrayfields['aa.active']['checked'])) { print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -446,7 +473,6 @@ if ($resql) { $accountstatic = new AccountingAccount($db); $accountparent = new AccountingAccount($db); - $totalarray = array(); $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -563,7 +589,7 @@ if ($resql) { } // Action - print ''."\n"; if (!$i) { @@ -582,6 +616,11 @@ if ($resql) { $i++; } + if ($num == 0) { + $totalarray['nbfield']++; + print ''; + } + print "
 '; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; + print ''; if ($user->rights->accounting->chartofaccount) { print ''; print img_edit(); @@ -572,6 +598,14 @@ if ($resql) { print ''; print img_delete(); print ''; + print ' '; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } } print '
'.$langs->trans("None").'
"; print "
"; print ''; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 8f7d869479d..0ebba6c18a4 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -180,10 +180,6 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { } } // Other checks - if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system', 'systemauto'))) { - $ok = 0; - setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); - } if (GETPOSTISSET("pcg_version")) { if (GETPOST("pcg_version") == '0') { $ok = 0; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 7bb9d81607f..7e77817ac5c 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -32,9 +32,7 @@ $error = 0; // Load translation files required by the page $langs->loadLangs(array("bills", "accountancy")); -$mesg = ''; $id = GETPOST('id', 'int'); -$rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); $cat_id = GETPOST('account_category', 'int'); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 89c8a2b3b71..cb987055cea 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -149,7 +149,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { // Check that all fields are filled $ok = 1; foreach ($listfield as $f => $value) { - if ($value == 'formula' && empty($_POST['formula'])) { + if ($value == 'formula' && !GETPOST('formula')) { continue; } if ($value == 'range_account' && empty($_POST['range_account'])) { @@ -185,7 +185,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { } } if (GETPOSTISSET("code")) { - if ($_POST["code"] == '0') { + if (GETPOST("code") == '0') { $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } @@ -247,7 +247,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') { $sql .= "null"; // For vat, we want/accept code = '' } else { - $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'"; } $i++; } @@ -787,7 +787,7 @@ if ($id) { $class = 'tddict'; // Show value for field if ($showfield) { - print ''.$valuetoshow.''; + print ''.dol_escape_htmltag($valuetoshow).''; } } } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 410807144f5..16463ec027b 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -121,8 +121,8 @@ if ($action == 'confirm_delete' && $confirm == "yes") { if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); - $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; - $object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end; + $object->date_start = GETPOST("fiscalyear") ? $date_start : ''; + $object->date_end = GETPOST("fiscalyearend") ? $date_end : ''; $object->label = GETPOST('label', 'alpha'); $object->statut = GETPOST('statut', 'int'); diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b5443486648..4e56b5bfa2f 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -81,7 +81,7 @@ if ($action == 'update') { $constvalue = GETPOST($constname, 'alpha'); if ($constname == 'ACCOUNTING_DATE_START_BINDING') { - $constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); + $constvalue = dol_mktime(0, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int')); } if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index dd55e870009..2013b0c7295 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -98,6 +98,28 @@ if (empty($action)) { $arrayfields = array(); +$accounting_product_modes = array( + 'ACCOUNTANCY_SELL', + 'ACCOUNTANCY_SELL_INTRA', + 'ACCOUNTANCY_SELL_EXPORT', + 'ACCOUNTANCY_BUY', + 'ACCOUNTANCY_BUY_INTRA', + 'ACCOUNTANCY_BUY_EXPORT' +); + +if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $accountancy_field_name = "accountancy_code_buy"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $accountancy_field_name = "accountancy_code_buy_intra"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $accountancy_field_name = "accountancy_code_buy_export"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + $accountancy_field_name = "accountancy_code_sell"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + $accountancy_field_name = "accountancy_code_sell_intra"; +} else { // $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT' + $accountancy_field_name = "accountancy_code_sell_export"; +} /* * Actions @@ -133,15 +155,6 @@ if ($action == 'update') { if (!empty($btn_changetype)) { $error = 0; - $accounting_product_modes = array( - 'ACCOUNTANCY_SELL', - 'ACCOUNTANCY_SELL_INTRA', - 'ACCOUNTANCY_SELL_EXPORT', - 'ACCOUNTANCY_BUY', - 'ACCOUNTANCY_BUY_INTRA', - 'ACCOUNTANCY_BUY_EXPORT' - ); - if (in_array($accounting_product_mode, $accounting_product_modes)) { if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { $error++; @@ -153,7 +166,7 @@ if ($action == 'update') { if (!empty($btn_changeaccount)) { //$msg = '
' . $langs->trans("Processing") . '...
'; - if (!empty($chk_prod)) { + if (!empty($chk_prod) && in_array($accounting_product_mode, $accounting_product_modes)) { $accounting = new AccountingAccount($db); //$msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; @@ -175,26 +188,15 @@ if ($action == 'update') { } else { $db->begin(); - $sql = " UPDATE ".MAIN_DB_PREFIX."product"; - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " SET accountancy_code_buy = ".$accounting->account_number; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_perentity (fk_product, entity, '".$db->escape($accountancy_field_name)."')"; + $sql .= " VALUES (".((int) $productid).", ".((int) $conf->entity).", '".$db->escape($accounting->account_number)."')"; + $sql .= " ON DUPLICATE KEY UPDATE ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; + } else { + $sql = " UPDATE ".MAIN_DB_PREFIX."product"; + $sql .= " SET ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; + $sql .= " WHERE rowid = ".((int) $productid); } - if ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $sql .= " SET accountancy_code_buy_intra = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $sql .= " SET accountancy_code_buy_export = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql .= " SET accountancy_code_sell = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; - } - $sql .= " WHERE rowid = ".((int) $productid); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { @@ -267,50 +269,25 @@ if (empty($pcgvercode)) { } $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; -$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; -$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; + $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; +} else { + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +} $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; -if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; -} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; -} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; -} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; -} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { - $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; -if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy", $search_current_account); - } -} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); - } -} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); - } -} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell", $search_current_account); - } -} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); - } -} else { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); - } +if (strlen(trim($search_current_account))) { + $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, $search_current_account); } if ($search_current_account_valid == 'withoutvalidaccount') { $sql .= " AND aa.account_number IS NULL"; @@ -459,7 +436,7 @@ if ($result) { // On sell if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print ''.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).''; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + } else { // On buy print ''.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).''; } @@ -484,26 +461,12 @@ if ($result) { } print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); // On sell / On purchase - if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_intra"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_export"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + } else { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy_intra"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy_export"; } - print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); @@ -607,11 +570,10 @@ if ($result) { print vatrate($obj->tva_tx); print ''; + // On sell / On purchase if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print ''.$product_static->getLibStatut(3, 0).''; - } - - if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + } else { print ''.$product_static->getLibStatut(3, 1).''; } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index dcaa16ffd4e..9ad21bb2e0a 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -45,12 +45,12 @@ $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); -$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int')); -$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); +$search_date_creation_end = dol_mktime(23, 59, 59, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int')); -$search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); +$search_date_modification_end = dol_mktime(23, 59, 59, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); $search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int')); $search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); $search_date_validation_start = dol_mktime(0, 0, 0, GETPOST('date_validation_startmonth', 'int'), GETPOST('date_validation_startday', 'int'), GETPOST('date_validation_startyear', 'int')); @@ -538,7 +538,7 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_export = '".$db->idate($now)."'"; $sql .= " , date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql .= " WHERE rowid = ".((int) $movement->id); dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); $result = $db->query($sql); @@ -745,7 +745,9 @@ if (!empty($arrayfields['t.piece_num']['checked'])) { } // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { @@ -766,12 +768,10 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.numero_compte']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 1); print '
'; print '
'; - print $langs->trans('to').' '; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 1); print '
'; print ''; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 24bcc4706c1..406664938cc 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -46,7 +46,7 @@ $search_date_endyear = GETPOST('search_date_endyear', 'int'); $search_date_endmonth = GETPOST('search_date_endmonth', 'int'); $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); -$search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); $search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 292fb55a29f..3e171110c8b 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -428,7 +428,7 @@ class AccountancyCategory // extends CommonObject global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = ".$id; + $sql .= " WHERE t.fk_accounting_category = ".((int) $id); $sql .= " AND t.entity = ".$conf->entity; $this->lines_display = array(); @@ -743,7 +743,7 @@ class AccountancyCategory // extends CommonObject } $listofaccount .= "'".$cptcursor."'"; } - $sql .= " AND t.numero_compte IN (".$listofaccount.")"; + $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount).")"; } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; } @@ -863,7 +863,7 @@ class AccountancyCategory // extends CommonObject if (!empty($cat_id)) { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = ".$cat_id; + $sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id); $sql .= " AND t.entity = ".$conf->entity; $sql .= " ORDER BY t.account_number"; } else { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ac8c3db644b..ad3e863cc8c 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1644,7 +1644,7 @@ class AccountancyExport // Get new customer invoice ref and company name $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; - $sql .= ' WHERE f.rowid = ' . $line->fk_doc; + $sql .= ' WHERE f.rowid = '.((int) $line->fk_doc); $resql = $this->db->query($sql); if ($resql) { if ($obj = $this->db->fetch_object($resql)) { @@ -1658,7 +1658,7 @@ class AccountancyExport // Get new supplier invoice ref and company name $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; - $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; + $sql .= ' WHERE ff.rowid = '.((int) $line->fk_doc); $resql = $this->db->query($sql); if ($resql) { if ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/accountancy/class/accountancyimport.class.php b/htdocs/accountancy/class/accountancyimport.class.php new file mode 100644 index 00000000000..ece843515e2 --- /dev/null +++ b/htdocs/accountancy/class/accountancyimport.class.php @@ -0,0 +1,101 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre + * Copyright (C) 2016-2020 Alexandre Spangaro + * Copyright (C) 2013-2017 Olivier Geffroy + * Copyright (C) 2017 Elarifr. Ari Elbaz + * Copyright (C) 2017-2019 Frédéric France + * Copyright (C) 2017 André Schild + * Copyright (C) 2020 Guillaume Alexandre + * + * 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/accountancy/class/accountancyimport.class.php + * \ingroup Accountancy (Double entries) + * \brief Class accountancy import + */ + + + +/** + * Manage the different format accountancy import + */ +class AccountancyImport +{ + /** + * Compute amount + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues) + { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } + + $debit = trim($arrayrecord[11]['val']); + $credit = trim($arrayrecord[12]['val']); + if (!empty($debit)) { + $amount = $debit; + } else { + $amount = $credit; + } + + $listfields[] = $fieldname; + $listvalues[] = "'" . abs($amount) . "'"; + + return 1; + } + + + /** + * Compute sens + * + * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param string $fieldname Field name with alias + * @param array $listfields Fields list to add + * @param array $listvalues Values list to add + * @return int <0 if KO, >0 if OK + */ + public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues) + { + $fieldArr = explode('.', $fieldname); + if (count($fieldArr) > 0) { + $fieldname = $fieldArr[1]; + } + + $debit = trim($arrayrecord[11]['val']); + if (!empty($debit)) { + $sens = 'D'; + } else { + $sens = 'C'; + } + + $listfields[] = $fieldname; + $listvalues[] = "'" . $sens . "'"; + + return 1; + } +} diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index d1939b84665..afb9b502a9e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -199,7 +199,7 @@ class BookKeeping extends CommonObject $error = 0; - // Clean parameters + // Clean parameters if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -294,7 +294,10 @@ class BookKeeping extends CommonObject $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; - //$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines + 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 + } $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').")"; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index ad6f186d68f..b2abf01948e 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -126,7 +126,7 @@ class Lettering extends BookKeeping if (count($ids_fact)) { $sql = 'SELECT bk.rowid, facf.ref, facf.ref_supplier '; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (".implode(',', $ids_fact)."))"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = facf.rowid AND facf.rowid IN (".$this->db->sanitize(implode(',', $ids_fact))."))"; $sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND ( "; @@ -185,7 +185,7 @@ class Lettering extends BookKeeping if (count($ids_fact)) { $sql = 'SELECT bk.rowid, fac.ref, fac.ref_supplier '; $sql .= " FROM ".MAIN_DB_PREFIX."facture fac "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (".implode(',', $ids_fact)."))"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (".$this->db->sanitize(implode(',', $ids_fact))."))"; $sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; @@ -255,7 +255,7 @@ class Lettering extends BookKeeping } $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; - $sql .= " rowid IN (".implode(',', $ids).") AND date_validated IS NULL"; + $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL"; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -276,7 +276,7 @@ class Lettering extends BookKeeping $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; $sql .= " lettering_code='".$this->db->escape($lettre)."'"; $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false - $sql .= " WHERE rowid IN (".implode(',', $ids).") AND date_validated IS NULL "; + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL "; $this->db->begin(); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 3ba552cdfa4..390c288b606 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -91,9 +91,9 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql .= " SET date_validated = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; - $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; - $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; + $sql .= " WHERE rowid = ".((int) $movement->id); + $sql .= " AND doc_date >= '" . $db->idate($date_start) . "'"; + $sql .= " AND doc_date <= '" . $db->idate($date_end) . "'"; dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 98e9151877e..f0bcd9f7a49 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * * 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 @@ -61,7 +61,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { } $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " SET fk_code_ventilation = ".((int) $codeventil); $sql .= " WHERE rowid = ".((int) $id); $resql = $db->query($sql); @@ -100,10 +100,18 @@ $formaccounting = new FormAccounting($db); if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; - $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,"; + $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " pa.accountancy_code_sell as code_sell,"; + } else { + $sql .= " p.accountancy_code_sell as code_sell,"; + } $sql .= " l.fk_code_ventilation, aa.account_number, aa.label"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index a0da7ace065..0b32e2802c4 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * @@ -125,19 +125,34 @@ if ($action == 'validatehistory') { $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; - $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; + } else { + $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + } $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; - $sql .= " s.tva_intra, s.accountancy_code_sell as company_code_sell"; + $sql .= " s.tva_intra,"; + if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { + $sql .= " sa.accountancy_code_sell as company_code_sell"; + } else { + $sql .= " s.accountancy_code_sell as company_code_sell"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } + $alias_societe_perentity = empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "s" : "sa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; @@ -192,8 +207,8 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3b14450fab1..6f522750398 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.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) 2014-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -129,7 +129,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')'; + $sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); @@ -182,9 +182,13 @@ print ''."\n"; @@ -1038,6 +1040,7 @@ if ($rowid > 0) { // Bank account print ''.$langs->trans("FinancialAccount").''; + print img_picto('', 'bank_account'); $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); print "\n"; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index a69962e84b6..6b76fc3d502 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -191,7 +191,7 @@ if ($search_note) { $sql .= natural_search('c.note', $search_note); } if ($search_account > 0) { - $sql .= " AND b.fk_account = ".urldecode($search_account); + $sql .= " AND b.fk_account = ".((int) $search_account); } if ($search_amount) { $sql .= natural_search('c.subscription', $search_amount, 1); @@ -496,11 +496,14 @@ while ($i < min($num, $limit)) { $adherent->morphy = $obj->morphy; $adherent->email = $obj->email; $adherent->typeid = $obj->type; + $adherent->datefin = $db->jdate($obj->datef); $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); $adht = new AdherentType($db); $adht->fetch($typeid); + $adherent->need_subscription = $adht->subscription; + print ''; // Ref @@ -547,8 +550,8 @@ while ($i < min($num, $limit)) { // Label if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; - print dol_trunc($obj->note, 128); + print ''; + print $obj->note; print ''; if (!$i) { $totalarray['nbfield']++; @@ -586,7 +589,7 @@ while ($i < min($num, $limit)) { } // Price if (!empty($arrayfields['d.amount']['checked'])) { - print ''.price($obj->subscription).''; + print ''.price($obj->subscription).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index a99f1f990ad..84fe883e41f 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -15,8 +15,8 @@ * 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 . - * or see http://www.gnu.org/ + * along with this program. If not, see . + * or see https://www.gnu.org/ */ /** diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index a53cacd2212..902206c7874 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -30,71 +30,100 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php'; -$adherent = new adherent($db); - - $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alphanohtml'); + +$object = new adherent($db); + +// Fetch object +if ($id > 0 || !empty($ref)) { + // Load member + $result = $object->fetch($id, $ref); + + // Define variables to know what current user can do on users + $canadduser = ($user->admin || $user->rights->user->user->creer); + // Define variables to know what current user can do on properties of user linked to edited member + if ($object->user_id) { + // $User is the user who edits, $object->user_id is the id of the related user in the edited member + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer)); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password)); + } +} + +// Define variables to determine what the current user can do on the members +$canaddmember = $user->rights->adherent->creer; +// Define variables to determine what the current user can do on the properties of a member +if ($id) { + $caneditfieldmember = $user->rights->adherent->creer; +} // Security check -$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); +$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0); -$result = $adherent->fetch($id); -if ($result <= 0) { - dol_print_error($adherent->error); - exit; -} +/* + * Actions + */ -$physicalperson = 1; +// None + + +/* + * View + */ $company = new Societe($db); -if ($adherent->socid) { - $result = $company->fetch($adherent->socid); +if ($object->socid) { + $result = $company->fetch($object->socid); } + + // We create VCard $v = new vCard(); $v->setProdId('Dolibarr '.DOL_VERSION); -$v->setUid('DOLIBARR-ADHERENTID-'.$adherent->id); -$v->setName($adherent->lastname, $adherent->firstname, "", $adherent->civility, ""); -$v->setFormattedName($adherent->getFullName($langs, 1)); +$v->setUid('DOLIBARR-ADHERENTID-'.$object->id); +$v->setName($object->lastname, $object->firstname, "", $object->civility, ""); +$v->setFormattedName($object->getFullName($langs, 1)); -$v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE"); -//$v->setPhoneNumber($adherent->phone_perso,"TYPE=HOME;VOICE"); -$v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE"); -$v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX"); +$v->setPhoneNumber($object->phone_pro, "TYPE=WORK;VOICE"); +//$v->setPhoneNumber($object->phone_perso,"TYPE=HOME;VOICE"); +$v->setPhoneNumber($object->phone_mobile, "TYPE=CELL;VOICE"); +$v->setPhoneNumber($object->fax, "TYPE=WORK;FAX"); -$country = $adherent->country_code ? $adherent->country : ''; +$country = $object->country_code ? $object->country : ''; -$v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL"); -$v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); +$v->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK;POSTAL"); +$v->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=WORK"); -$v->setEmail($adherent->email); -$v->setNote($adherent->note_public); -$v->setTitle($adherent->poste); +$v->setEmail($object->email); +$v->setNote($object->note_public); +$v->setTitle($object->poste); // Data from linked company if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (!$adherent->phone_pro) { + if (!$object->phone_pro) { $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); } - if (!$adherent->fax) { + if (!$object->fax) { $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); } - if (!$adherent->zip) { + if (!$object->zip) { $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); } // when company e-mail is empty, use only adherent e-mail if (empty(trim($company->email))) { // was set before, don't set twice - } elseif (empty(trim($adherent->email))) { + } elseif (empty(trim($object->email))) { // when adherent e-mail is empty, use only company e-mail $v->setEmail($company->email); - } elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) { + } elseif (strtolower(end(explode("@", $object->email))) == strtolower(end(explode("@", $company->email)))) { // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) - $v->setEmail($adherent->email); + $v->setEmail($object->email); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); @@ -103,7 +132,7 @@ if ($company->id) { $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($adherent->email, 'INTERNET'); + $v->setEmail($object->email, 'INTERNET'); } // Si adherent lie a un tiers non de type "particulier" @@ -113,9 +142,9 @@ if ($company->id) { } // Personal informations -$v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE"); -if ($adherent->birth) { - $v->setBirthday($adherent->birth); +$v->setPhoneNumber($object->phone_perso, "TYPE=HOME;VOICE"); +if ($object->birth) { + $v->setBirthday($object->birth); } $db->close(); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index b28c81a25b1..741a6157dcd 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -49,8 +49,8 @@ $boxes = array(); */ if ($action == 'addconst') { - dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", GETPOST("MAIN_BOXES_MAXLINES", 'int'), '', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", GETPOST("MAIN_ACTIVATE_FILECACHE", 'alpha'), 'chaine', 0, '', $conf->entity); } if ($action == 'add') { @@ -93,7 +93,7 @@ if ($action == 'add') { $arrayofexistingboxid = array(); $nbboxonleft = $nbboxonright = 0; $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity; + $sql .= " WHERE position = ".((int) $pos)." AND fk_user = ".((int) $fk_user)." AND entity = ".((int) $conf->entity); dol_syslog("boxes.php activate box", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d78ba486224..d8af6ac1b4f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -211,7 +211,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity); - if ($_POST["optionlocaltax1"] == "localtax1on") { + if (GETPOST("optionlocaltax1") == "localtax1on") { if (!GETPOSTISSET('lt1')) { dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity); } else { @@ -219,7 +219,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) } dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity); } - if ($_POST["optionlocaltax2"] == "localtax2on") { + if (GETPOST("optionlocaltax2") == "localtax2on") { if (!GETPOSTISSET('lt2')) { dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity); } else { @@ -288,8 +288,8 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thu } else { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorFileDoesNotExists", $_GET["file"]), null, 'errors'); - dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", $_GET["file"]), LOG_WARNING); + setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors'); + dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING); } } diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 177a38e382b..93550ea3254 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -237,7 +237,7 @@ $sql .= ", note"; $sql .= ", tms"; $sql .= ", entity"; $sql .= " FROM ".MAIN_DB_PREFIX."const"; -$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; +$sql .= " WHERE entity IN (".$db->sanitize($user->entity.",".$conf->entity).")"; if ((empty($user->entity) || $user->admin) && $debug) { } elseif (!GETPOST('visible') || GETPOST('visible') != 'all') { // to force for superadmin to debug diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 6c0cd230cc9..4fe21a8460b 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -181,7 +181,7 @@ if ($action == 'update') { } } - dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_METEO", GETPOST("MAIN_DISABLE_METEO"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); // For update value with percentage diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 2d1247ec226..b1a3a96bc3b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors", "admin", "main", "companies", "resource", "holiday", "accountancy", "hrm", "orders", "contracts", "projects", "propal", "bills", "interventions")); +$langs->loadLangs(array("errors", "admin", "main", "companies", "resource", "holiday", "accountancy", "hrm", "orders", "contracts", "projects", "propal", "bills", "interventions", "ticket")); $action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; $confirm = GETPOST('confirm', 'alpha'); @@ -788,7 +788,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) { $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (GETPOSTISSET("country") && ($_POST["country"] == '0') && ($id != 2)) { + if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) { if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) { // Field country is no mandatory for such dictionaries $_POST["country"] = ''; } else { @@ -796,25 +796,25 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); } } - if (($id == 3 || $id == 42) && !is_numeric($_POST["code"])) { + if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code"))) { $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors'); } // Clean some parameters - if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) { + if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) { $_POST["localtax1"] = '0'; // If empty, we force to 0 } - if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) { + if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) { $_POST["localtax2"] = '0'; // If empty, we force to 0 } - if ($_POST["accountancy_code"] <= 0) { + if (GETPOST("accountancy_code") <= 0) { $_POST["accountancy_code"] = ''; // If empty, we force to null } - if ($_POST["accountancy_code_sell"] <= 0) { + if (GETPOST("accountancy_code_sell") <= 0) { $_POST["accountancy_code_sell"] = ''; // If empty, we force to null } - if ($_POST["accountancy_code_buy"] <= 0) { + if (GETPOST("accountancy_code_buy") <= 0) { $_POST["accountancy_code_buy"] = ''; // If empty, we force to null } if ($id == 10 && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary @@ -1139,6 +1139,7 @@ if ($action == 'delete') { } //var_dump($elementList); + /* * Show a dictionary */ @@ -1397,6 +1398,9 @@ if ($id) { if ($fieldlist[$field] == 'unit_type') { $valuetoshow = $langs->trans('TypeOfUnit'); } + if ($fieldlist[$field] == 'public' && $tablib[$id] == 'TicketDictCategory') { + $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; + } if ($id == 2) { // Special case for state page if ($fieldlist[$field] == 'region_id') { @@ -1738,6 +1742,9 @@ if ($id) { if ($fieldlist[$field] == 'unit_type') { $valuetoshow = $langs->trans('TypeOfUnit'); } + if ($fieldlist[$field] == 'public' && $tablib[$id] == 'TicketDictCategory') { + $valuetoshow = $langs->trans('TicketGroupIsPublic'); $cssprefix = 'center '; + } if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; @@ -1908,10 +1915,10 @@ if ($id) { $showfield = 0; } elseif ($fieldlist[$field] == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); - } elseif ($fieldlist[$field] == 'label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { + } elseif ($fieldlist[$field] == 'label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'short_label' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX.'c_units') { + } elseif ($fieldlist[$field] == 'short_label' && $tabname[GETPOST("id", 'int')] == MAIN_DB_PREFIX.'c_units') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } elseif (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { @@ -1984,6 +1991,9 @@ if ($id) { if ($fieldlist[$field] == 'use_default') { $class .= ' center'; } + if ($fieldlist[$field] == 'public') { + $class .= ' center'; + } // Show value for field if ($showfield) { print ''.$valuetoshow.''; @@ -2046,7 +2056,7 @@ if ($id) { if ($id == 4) { print ''; if ($iserasable) { - print ''.$actl[$obj->favorite].''; + print ''.$actl[$obj->favorite].''; } else { print $langs->trans("AlwaysActive"); } @@ -2056,7 +2066,7 @@ if ($id) { // Active print ''; if ($canbedisabled) { - print ''.$actl[$obj->active].''; + print ''.$actl[$obj->active].''; } else { if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) { print $langs->trans("AlwaysActive"); @@ -2343,10 +2353,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($fieldlist[$field] == 'code') { $class = 'maxwidth100'; } - if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) { + if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'pos', 'use_default', 'affect', 'delay', 'position', 'public', 'sortorder', 'sens', 'category_type'))) { $class = 'maxwidth50 center'; } - if (in_array($fieldlist[$field], array('use_default'))) { + if (in_array($fieldlist[$field], array('use_default', 'public'))) { $classtd = 'center'; } if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) { diff --git a/htdocs/admin/dolistore/ajax/index.html b/htdocs/admin/dolistore/ajax/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/admin/dolistore/ajax/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index bf63f4c42ab..adaf82d6964 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -7,7 +7,7 @@ * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/osl-3.0.php +* https://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. @@ -16,11 +16,11 @@ * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your -* needs please refer to http://www.prestashop.com for more information. +* needs please refer to https://www.prestashop.com for more information. * * @author PrestaShop SA * @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA * PrestaShop Webservice Library * @package PrestaShopWebservice diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 8625f182f47..c1d0fe61e67 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -52,12 +52,15 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TASK_LABEL'=>array('type'=>'textarea','enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_CONF'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), 'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'EVENTORGANIZATION_FILTERATTENDEES_CAT'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'EVENTORGANIZATION_FILTERATTENDEES_TYPE'=>array('type'=>'thirdparty_type:', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), + 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), ); $error = 0; @@ -72,6 +75,7 @@ if ((float) DOL_VERSION >= 6) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; } + if ($action == 'updateMask') { $maskconstorder = GETPOST('maskconstorder', 'alpha'); $maskorder = GETPOST('maskorder', 'alpha'); @@ -144,7 +148,7 @@ if ($action == 'updateMask') { } } } -} elseif ($action == 'setdoc') { +}/* elseif ($action == 'setdoc') { // Set or unset default model $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { @@ -167,7 +171,7 @@ if ($action == 'updateMask') { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); } -} +}*/ @@ -177,7 +181,7 @@ if ($action == 'updateMask') { $form = new Form($db); -$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); +//$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $page_name = "EventOrganizationSetup"; llxHeader('', $langs->trans($page_name)); @@ -194,22 +198,21 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, 'even // Setup page goes here echo ''.$langs->trans("EventOrganizationSetupPage").'

'; - if ($action == 'edit') { print '
'; print ''; print ''; print ''; - print ''; + print ''; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; + print ''; print ''; // Other attributes @@ -461,16 +468,14 @@ if ($action == 'create') { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Bouton Save payment - print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; + if ($val['enabled']==1) { + $setupnotempty++; + print '
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; if ($val['type'] == 'textarea') { print '
'; - print $langs->trans("ClosePaidVATAutomatically"); - print '
'; print dol_get_fiche_end(); print '
'; + print ''; + print ' '.$langs->trans("ClosePaidVATAutomatically").''; + print '
'; print ''; print '     '; print ''; @@ -619,7 +624,7 @@ if ($id) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; $sql .= ", ".MAIN_DB_PREFIX."tva as tva"; - $sql .= " WHERE p.fk_tva = ".$id; + $sql .= " WHERE p.fk_tva = ".((int) $id); $sql .= " AND p.fk_tva = tva.rowid"; $sql .= " AND tva.entity IN (".getEntity('tax').")"; $sql .= " ORDER BY dp DESC"; @@ -676,7 +681,7 @@ if ($id) { } print ''; } - print ''.price($objp->amount)."\n"; + print ''.price($objp->amount)."\n"; print ""; $totalpaye += $objp->amount; $i++; diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 9ba1bd2ed1d..f8a397bdb9a 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -620,7 +620,7 @@ class PaymentVAT extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 552195cf2d2..25d622d825d 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -427,7 +427,7 @@ class Tva extends CommonObject { // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; + $sql = "SELECT sum(f.total_tva) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; if ($year) { $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 7ec5ad5b4f1..f7b860cd792 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -43,71 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); - -$now = dol_now(); -$current_date = dol_getdate($now); -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { - $conf->global->SOCIETE_FISCAL_MONTH_START = 1; -} - -// Date range -$year = GETPOST("year", "int"); -if (empty($year)) { - $year_current = $current_date['year']; - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} -$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -// Set default period if not defined -if (empty($date_start) || empty($date_end)) { // We define date_start and date_end - $q = GETPOST("q", "int"); - if (empty($q)) { - if (GETPOST("month", 'int')) { - $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); - $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); - } else { - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); - $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat - if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { - if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year - $year_start--; - } - } else { - if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year - $year_start--; - } - } - $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); - $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; - } - } - } else { - if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); - $date_end = dol_get_last_day($year_start, 3, false); - } - if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); - $date_end = dol_get_last_day($year_start, 6, false); - } - if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); - $date_end = dol_get_last_day($year_start, 9, false); - } - if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); - $date_end = dol_get_last_day($year_start, 12, false); - } - } -} +include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; $min = price2num(GETPOST("min", "alpha")); if (empty($min)) { @@ -116,20 +52,20 @@ if (empty($min)) { // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +$modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE); if (GETPOSTISSET("modetax")) { - $modetax = GETPOST("modetax", 'int'); + $modetax = GETPOSTINT("modetax"); } if (empty($modetax)) { $modetax = 0; } // Security check -$socid = GETPOST('socid', 'int'); +$socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); @@ -184,7 +120,7 @@ if ($modetax == 2) { $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear = $year_start; +$prevyear = $date_start_year; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -192,7 +128,7 @@ if ($prevquarter > 1) { $prevquarter = 4; $prevyear--; } -$nextyear = $year_start; +$nextyear = $date_start_year; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; @@ -262,6 +198,10 @@ $y = $year_current; $total = 0; $i = 0; $columns = 5; +$span = $columns; +if ($modetax != 1) { + $span += 2; +} // Load arrays of datas $x_coll = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'sell'); @@ -290,14 +230,33 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; - $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + + //$company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $company_static->id = $x_coll[$my_coll_thirdpartyid]['company_id'][$id]; + $company_static->name = $x_coll[$my_coll_thirdpartyid]['company_name'][$id]; + $company_static->name_alias = $x_coll[$my_coll_thirdpartyid]['company_alias'][$id]; + $company_static->email = $x_coll[$my_coll_thirdpartyid]['company_email'][$id]; + $company_static->tva_intra = $x_coll[$my_coll_thirdpartyid]['tva_intra'][$id]; + $company_static->client = $x_coll[$my_coll_thirdpartyid]['company_client'][$id]; + $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid]['company_fournisseur'][$id]; + $company_static->status = $x_coll[$my_coll_thirdpartyid]['company_status'][$id]; + $company_static->code_client = $x_coll[$my_coll_thirdpartyid]['company_customer_code'][$id]; + $company_static->code_compta_client = $x_coll[$my_coll_thirdpartyid]['company_customer_accounting_code'][$id]; + $company_static->code_fournisseur = $x_coll[$my_coll_thirdpartyid]['company_supplier_code'][$id]; + $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid]['company_supplier_accounting_code'][$id]; + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'pstatus' =>$x_paye[$my_coll_thirdpartyid]['pstatus'][$id], + 'pstatusbuy'=>$x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_ref'=>$x_coll[$my_coll_thirdpartyid]['payment_ref'][$id], 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], @@ -305,7 +264,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], @@ -335,10 +296,15 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy' =>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref' =>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), @@ -354,14 +320,33 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + + //$company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $company_static->id = $x_paye[$my_paye_thirdpartyid]['company_id'][$id]; + $company_static->name = $x_paye[$my_paye_thirdpartyid]['company_name'][$id]; + $company_static->name_alias = $x_paye[$my_paye_thirdpartyid]['company_alias'][$id]; + $company_static->email = $x_paye[$my_paye_thirdpartyid]['company_email'][$id]; + $company_static->tva_intra = $x_paye[$my_paye_thirdpartyid]['tva_intra'][$id]; + $company_static->client = $x_paye[$my_paye_thirdpartyid]['company_client'][$id]; + $company_static->fournisseur = $x_paye[$my_paye_thirdpartyid]['company_fournisseur'][$id]; + $company_static->status = $x_paye[$my_paye_thirdpartyid]['company_status'][$id]; + $company_static->code_client = $x_paye[$my_paye_thirdpartyid]['company_customer_code'][$id]; + $company_static->code_compta_client = $x_paye[$my_paye_thirdpartyid]['company_customer_accounting_code'][$id]; + $company_static->code_fournisseur = $x_paye[$my_paye_thirdpartyid]['company_supplier_code'][$id]; + $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid]['company_supplier_accounting_code'][$id]; + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'pstatus' =>$x_paye[$my_paye_thirdpartyid]['pstatus'][$id], + 'pstatusbuy'=>$x_paye[$my_paye_thirdpartyid]['pstatusbuy'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_ref'=>$x_paye[$my_paye_thirdpartyid]['payment_ref'][$id], 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), @@ -369,7 +354,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), @@ -389,11 +376,6 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $x_paye_sum = 0; $x_paye_ht = 0; - $span = $columns; - if ($modetax != 1) { - $span += 2; - } - //print ''..')'; // Customers invoices @@ -483,6 +465,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + $product_static->status = $fields['pstatus']; + $product_static->status_buy = $fields['pstatusbuy']; + print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) { print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); @@ -511,14 +496,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total HT if ($modetax != 1) { - print ''; + print ''; print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } - print ''; + print ''; } // Payment @@ -528,7 +513,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id = $fields['payment_id']; - print $payment_static->getNomUrl(2); + $payment_static->ref = $fields['payment_ref']; + print $payment_static->getNomUrl(2, '', '', 0).' '; } if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { @@ -537,7 +523,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } - print price(price2num($fields['payment_amount'], 'MT')); + print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; } @@ -546,17 +532,17 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // Total collected - print ''; + print ''; $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); - print ''; + print ''; // VAT - print ''; + print ''; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; print price(price2num($temp_vat, 'MT'), 1); //print price($fields['vat']); - print ''; + print ''; print ''; $subtot_coll_total_ht += $temp_ht; @@ -564,6 +550,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $x_coll_sum += $temp_vat; } } + // Total customers for this vat rate print ''; print ''; @@ -572,13 +559,13 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; print ''; } } - if (count($x_coll) == 0) { // Show a total ine if nothing shown + if (count($x_coll) == 0) { // Show a total line if nothing shown print ''; print ''; print ''.$langs->trans("Total").':'; @@ -662,7 +649,9 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // Company name - print ''.$fields['company_link'].''; + print ''; + print $fields['company_link']; + print ''; // Description print ''; @@ -698,14 +687,14 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Total HT if ($modetax != 1) { - print ''; + print ''; print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); //print ' ('.round($ratiolineinvoice*100,2).'%)'; } - print ''; + print ''; } // Payment @@ -714,7 +703,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); + $paymentfourn_static->ref = $fields['payment_ref']; + print $paymentfourn_static->getNomUrl(2, '', '', 0); } if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') @@ -724,7 +714,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); } - print price(price2num($fields['payment_amount'], 'MT')); + print ''.price(price2num($fields['payment_amount'], 'MT')).''; if (isset($fields['payment_amount'])) { print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; } @@ -733,17 +723,17 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // VAT paid - print ''; + print ''; $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; print price(price2num($temp_ht, 'MT'), 1); - print ''; + print ''; // VAT - print ''; + print ''; $temp_vat = $fields['vat'] * $ratiopaymentinvoice; print price(price2num($temp_vat, 'MT'), 1); //print price($fields['vat']); - print ''; + print ''; print ''; $subtot_paye_total_ht += $temp_ht; @@ -759,8 +749,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ' '; print ' '; } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; print ''; } } diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 38d88fb3d12..ea06d0dca06 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -46,13 +46,6 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', '', 'vat', 'charges'); - - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -71,8 +64,8 @@ if (!$sortfield) { $sortfield = "name"; } - $object = new Tva($db); + if ($id > 0) { $object->fetch($id); } @@ -80,6 +73,12 @@ if ($id > 0) { $upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref); $modulepart = 'tax-vat'; +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * Actions diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index ba2669077c9..e1ac3f96a2d 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -37,99 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); -$form = new Form($db); -$now = dol_now(); -$current_date = dol_getdate($now); -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { - $conf->global->SOCIETE_FISCAL_MONTH_START = 1; -} - $refresh = GETPOSTISSET('submit') ? true : false; +$year_current = GETPOSTISSET('year') ? GETPOST('year', 'int') : dol_print_date($now, '%Y', 'tzserver'); +$year_start = $year_current; +$month_current = GETPOSTISSET('month') ? GETPOST('month', 'int') : dol_print_date($now, '%m', 'tzserver'); +$month_start = $month_current; -if ($refresh === false) { - $year_current = dol_print_date('%Y', $now); - $month_current = dol_print_date('%m', $now); +$refresh = true; - // 1 : Monthly (by default) - // 2 : Quarterly - // 3 : Annual - if ($conf->global->MAIN_INFO_VAT_RETURN == 2) { - // quarterly - $year = $year_current; - if ($month_current >= 7 && $month_current <= 9) { - $month_start = 4; - $month_end = 6; - } elseif ($month_current >= 10 && $month_current <= 12) { - $month_start = 7; - $month_end = 9; - } elseif ($month_current >= 1 && $month_current <= 3) { - $month_start = 10; - $month_end = 12; - $year--; - } else { - $month_start = 1; - $month_end = 3; - } - $date_start = dol_get_first_day($year, $month_start); - $date_end = dol_get_last_day($year, $month_end); - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { - // annual - $date_start = dol_get_first_day($year_current, 1); - $date_end = dol_get_last_day($year_current, 12); - } else { - // monthly by default - $year = $year_current; - $month_last = $month_current - 1; - if ($month_last <= 0) { - $month_last = $month_last + 12; - $year--; - } - $date_start = dol_get_first_day($year, $month_last); - $date_end = dol_get_last_day($year, $month_last); - } -} else { - // Date range - $year = GETPOST("year", "int"); - if (empty($year)) { - $year_current = dol_print_date(dol_now(), "%Y"); - if ($conf->global->SOCIETE_FISCAL_MONTH_START > dol_print_date(dol_now(), "%m")) $year_current--; - $year_start = $year_current; - } else { - $year_current = $year; - $year_start = $year; - } - $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); - $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); - if (empty($date_start) || empty($date_end)) {// We define date_start and date_end - $q = GETPOST("q", "int"); - if (empty($q)) { - if (GETPOST("month", "int")) { - $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); - $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); - } else { - $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } - } else { - if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); - $date_end = dol_get_last_day($year_start, 3, false); - } - if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); - $date_end = dol_get_last_day($year_start, 6, false); - } - if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); - $date_end = dol_get_last_day($year_start, 9, false); - } - if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); - $date_end = dol_get_last_day($year_start, 12, false); - } - } - } -} +include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products @@ -146,7 +62,7 @@ $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /** @@ -190,8 +106,8 @@ function pt($db, $sql, $date) if ($obj->mode == 'claimed' && !empty($previousmode)) { print ''; print ''.$previousmonth."\n"; - print ''.price($amountclaimed)."\n"; - print ''.price($amountpaid)."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; print "\n"; $amountclaimed = 0; @@ -210,8 +126,8 @@ function pt($db, $sql, $date) if ($obj->mode == 'paid') { print ''; print ''.$obj->dm."\n"; - print ''.price($amountclaimed)."\n"; - print ''.price($amountpaid)."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; print "\n"; $amountclaimed = 0; $amountpaid = 0; @@ -255,6 +171,7 @@ function pt($db, $sql, $date) * View */ +$form = new Form($db); $company_static = new Societe($db); $tva = new Tva($db); @@ -521,7 +438,7 @@ if ($refresh === true) { $x_coll_sum += $temp_vat; } } - print '' . price(price2num($x_coll_sum, 'MT')) . ''; + print '' . price(price2num($x_coll_sum, 'MT')) . ''; $x_paye_sum = 0; foreach (array_keys($x_paye) as $rate) { @@ -561,7 +478,7 @@ if ($refresh === true) { $x_paye_sum += $temp_vat; } } - print '' . price(price2num($x_paye_sum, 'MT')) . ''; + print '' . price(price2num($x_paye_sum, 'MT')) . ''; $subtotalcoll = $subtotalcoll + $x_coll_sum; $subtotalpaye = $subtotalpaye + $x_paye_sum; @@ -570,10 +487,11 @@ if ($refresh === true) { $total = $total + $diff; $subtotal = price2num($subtotal + $diff, 'MT'); - print '' . price(price2num($diff, 'MT')) . '' . "\n"; + print '' . price(price2num($diff, 'MT')) . '' . "\n"; print " \n"; print "\n"; + // Total $i++; $m++; if ($i > 2) { diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index fb3d0c62d86..96eed7ce20b 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -32,15 +32,14 @@ $langs->loadLangs(array('compta', 'bills')); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$object = new Tva($db); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - -$object = new Tva($db); - +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /* diff --git a/htdocs/compta/tva/initdatesforvat.inc.php b/htdocs/compta/tva/initdatesforvat.inc.php new file mode 100644 index 00000000000..8039fce728f --- /dev/null +++ b/htdocs/compta/tva/initdatesforvat.inc.php @@ -0,0 +1,98 @@ + + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/compta/tva/initdatesforvat.inc.php + * \brief Set value for date_start and date_end + */ + +$now = dol_now(); +$current_date = dol_getdate($now); +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; +} + +// Date range +$year = GETPOST("year", "int"); +if (empty($year)) { + $year_current = $current_date['year']; + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} +$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); +$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); +// Set default period if not defined +if (empty($date_start) || empty($date_end)) { // We define date_start and date_end + $q = GETPOST("q", "int"); + if (empty($q)) { + if (GETPOST("month", 'int')) { + $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), 'tzserver'); + $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), 'tzserver'); + } else { + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, 'tzserver'); + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } + } + } else { + if ($q == 1) { + $date_start = dol_get_first_day($year_start, 1, 'tzserver'); + $date_end = dol_get_last_day($year_start, 3, 'tzserver'); + } + if ($q == 2) { + $date_start = dol_get_first_day($year_start, 4, 'tzserver'); + $date_end = dol_get_last_day($year_start, 6, 'tzserver'); + } + if ($q == 3) { + $date_start = dol_get_first_day($year_start, 7, 'tzserver'); + $date_end = dol_get_last_day($year_start, 9, 'tzserver'); + } + if ($q == 4) { + $date_start = dol_get_first_day($year_start, 10, 'tzserver'); + $date_end = dol_get_last_day($year_start, 12, 'tzserver'); + } + } +} + +//print dol_print_date($date_start, 'day').' '.dol_print_date($date_end, 'day'); + +$tmp = dol_getdate($date_start); +$date_start_day = $tmp['mday']; +$date_start_month = $tmp['mon']; +$date_start_year = $tmp['year']; +$tmp = dol_getdate($date_end); +$date_end_day = $tmp['mday']; +$date_end_month = $tmp['mon']; +$date_end_year = $tmp['year']; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index c7146023aab..17237732cea 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -28,13 +28,6 @@ require '../../main.inc.php'; -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax', '', '', 'charges'); - require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -57,7 +50,6 @@ $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); $search_type = GETPOST('search_type', 'int'); -$search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); $search_status = GETPOST('search_status', 'int'); @@ -85,16 +77,28 @@ $arrayfields = array( 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",), 't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"), 't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"), - 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"Type"), + 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"), 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"), 't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"), ); + +if (!empty($conf->banque->enabled)) { + $arrayfields['t.fk_account'] = array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount"); +} + $arrayfields = dol_sort_array($arrayfields, 'position'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salestaxeslist')); $object = new Tva($db); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * Actions @@ -118,7 +122,6 @@ if (empty($reshook)) { $search_datepayment_start = ''; $search_datepayment_end = ''; $search_type = ''; - $search_cheque = ''; $search_account = ''; $search_amount = ''; $search_status = ''; @@ -139,11 +142,14 @@ $bankline = new AccountLine($db); llxHeader('', $langs->trans("VATDeclarations")); -$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.num_payment, pst.code as payment_code,'; +$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.fk_account,'; +$sql.= ' ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,'; +$sql.= ' t.num_payment, pst.code as payment_code,'; $sql .= ' SUM(ptva.amount) as alreadypayed'; $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON t.fk_typepayment = pst.id'; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON ptva.fk_tva = t.rowid"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON (t.fk_typepayment = pst.id)'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON (t.fk_account = ba.rowid)'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (ptva.fk_tva = t.rowid)"; $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')'; if (!empty($search_ref)) { @@ -168,7 +174,7 @@ if (!empty($search_type) && $search_type > 0) { $sql .= ' AND t.fk_typepayment='.$search_type; } if (!empty($search_account) && $search_account > 0) { - $sql .= ' AND b.fk_account='.$search_account; + $sql .= ' AND t.fk_account='.$search_account; } if (!empty($search_amount)) { $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1); @@ -177,7 +183,7 @@ if ($search_status != '' && $search_status >= 0) { $sql .= " AND t.paye = ".$db->escape($search_status); } -$sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.num_payment, pst.code"; +$sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code"; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -260,9 +266,6 @@ if (!empty($search_datepayment_end)) { if (!empty($search_type) && $search_type > 0) { $param .= '&search_type='.$search_type; } -if (!empty($search_cheque)) { - $param .= '&search_cheque="'.$search_cheque.'"'; -} if (!empty($search_account) && $search_account > 0) { $param .= '&search_account='.$search_account; } @@ -353,6 +356,13 @@ if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print ''; } +// Filter: Bank Account +if (!empty($arrayfields['t.fk_account']['checked'])) { + print ''; + $form->select_comptes($search_account, 'search_account', 0, '', 1); + print ''; +} + // Filter: Amount if (!empty($arrayfields['t.amount']['checked'])) { print ''; @@ -396,6 +406,9 @@ if (!empty($arrayfields['t.datev']['checked'])) { if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left '); } +if (!empty($arrayfields['t.fk_account']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left '); +} if (!empty($arrayfields['t.amount']['checked'])) { print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right '); } @@ -462,35 +475,41 @@ while ($i < min($num, $limit)) { // Type if (!empty($arrayfields['t.fk_typepayment']['checked'])) { - print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).''; + print ''; + if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ''; if (!$i) { $totalarray['nbfield']++; } } // Account - /*if (!empty($arrayfields['ba.label']['checked'])) { + if (!empty($arrayfields['t.fk_account']['checked'])) { print ''; - if ($obj->fk_bank > 0) { - $bankstatic->id = $obj->bid; + if ($obj->fk_account > 0) { + $bankstatic->id = $obj->fk_account; $bankstatic->ref = $obj->bref; $bankstatic->number = $obj->bnumber; + $bankstatic->iban = $obj->iban; + $bankstatic->bic = $obj->bic; + $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); $bankstatic->account_number = $obj->account_number; + $bankstatic->clos = $obj->clos; - $accountingjournal->fetch($obj->fk_accountancy_journal); - $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); $bankstatic->label = $obj->blabel; print $bankstatic->getNomUrl(1); } print ''; if (!$i) $totalarray['nbfield']++; - }*/ + } // Amount if (!empty($arrayfields['t.amount']['checked'])) { $total = $total + $obj->amount; - print '' . price($obj->amount) . ''; + print '' . price($obj->amount) . ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 73e2dae0e05..57e70e70a3d 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -38,12 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); - $mode = GETPOST("mode", 'alpha'); $year = GETPOST("year", 'int'); $filtre = GETPOST("filtre", 'alpha'); @@ -68,6 +62,15 @@ if (!$sortorder) { $sortorder = "DESC"; } +$object = new Tva($db); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +//$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); + /* * View @@ -75,6 +78,7 @@ if (!$sortorder) { $tva_static = new Tva($db); $tva = new Tva($db); +$accountlinestatic = new AccountLine($db); $payment_vat_static = new PaymentVAT($db); $sal_static = new PaymentSalary($db); @@ -119,17 +123,22 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; print ''; print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("LabelContrib", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); - //print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("VATDeclaration", $_SERVER["PHP_SELF"], "tva.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "ptva.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); + if (!empty($conf->banque->enabled)) { + print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "ptva.fk_bank", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); + } + //print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "tva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; - $sql = "SELECT tva.rowid, tva.label as label, b.fk_account"; + $sql = "SELECT tva.rowid, tva.label as label, b.fk_account, ptva.fk_bank"; $sql .= ", tva.datev"; $sql .= ", tva.amount as total,"; $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; @@ -175,42 +184,63 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $payment_vat_static->ref = $obj->pid; print ''; + // Ref payment print '\n"; - // Date payment - print ''; - // Type payment - print ''; - // Account - print ''; - // Label + + // VAT print ''; - // Type - //print ''; + + // Label + print ''; + // Date $date = $obj->datev; print ''; + + // Date payment + print ''; + + // Type payment + print ''; + + // Chq number + print ''; + + if (!empty($conf->banque->enabled)) { + // Bank transaction + print ''; + + // Account + print ''; + } + + // Type + //print ''; // Expected to pay - print ''; + print ''; // Paid - print ''; + print ''; print ''; $total = $total + $obj->total; @@ -218,11 +248,17 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $totalpaye = $totalpaye + $obj->totalpaye; $i++; } + + // Total print ''; print ''; // A total here has no sense - //print ''; print ''; print ''; + if (!empty($conf->banque->enabled)) { + print ''; + print ''; + } + print ''; print ''; print '"; print ""; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 590999c7b31..4b44959bc1a 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -45,68 +45,11 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); -$now = dol_now(); -$refresh = GETPOSTISSET('submit') ? true : false; +$refresh = (GETPOSTISSET('submit') || GETPOSTISSET('vat_rate_show') || GETPOSTISSET('invoice_type')) ? true : false; $invoice_type = GETPOSTISSET('invoice_type') ? GETPOST('invoice_type', 'alpha') : ''; $vat_rate_show = GETPOSTISSET('vat_rate_show') ? GETPOST('vat_rate_show', 'int') : -1; -$year_current = GETPOSTISSET('year') ? GETPOST('year', 'int') : intval(strftime('%Y', $now)); -$year_start = $year_current; -$month_current = GETPOSTISSET('month') ? GETPOST('month', 'int') : intval(strftime('%m', $now)); -$month_start = $month_current; -if ($refresh === false) { - $date_start = dol_get_first_day($year_start, $month_start); - $date_end = dol_get_last_day($year_start, $month_start); -} else { - // Date range - //$year=GETPOST("year", "int"); - //if (empty($year)) - //{ - // $year_current = strftime("%Y", dol_now()); - // $year_start = $year_current; - //} else { - // $year_current = $year; - // $year_start = $year; - //} - - $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); - $date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); - // Quarter - if (empty($date_start) || empty($date_end)) { // We define date_start and date_end - $q=GETPOST("q", "int"); - if (empty($q)) { - if (GETPOST("month", "int")) { - $date_start=dol_get_first_day($year_start, GETPOST("month", "int"), false); - $date_end=dol_get_last_day($year_start, GETPOST("month", "int"), false); - } else { - $date_start=dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START, false); - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { - $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { - $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; - } - } - } else { - if ($q == 1) { - $date_start=dol_get_first_day($year_start, 1, false); $date_end=dol_get_last_day($year_start, 3, false); - } - if ($q == 2) { - $date_start=dol_get_first_day($year_start, 4, false); $date_end=dol_get_last_day($year_start, 6, false); - } - if ($q == 3) { - $date_start=dol_get_first_day($year_start, 7, false); $date_end=dol_get_last_day($year_start, 9, false); - } - if ($q == 4) { - $date_start=dol_get_first_day($year_start, 10, false); $date_end=dol_get_last_day($year_start, 12, false); - } - } - } -} - -$month_start = strftime('%m', $date_start); -$year_start = strftime('%Y', $date_start); +include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php'; $min = price2num(GETPOST("min", "alpha")); if (empty($min)) { @@ -123,13 +66,14 @@ if (empty($modetax)) { $modetax = 0; } +$object = new Tva($db); + // Security check $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - +$result = restrictedArea($user, 'tax', '', 'tva', 'charges'); /* @@ -154,7 +98,7 @@ foreach ($listofparams as $param) { } } -$title = $langs->trans("VATReport")." ".dol_print_date($date_start)." -> ".dol_print_date($date_end); +$title = $langs->trans("VATReport")." ".dol_print_date($date_start, '', 'tzserver')." -> ".dol_print_date($date_end, '', 'tzserver'); llxHeader('', $title, '', '', 0, 0, '', '', $morequerystring); @@ -182,8 +126,10 @@ if ($modetax == 2) { } $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period -$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear = $year_start; +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$period .= ' - '; +$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); +$prevyear = $date_start_year; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; @@ -191,7 +137,7 @@ if ($prevquarter > 1) { $prevquarter = 4; $prevyear--; } -$nextyear = $year_start; +$nextyear = $date_start_year; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; @@ -256,9 +202,13 @@ print '
'; print '
'.$payment_vat_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - } - print $obj->num_payment.''; - $account = new Account($db); - $account->fetch($obj->fk_account); - print $account->getNomUrl(1); - print ''; $tva->id = $obj->rowid; $tva->ref = $obj->rowid; $tva->label = $obj->label; print $tva->getNomUrl(1, '20'); print ''.$obj->type_label.''.$obj->label.''.dol_print_date($date, 'day').''.dol_print_date($db->jdate($obj->datep), 'day').''; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + } + print ''.$obj->num_payment.''; + $accountlinestatic->id = $obj->fk_bank; + print $accountlinestatic->getNomUrl(1); + print ''; + $account = new Account($db); + $account->fetch($obj->fk_account); + print $account->getNomUrl(1); + print ''.$obj->type_label.''.price($obj->total).''.price($obj->total).''; + print ''; if ($obj->totalpaye) { print price($obj->totalpaye); } - print '
'.$langs->trans("Total").'       '.price($totalpaye)."
'; $y = $year_current; -$total = 0; $i = 0; -$columns = 5; + +$columns = 7; +$span = $columns; +if ($modetax != 1) { + $span += 2; +} // Load arrays of datas $x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); @@ -287,7 +237,21 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id]; $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id]; - $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + + //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + $company_static->id = $x_coll[$my_coll_rate]['company_id'][$id]; + $company_static->name = $x_coll[$my_coll_rate]['company_name'][$id]; + $company_static->name_alias = $x_coll[$my_coll_rate]['company_alias'][$id]; + $company_static->email = $x_coll[$my_coll_rate]['company_email'][$id]; + $company_static->tva_intra = $x_coll[$my_coll_rate]['tva_intra'][$id]; + $company_static->client = $x_coll[$my_coll_rate]['company_client'][$id]; + $company_static->fournisseur = $x_coll[$my_coll_rate]['company_fournisseur'][$id]; + $company_static->status = $x_coll[$my_coll_rate]['company_status'][$id]; + $company_static->code_client = $x_coll[$my_coll_rate]['company_customer_code'][$id]; + $company_static->code_compta_client = $x_coll[$my_coll_rate]['company_customer_accounting_code'][$id]; + $company_static->code_fournisseur = $x_coll[$my_coll_rate]['company_supplier_code'][$id]; + $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate]['company_supplier_accounting_code'][$id]; + $x_both[$my_coll_rate]['coll']['detail'][] = array( 'id' =>$x_coll[$my_coll_rate]['facid'][$id], 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], @@ -295,13 +259,16 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_ref'=>$x_coll[$my_coll_rate]['payment_ref'][$id], 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], @@ -335,6 +302,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_ref' =>$x_paye[$my_paye_rate]['payment_ref'][$id], 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), @@ -349,7 +317,20 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id]; $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id]; $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id]; - $company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); + + $company_static->id = $x_paye[$my_paye_rate]['company_id'][$id]; + $company_static->name = $x_paye[$my_paye_rate]['company_name'][$id]; + $company_static->name_alias = $x_paye[$my_paye_rate]['company_alias'][$id]; + $company_static->email = $x_paye[$my_paye_rate]['company_email'][$id]; + $company_static->tva_intra = $x_paye[$my_paye_rate]['tva_intra'][$id]; + $company_static->client = $x_paye[$my_paye_rate]['company_client'][$id]; + $company_static->fournisseur = $x_paye[$my_paye_rate]['company_fournisseur'][$id]; + $company_static->status = $x_paye[$my_paye_rate]['company_status'][$id]; + $company_static->code_client = $x_paye[$my_paye_rate]['company_customer_code'][$id]; + $company_static->code_compta_client = $x_paye[$my_paye_rate]['company_customer_accounting_code'][$id]; + $company_static->code_fournisseur = $x_paye[$my_paye_rate]['company_supplier_code'][$id]; + $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate]['company_supplier_accounting_code'][$id]; + $x_both[$my_paye_rate]['paye']['detail'][] = array( 'id' =>$x_paye[$my_paye_rate]['facid'][$id], 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], @@ -357,13 +338,16 @@ if (!is_array($x_coll) || !is_array($x_paye)) { 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_ref'=>$x_paye[$my_paye_rate]['payment_ref'][$id], 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), @@ -383,11 +367,6 @@ if (!is_array($x_coll) || !is_array($x_paye)) { $x_paye_sum = 0; $x_paye_ht = 0; - $span = $columns; - if ($modetax != 1) { - $span += 2; - } - //print ''; // Customers invoices @@ -429,7 +408,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ""; print ''; print ''."\n"; @@ -473,6 +456,19 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($invoice_type == 'customer' && $vat_rate_show == $rate) { if (is_array($x_both[$rate]['coll']['detail'])) { foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { + /*$company_static->id = $fields['company_id']; + $company_static->name = $fields['company_name']; + $company_static->name_alias = $fields['company_alias']; + $company_static->email = $fields['company_email']; + $company_static->tva_intra = $fields['tva_intra']; + $company_static->client = $fields['company_client']; + $company_static->fournisseur = $fields['company_fournisseur']; + $company_static->status = $fields['company_status']; + $company_static->code_client = $fields['company_client']; + $company_static->code_compta_client = $fields['company_customer_code']; + $company_static->code_fournisseur = $fields['company_customer_accounting_code']; + $company_static->code_compta_fournisseur = $fields['company_supplier_accounting_code'];*/ + // Define type // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); @@ -499,7 +495,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) { else print ''; // Company name - print ''; + print ''; // Description print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } @@ -618,7 +618,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) { // Blank line print ''; - // Print table headers for this quadri - expenses now + // Print table headers for this quadri - expenses print ''; print ''; print ''; @@ -642,7 +642,11 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ""; print ''; print ''."\n"; @@ -684,6 +688,19 @@ if (!is_array($x_coll) || !is_array($x_paye)) { if ($invoice_type == 'supplier' && $vat_rate_show == $rate) { foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) { + /*$company_static->id = $fields['company_id']; + $company_static->name = $fields['company_name']; + $company_static->name_alias = $fields['company_alias']; + $company_static->email = $fields['company_email']; + $company_static->tva_intra = $fields['tva_intra']; + $company_static->client = $fields['company_client']; + $company_static->fournisseur = $fields['company_fournisseur']; + $company_static->status = $fields['company_status']; + $company_static->code_client = $fields['company_client']; + $company_static->code_compta_client = $fields['company_customer_code']; + $company_static->code_fournisseur = $fields['company_customer_accounting_code']; + $company_static->code_compta_fournisseur = $fields['company_supplier_accounting_code'];*/ + // Define type // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); @@ -713,7 +730,10 @@ if (!is_array($x_coll) || !is_array($x_paye)) { } // Company name - print ''; + print ''; // Description print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } @@ -825,8 +846,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; print ''; } - print ''; - print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index a32263cd65e..0e80df07676 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -283,32 +283,32 @@ abstract class ActionsContactCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = GETPOST("old_name"); + $this->object->old_firstname = GETPOST("old_firstname"); - $this->object->socid = $_POST["socid"]; - $this->object->lastname = $_POST["name"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->poste = $_POST["poste"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_pro = $_POST["phone_pro"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->fax = $_POST["fax"]; - $this->object->email = $_POST["email"]; - $this->object->jabberid = $_POST["jabberid"]; - $this->object->priv = $_POST["priv"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->socid = GETPOST("socid"); + $this->object->lastname = GETPOST("name"); + $this->object->firstname = GETPOST("firstname"); + $this->object->civility_id = GETPOST("civility_id"); + $this->object->poste = GETPOST("poste"); + $this->object->address = GETPOST("address"); + $this->object->zip = GETPOST("zipcode"); + $this->object->town = GETPOST("town"); + $this->object->country_id = GETPOST("country_id") ? GETPOST("country_id") : $mysoc->country_id; + $this->object->state_id = GETPOST("state_id"); + $this->object->phone_pro = GETPOST("phone_pro"); + $this->object->phone_perso = GETPOST("phone_perso"); + $this->object->phone_mobile = GETPOST("phone_mobile"); + $this->object->fax = GETPOST("fax"); + $this->object->email = GETPOST("email"); + $this->object->jabberid = GETPOST("jabberid"); + $this->object->priv = GETPOST("priv"); + $this->object->note = GETPOST("note", "restricthtml"); + $this->object->canvas = GETPOST("canvas"); // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".((int) $this->object->country_id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 421b88ea6b8..b337f0980e6 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -561,7 +561,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->state_id = GETPOST("state_id"); // We set country_id, country_code and label for the selected country - $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); + $object->country_id = GETPOST("country_id") ? GETPOST("country_id", "int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id); if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 5e0c65e1b70..5befcba4537 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1651,8 +1651,8 @@ class Contact extends CommonObject // Desactive utilisateur $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople"; - $sql .= " SET statut = ".$this->statut; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET statut = ".((int) $this->statut); + $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); @@ -1882,7 +1882,7 @@ class Contact extends CommonObject $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; if ($active >= 0) { - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 1e0f5b06094..b87a73e8cc2 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -258,7 +258,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices // $documentstatic=new SupplierProposal($db); // $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; // $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; - // $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + // $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); // $where.= " AND d.fk_supplier_proposal = c.rowid"; // $where.= " AND c.entity = ".$conf->entity; // $dateprint = 'c.date_valid'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 53ebbdfddd9..4535c0514e9 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -458,7 +458,7 @@ if ($search_societe) { $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); } if ($search_country) { - $sql .= " AND p.fk_pays IN (".$search_country.')'; + $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')'; } if (strlen($search_poste)) { $sql .= natural_search('p.poste', $search_poste); @@ -492,9 +492,8 @@ if (strlen($search_town)) { $sql .= natural_search("p.town", $search_town); } if (count($search_roles) > 0) { - $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; + $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))"; } - if ($search_no_email != '' && $search_no_email >= 0) { $sql .= " AND p.no_email = ".$db->escape($search_no_email); } @@ -705,25 +704,29 @@ $moreforfilter = ''; if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('Categories').': '; - $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); + $tmptitle = $langs->trans('ContactCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1, $tmptitle); $moreforfilter .= '
'; if (empty($type) || $type == 'c' || $type == 'p') { $moreforfilter .= '
'; + $tmptitle = ''; if ($type == 'c') { - $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; + $tmptitle .= $langs->trans('CustomersCategoriesShort'); } elseif ($type == 'p') { - $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; + $tmptitle .= $langs->trans('ProspectsCategoriesShort'); } else { - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $tmptitle .= $langs->trans('CustomersProspectsCategoriesShort'); } - $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1, $tmptitle); $moreforfilter .= '
'; } if (empty($type) || $type == 'f') { $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); + $tmptitle = $langs->trans('SuppliersCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1, $tmptitle); $moreforfilter .= '
'; } } @@ -1093,35 +1096,35 @@ while ($i < min($num, $limit)) { } // Phone if (!empty($arrayfields['p.phone']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } // Phone perso if (!empty($arrayfields['p.phone_perso']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } // Phone mobile if (!empty($arrayfields['p.phone_mobile']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } // Fax if (!empty($arrayfields['p.fax']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } // EMail if (!empty($arrayfields['p.email']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1145,7 +1148,7 @@ while ($i < min($num, $limit)) { } // Company if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { - print ''; + + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= ''; + + $i++; + } + + $result .= '
'..')
'; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; - print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; + print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; print '
' . $fields['company_link'] . ''; + //print $company_static->getNomUrl(1); + print $fields['company_link']; + print ''; @@ -552,7 +551,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id = $fields['payment_id']; - print $payment_static->getNomUrl(2); + $payment_static->ref = $fields['payment_ref']; + print $payment_static->getNomUrl(2, '', '', 0).' '; } if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { @@ -597,8 +597,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print '  '.price(price2num($subtot_coll_total_ht, 'MT')).''.price(price2num($subtot_coll_vat, 'MT')).''.price(price2num($subtot_coll_total_ht, 'MT')).''.price(price2num($subtot_coll_vat, 'MT')).'
 
'.$elementsup.''.$langs->trans("DateInvoice").'
'; print $langs->trans('Rate') . ' : ' . vatrate($rate) . '%'; - print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; + print ' - ' . img_picto('', 'chevron-down', 'class="paddingrightonly"') . $langs->trans('VATReportShowByRateDetails') . ''; print '
' . $fields['company_link'] . ''; + //print $company_static->getNomUrl(1); + print $fields['company_link']; + print ''; @@ -765,7 +785,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print ''; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $paymentfourn_static->id = $fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); + $paymentfourn_static->ref = $fields['payment_ref']; + print $paymentfourn_static->getNomUrl(2, '', '', 0).' '; } if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') @@ -812,8 +833,8 @@ if (!is_array($x_coll) || !is_array($x_paye)) { print '  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).''.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'
  '.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).'
'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; + print ''; if ($obj->socid) { $objsoc = new Societe($db); $objsoc->fetch($obj->socid); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 8d2969a1370..628c73b0afc 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -45,12 +45,12 @@ $object = new Contact($db); * Action */ -if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { +if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact->creer) { $ret = $object->fetch($id); // Note: Correct date should be completed with location to have exact GM time of birth. - $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]); - $object->birthday_alert = $_POST["birthday_alert"]; + $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth"), GETPOST("birthdayday"), GETPOST("birthdayyear")); + $object->birthday_alert = GETPOST("birthday_alert"); if (GETPOST('deletephoto')) { $object->photo = ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 217414aa30c..9e342b9b8d3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -54,6 +54,8 @@ $langs->loadLangs(array("contracts", "orders", "companies", "bills", "products", $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); + $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -113,7 +115,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { - $result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); + $result = $object->active_line($user, GETPOST('ligne', 'int'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -127,7 +129,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } if (!$error) { - $result = $object->close_line($user, GETPOST('ligne'), GETPOST('dateend'), urldecode(GETPOST('comment'))); + $result = $object->close_line($user, GETPOST('ligne', 'int'), GETPOST('dateend'), urldecode(GETPOST('comment'))); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -931,10 +933,10 @@ if (empty($reshook)) { } } elseif ($action == 'swapstatut') { // bascule du statut d'un contact - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact') { // Efface un contact - $result = $object->delete_contact(GETPOST('lineid')); + $result = $object->delete_contact(GETPOST('lineid', 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -1528,7 +1530,7 @@ if ($action == 'create') { print ''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { print ''; - print ''; + print ''; print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow'); print ''; } @@ -1747,25 +1749,25 @@ if ($action == 'create') { 'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"), array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid)); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("MoveToAnotherContract"), $langs->trans("ConfirmMoveToAnotherContract"), "confirm_move", $formquestion); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid', 'int'), $langs->trans("MoveToAnotherContract"), $langs->trans("ConfirmMoveToAnotherContract"), "confirm_move", $formquestion); print '
'; } /* * Confirmation de la validation activation */ - if ($action == 'active' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { + if ($action == 'active' && !$cancel && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); $comment = GETPOST('comment', 'alpha'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("ActivateService"), $langs->trans("ConfirmActivateService", dol_print_date($dateactstart, "%A %d %B %Y")), "confirm_active", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne', 'int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("ActivateService"), $langs->trans("ConfirmActivateService", dol_print_date($dateactstart, "%A %d %B %Y")), "confirm_active", '', 0, 1); print '
'; } /* * Confirmation de la validation fermeture */ - if ($action == 'closeline' && !$_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { + if ($action == 'closeline' && !$cancel && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); $comment = GETPOST('comment', 'alpha'); @@ -1843,8 +1845,8 @@ if ($action == 'create') { } // Form to activate line - if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { - print ''; + if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { + print ''; print ''; print ''; @@ -1893,7 +1895,7 @@ if ($action == 'create') { print ''; } - if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne')) { + if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { /** * Disable a contract line */ @@ -2008,7 +2010,7 @@ if ($action == 'create') { if (empty($user->socid)) { if ($object->statut == 1) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) { - print ''; + print ''; } else { print ''; } @@ -2017,14 +2019,14 @@ if ($action == 'create') { if ($object->statut == 0 && $nbofservices) { if ($user->rights->contrat->creer) { - print ''; + print ''; } else { print ''; } } if ($object->statut == 1) { if ($user->rights->contrat->creer) { - print ''; + print ''; } else { print ''; } @@ -2050,14 +2052,14 @@ if ($action == 'create') { if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) { if ($user->rights->contrat->activer) { - print ''; + print ''; } else { print ''; } } if ($object->nbofservicesclosed < $nbofservices) { if ($user->rights->contrat->desactiver) { - print ''; + print ''; } else { print ''; } @@ -2081,7 +2083,7 @@ if ($action == 'create') { // Clone if ($user->rights->contrat->creer) { - print ''; + print ''; } // On peut supprimer entite si diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index c6a834331c9..1de8f0c480d 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -106,6 +106,10 @@ class Contracts extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -132,14 +136,14 @@ class Contracts extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Add sql filters if ($sqlfilters) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 02929f281a8..33dd0e8e2f7 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1057,7 +1057,7 @@ class Contrat extends CommonObject } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact .= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { @@ -1172,7 +1172,7 @@ class Contrat extends CommonObject $this->db->free($resql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; - $sql .= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",", $tab_resql).")"; + $sql .= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".$this->db->sanitize(implode(",", $tab_resql)).")"; dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1759,7 +1759,7 @@ class Contrat extends CommonObject $sql .= ",date_cloture=null"; } $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 35b7268109b..3d0be4d9552 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -85,7 +85,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { // bascule du statut d'un contact if ($action == 'swapstatut' && $user->rights->contrat->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db, $object->error); } @@ -94,7 +94,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { // Delete contact if ($action == 'deletecontact' && $user->rights->contrat->creer) { $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 6b1aecf1162..46a89209996 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -187,7 +187,7 @@ if ($resql) { $colorseries = array(); -include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; +include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
'; print '
'; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 27cbf5a3a70..60215abb847 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -488,24 +488,24 @@ $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmpttile = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmpttile, 'maxwidth250'); $moreforfilter .= '
'; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmpttile = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmpttile, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
'; } // If the user can view categories of products if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmpttile = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmpttile, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
'; } diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index d61ac357a40..bd96eac7b0d 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -180,6 +180,7 @@ if ($id > 0 || !empty($ref)) { //print '
'; + $cssclass='fieldtitle'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print dol_get_fiche_end(); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 057443d09b4..13cb7126769 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1321,7 +1321,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' } if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".((int) $objecttmp->id); $res = $db->query($sql); if (!$res) { diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 5f0d6823978..797bb8e4cb7 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -33,7 +33,17 @@ if ($action == 'update' && is_array($arrayofparameters)) { foreach ($arrayofparameters as $key => $val) { // Modify constant only if key was posted (avoid resetting key to the null value) if (GETPOSTISSET($key)) { - $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); + if (preg_match('/category:/', $val['type'])) { + if (GETPOST($key, 'int') == '-1') { + $val_const = ''; + } else { + $val_const = GETPOST($key, 'int'); + } + } else { + $val_const = GETPOST($key, 'alpha'); + } + + $result = dolibarr_set_const($db, $key, $val_const, 'chaine', 0, '', $conf->entity); if ($result < 0) { $error++; break; diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 17c7b3606d9..8559cdd10b0 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -42,7 +42,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $boxid = GETPOST('boxid', 'int'); $boxorder = GETPOST('boxorder'); -$userid = GETPOST('userid'); $zone = GETPOST('zone', 'int'); $userid = GETPOST('userid', 'int'); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 883ba664b5c..4662c3a1406 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -59,15 +59,52 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2) - && GETPOST('fk_element', 'alpha', 2) && GETPOST('element_id', 'int', 2)) { +if (GETPOST('roworder', 'alpha', 2) && GETPOST('table_element_line', 'aZ09', 2) + && GETPOST('fk_element', 'aZ09', 2) && GETPOST('element_id', 'int', 2)) { $roworder = GETPOST('roworder', 'alpha', 2); - $table_element_line = GETPOST('table_element_line', 'alpha', 2); - $fk_element = GETPOST('fk_element', 'alpha', 2); + $table_element_line = GETPOST('table_element_line', 'aZ09', 2); + $fk_element = GETPOST('fk_element', 'aZ09', 2); $element_id = GETPOST('element_id', 'int', 2); dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG); + // Make test on pemrission + $perm = 0; + if ($table_element_line == 'propaldet' && $user->rights->propal->creer) { + $perm = 1; + } elseif ($table_element_line == 'commandedet' && $user->rights->commande->creer) { + $perm = 1; + } elseif ($table_element_line == 'facturedet' && $user->rights->facture->creer) { + $perm = 1; + } elseif ($table_element_line == 'facturerecdet' && $user->rights->facture->creer) { + $perm = 1; + } elseif ($table_element_line == 'ecm_files' && $user->rights->ecm->creer) { + $perm = 1; + } elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) { + $perm = 1; + } elseif ($table_element_line == 'bom_bomline' && $user->rights->bom->write) { + $perm = 1; + } elseif ($table_element_line == 'mrp_production' && $user->rights->mrp->write) { + $perm = 1; + } elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->write) { + $perm = 1; + } elseif ($table_element_line == 'commande_fournisseurdet' && $user->rights->fourn->commande->creer) { + $perm = 1; + } elseif ($table_element_line == 'facture_fourn_det' && $user->rights->fourn->facture->creer) { + $perm = 1; + } else { + $tmparray = explode('_', $table_element_line); + $tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]); + if (!empty($tmpmodule) && !empty($tmpobject) && !empty($conf->$tmpmodule->enabled) && !empty($user->rights->$tmpobject->write)) { + $perm = 1; + } + } + + if (! $perm) { + print 'Bad permission to modify position of lines for object in table '.$table_element_line; + accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line); + } + $rowordertab = explode(',', $roworder); $newrowordertab = array(); foreach ($rowordertab as $value) { @@ -88,4 +125,6 @@ if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2) if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) { $result = $row->line_order(true); } +} else { + print 'Bad parameters for row.php'; } diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index c491ad63749..c8c3e13ea3d 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -43,9 +43,7 @@ require '../../main.inc.php'; $objectdesc = GETPOST('objectdesc', 'alpha'); $htmlname = GETPOST('htmlname', 'aZ09'); -$sqlfilter = GETPOST('sqlfilter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); -$action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -54,11 +52,8 @@ $id = GETPOST('id', 'int'); */ //print ''."\n"; - -dol_syslog(join(',', $_GET)); //print_r($_GET); - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 2794243b7f3..d10324ef620 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -81,7 +81,7 @@ if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empt $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); // search on lot/serial numbers if ( ! empty($conf->productbatch->enabled) ) { - $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_plot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } } diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 44c7bc0760b..aa9474ce142 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -59,17 +59,17 @@ top_httphead(); //print ''."\n"; -dol_syslog("GET is ".join(',', $_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); +dol_syslog('ziptown call with MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); //var_dump($_GET); // Generation of list of zip-town -if (!empty($_GET['zipcode']) || !empty($_GET['town'])) { +if (GETPOST('zipcode') || GETPOST('town')) { $return_arr = array(); $formcompany = new FormCompany($db); // Define filter on text typed - $zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : ''; - $town = $_GET['town'] ? $_GET['town'] : ''; + $zipcode = GETPOST('zipcode'); + $town = GETPOST('town'); if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { // Use zip-town table $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; @@ -141,7 +141,6 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town'])) { } echo json_encode($return_arr); -} else { } $db->close(); diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 31eaa65bf72..aa648270b97 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -15,7 +15,7 @@ * 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 . + * along with this program. If not, see . */ /** @@ -83,7 +83,7 @@ class box_accountancy_suspense_account extends ModeleBoxes if (!empty($suspenseAccount) && $suspenseAccount > 0) { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.numero_compte = ".$suspenseAccount; + $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'"; $sql .= " AND b.entity = ".$conf->entity; $result = $this->db->query($sql); diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 9d6df6c7535..1a3a1183032 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -87,7 +87,7 @@ class box_bookmarks extends ModeleBoxes if ($user->rights->bookmark->lire) { $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; - $sql .= " WHERE fk_user = ".$user->id; + $sql .= " WHERE fk_user = ".((int) $user->id); $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d85f0a3f44b..7bf8a69ed03 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -77,6 +77,7 @@ class box_external_rss extends ModeleBoxes $this->max = $max; // On recupere numero de param de la boite + $reg = array(); preg_match('/^([0-9]+) /', $this->paramdef, $reg); $site = $reg[1]; diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index c9ad5e69564..9ef12a9b8f6 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -89,8 +89,8 @@ class box_factures extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; + $sql .= ", f.ref, f.type, f.total_ht"; + $sql .= ", f.total_tva"; $sql .= ", f.total_ttc"; $sql .= ", f.datef as df"; $sql .= ", f.paye, f.fk_statut as status, f.datec, f.tms"; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 76dc76720a1..54d3a950a79 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -94,8 +94,8 @@ class box_factures_imp extends ModeleBoxes $sql .= ", f.ref, f.date_lim_reglement as datelimite"; $sql .= ", f.type"; $sql .= ", f.datef as df"; - $sql .= ", f.total as total_ht"; - $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ht"; + $sql .= ", f.total_tva"; $sql .= ", f.total_ttc"; $sql .= ", f.paye, f.fk_statut as status, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; @@ -117,7 +117,7 @@ class box_factures_imp extends ModeleBoxes } $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; $sql .= " f.ref, f.date_lim_reglement,"; - $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; + $sql .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql .= " ORDER BY datelimite ASC, f.ref ASC "; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 79610a3e988..c961ffe3f4a 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2020 Frederic 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 @@ -92,13 +93,15 @@ class box_members_by_type extends ModeleBoxes if ($user->rights->adherent->lire) { $MembersToValidate = array(); $MembersValidated = array(); - $MemberUpToDate = array(); + $MembersUpToDate = array(); + $MembersExcluded = array(); $MembersResiliated = array(); - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; + $SumToValidate = 0; + $SumValidated = 0; + $SumUpToDate = 0; + $SumResiliated = 0; + $SumExcluded = 0; $AdherentType = array(); @@ -132,6 +135,9 @@ class box_members_by_type extends ModeleBoxes if ($objp->statut == 1) { $MembersValidated[$objp->rowid] = $objp->somme; } + if ($objp->statut == -2) { + $MembersExcluded[$objp->rowid] = $objp->somme; + } if ($objp->statut == 0) { $MembersResiliated[$objp->rowid] = $objp->somme; } @@ -158,7 +164,7 @@ class box_members_by_type extends ModeleBoxes $i = 0; while ($i < $num2) { $objp = $this->db->fetch_object($result); - $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; + $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } $this->db->free($result); @@ -181,16 +187,22 @@ class box_members_by_type extends ModeleBoxes 'td' => 'class="right"', 'text' => $langs->trans("UpToDate"), ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusExcluded"), + ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => $langs->trans("MembersStatusResiliated"), ); $line++; foreach ($AdherentType as $key => $adhtype) { - $SommeA += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; + $SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0; + $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; + $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; + $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $adhtype->getNomUrl(1, dol_size(32)), @@ -203,12 +215,17 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(1, 1, 0, 3), + 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(1, 1, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, 1, $now, 3), + 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersExcluded[$key]) && $MembersExcluded[$key] > 0 ? $MembersExcluded[$key] : '') . ' ' . $staticmember->LibStatut(-2, 1, $now, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( @@ -232,22 +249,27 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SommeA.' '.$staticmember->LibStatut(-1, 1, 0, 3), + 'text' => $SumToValidate.' '.$staticmember->LibStatut(-1, 1, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SommeB.' '.$staticmember->LibStatut(1, 1, 0, 3), + 'text' => $SumValidated.' '.$staticmember->LibStatut(1, 1, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SommeC.' '.$staticmember->LibStatut(1, 1, $now, 3), + 'text' => $SumUpToDate.' '.$staticmember->LibStatut(1, 1, $now, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SommeD.' '.$staticmember->LibStatut(0, 1, 0, 3), + 'text' => $SumExcluded.' '.$staticmember->LibStatut(-2, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SumResiliated.' '.$staticmember->LibStatut(0, 1, 0, 3), 'asis' => 1 ); } diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index 6da20bf28d0..e08bc1073b6 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -153,7 +153,7 @@ class box_members_last_subscriptions extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => price($obj->subscription), + 'text' => ''.price($obj->subscription).'', ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index ef796b75044..b6c146312bc 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -180,11 +180,11 @@ class box_members_subscriptions_by_year extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => price($value), + 'text' => ''.price($value).'', ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => price(price2num($value / $Number[$key], 'MT')), + 'text' => ''.price(price2num($value / $Number[$key], 'MT')).'', ); $line++; } @@ -205,11 +205,11 @@ class box_members_subscriptions_by_year extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => price($tot), + 'text' => ''.price($tot).'', ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')), + 'text' => ''.price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')).'', ); } } else { diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 04aa812ea34..9f1204c4dc4 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -103,7 +103,7 @@ class box_project extends ModeleBoxes $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql .= " AND p.fk_statut = 1"; // Only open projects if (!$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } $sql .= " ORDER BY p.datec DESC"; diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 7325b9bed5f..1a8cec07155 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -15,7 +15,7 @@ * 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 . + * along with this program. If not, see . */ /** diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 0650b10a872..16cd41ce564 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -169,7 +169,7 @@ class box_task extends ModeleBoxes $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed $sql .= " AND p.usage_task = 1 "; if (!$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 7541c58a889..a4414fa6edb 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -107,6 +107,7 @@ class Canvas $this->card = $card; $this->dirmodule = $module; // Correct values if canvas is into an external module + $regs = array(); if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { $this->canvas = $regs[1]; $this->dirmodule = $regs[2]; @@ -194,7 +195,7 @@ class Canvas // This functions should not be used anymore because canvas should contains only templates. - // http://wiki.dolibarr.org/index.php/Canvas_development + // https://wiki.dolibarr.org/index.php/Canvas_development /** * Return if a canvas contains an action controller @@ -215,7 +216,7 @@ class Canvas * @param string $action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas - * @see http://wiki.dolibarr.org/index.php/Canvas_development + * @see https://wiki.dolibarr.org/index.php/Canvas_development */ public function doActions(&$action = 'view', $id = 0) { diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 78f168fd8f7..7184d7846b0 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -365,7 +365,7 @@ class Comment extends CommonObject $sql = "SELECT"; $sql .= " c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c"; - $sql .= " WHERE c.fk_element = ".$fk_element; + $sql .= " WHERE c.fk_element = ".((int) $fk_element); $sql .= " AND c.element_type = '".$this->db->escape($element_type)."'"; $sql .= " AND c.entity = ".$conf->entity; $sql .= " ORDER BY c.tms DESC"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 0f3865f54a7..3e947c518c2 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -461,7 +461,7 @@ abstract class CommonDocGenerator $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), + $array_key.'_multicurrency_code' => $object->multicurrency_code, $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 6366cf52756..50d94da8531 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -801,7 +801,7 @@ abstract class CommonInvoice extends CommonObject { // phpcs:enable $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' WHERE rowid = '.$did; + $sql .= ' WHERE rowid = '.((int) $did); $sql .= ' AND traite = 0'; if ($this->db->query($sql)) { return 0; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 253ed9a1d02..a93acda2a17 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7,14 +7,14 @@ * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015-2021 Alexandre Spangaro * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2019 Nicolas ZABOURI - * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Josep Lluís Amador - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -358,7 +358,7 @@ abstract class CommonObject /** * @var string * @deprecated - * @see model_pdf + * @see $model_pdf */ public $modelpdf; @@ -1072,9 +1072,9 @@ abstract class CommonObject // Insert into database $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; - $sql .= " VALUES (".$this->id.", ".$fk_socpeople." , "; + $sql .= " VALUES (".$this->id.", ".((int) $fk_socpeople)." , "; $sql .= "'".$this->db->idate($datecreate)."'"; - $sql .= ", 4, ".$id_type_contact; + $sql .= ", 4, ".((int) $id_type_contact); $sql .= ")"; $resql = $this->db->query($sql); @@ -1148,7 +1148,7 @@ abstract class CommonObject if ($fk_socpeople) { $sql .= ", fk_socpeople = ".((int) $fk_socpeople); } - $sql .= " where rowid = ".$rowid; + $sql .= " where rowid = ".((int) $rowid); $resql = $this->db->query($sql); if ($resql) { return 0; @@ -1175,7 +1175,7 @@ abstract class CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; - $sql .= " WHERE rowid =".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1218,7 +1218,7 @@ abstract class CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql .= " WHERE element_id = ".$this->id; if ($listId) { - $sql .= " AND fk_c_type_contact IN (".$listId.")"; + $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; } dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); @@ -1338,7 +1338,7 @@ abstract class CommonObject $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; $sql .= " tc.code, tc.libelle"; $sql .= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)"; - $sql .= " WHERE ec.rowid =".$rowid; + $sql .= " WHERE ec.rowid =".((int) $rowid); $sql .= " AND ec.fk_c_type_contact=tc.rowid"; $sql .= " AND tc.element = '".$this->db->escape($this->element)."'"; @@ -1548,7 +1548,7 @@ abstract class CommonObject $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; } $sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc"; - $sql .= " WHERE ec.element_id = ".$id; + $sql .= " WHERE ec.element_id = ".((int) $id); $sql .= " AND ec.fk_socpeople = c.rowid"; if ($source == 'internal') { $sql .= " AND c.entity IN (".getEntity('user').")"; @@ -1564,7 +1564,7 @@ abstract class CommonObject } $sql .= " AND tc.active = 1"; if ($status) { - $sql .= " AND ec.statut = ".$status; + $sql .= " AND ec.statut = ".((int) $status); } dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); @@ -1706,7 +1706,7 @@ abstract class CommonObject if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { // If data not already loaded $sql = "SELECT rowid, code, libelle as label, coder"; $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE rowid = ".$idtype; + $sql .= " WHERE rowid = ".((int) $idtype); dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1939,7 +1939,7 @@ abstract class CommonObject } } - $sql .= " WHERE ".$id_field." = ".$id; + $sql .= " WHERE ".$id_field." = ".((int) $id); dol_syslog(__METHOD__."", LOG_DEBUG); $resql = $this->db->query($sql); @@ -2201,22 +2201,22 @@ abstract class CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; if (!empty($this->fields['fk_project'])) { // Common case if ($projectid) { - $sql .= ' SET fk_project = '.$projectid; + $sql .= ' SET fk_project = '.((int) $projectid); } else { $sql .= ' SET fk_project = NULL'; } - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.((int) $this->id); } elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm if ($projectid) { - $sql .= ' SET fk_project = '.$projectid; + $sql .= ' SET fk_project = '.((int) $projectid); } else { $sql .= ' SET fk_project = NULL'; } - $sql .= ' WHERE id = '.$this->id; + $sql .= ' WHERE id = '.((int) $this->id); } else // Special case for old architecture objects { if ($projectid) { - $sql .= ' SET fk_projet = '.$projectid; + $sql .= ' SET fk_projet = '.((int) $projectid); } else { $sql .= ' SET fk_projet = NULL'; } @@ -2225,7 +2225,7 @@ abstract class CommonObject dol_syslog(get_class($this)."::setProject", LOG_DEBUG); if ($this->db->query($sql)) { - $this->fk_project = $projectid; + $this->fk_project = ((int) $projectid); return 1; } else { dol_print_error($this->db); @@ -2332,7 +2332,7 @@ abstract class CommonObject $fieldname = 'multicurrency_tx'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$rate; + $sql .= ' SET '.$fieldname.' = '.((float) $rate); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2617,7 +2617,7 @@ abstract class CommonObject $fieldname = 'retained_warranty_fk_cond_reglement'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' SET '.$fieldname.' = '.((int) $id); $sql .= ' WHERE rowid='.((int) $this->id); if ($this->db->query($sql)) { @@ -2649,7 +2649,7 @@ abstract class CommonObject $fieldname = 'fk_address'; } - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".((int) $id); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { @@ -2695,7 +2695,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_shipping_method = ".$shipping_method_id; + $sql .= " SET fk_shipping_method = ".((int) $shipping_method_id); $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -2742,7 +2742,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_warehouse = ".$warehouse_id; + $sql .= " SET fk_warehouse = ".((int) $warehouse_id); $sql .= " WHERE rowid=".((int) $this->id); if ($this->db->query($sql)) { @@ -2819,7 +2819,7 @@ abstract class CommonObject dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_account = ".$fk_account; + $sql .= " SET fk_account = ".((int) $fk_account); $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); @@ -3022,8 +3022,8 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; - $sql .= ' WHERE rowid = '.$rowid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); + $sql .= ' WHERE rowid = '.((int) $rowid); dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -3062,12 +3062,12 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; $sql .= ' AND rang = '.($rang - 1); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1); - $sql .= ' WHERE rowid = '.$rowid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1)); + $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -3093,12 +3093,12 @@ abstract class CommonObject $fieldposition = 'position'; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang); $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql .= ' AND rang = '.($rang + 1); + $sql .= ' AND rang = '.((int) ($rang + 1)); if ($this->db->query($sql)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1); - $sql .= ' WHERE rowid = '.$rowid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1)); + $sql .= ' WHERE rowid = '.((int) $rowid); if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -3518,7 +3518,7 @@ abstract class CommonObject $fieldttc = 'total_ttc'; // Specific code for backward compatibility with old field names if ($this->element == 'facture' || $this->element == 'facturerec') { - $fieldht = 'total'; + $fieldtva = 'total_tva'; } if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { $fieldtva = 'total_tva'; @@ -4047,7 +4047,7 @@ abstract class CommonObject global $db; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.$fk_object_where; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where); $resql = $db->query($sql); if (empty($resql)) { @@ -4221,7 +4221,7 @@ abstract class CommonObject public function getSpecialCode($lineid) { $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid = '.$lineid; + $sql .= ' WHERE rowid = '.((int) $lineid); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -4263,7 +4263,7 @@ abstract class CommonObject //print $id.'-'.$table.'-'.$elementname.'
'; // Check if third party can be deleted $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$this->fk_element." = ".$id; + $sql .= " WHERE ".$this->fk_element." = ".((int) $id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -7656,7 +7656,7 @@ abstract class CommonObject public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); if (!$db->query($sql)) { if ($ignoreerrors) { @@ -7688,7 +7688,8 @@ abstract class CommonObject $buyPrice = 0; - if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { // In most cases, test here is false + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull > 0)) { + // When ForceBuyingPriceIfNull is set $buyPrice = $unitPrice * (1 - $discountPercent / 100); } else { // Get cost price for margin calculation @@ -8410,7 +8411,7 @@ abstract class CommonObject // If we have a field ref with a default value of (PROV) if (!$error) { if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && !is_null($this->fields['ref']['default']) && $this->fields['ref']['default'] == '(PROV)') { - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id); $resqlupdate = $this->db->query($sql); if ($resqlupdate === false) { @@ -9266,7 +9267,7 @@ abstract class CommonObject } $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files"; - $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 01a6eb5e697..c8421c54b1f 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -163,7 +163,6 @@ class Ctypent // extends CommonObject */ public function fetch($id, $code = '', $label = '') { - global $langs; $sql = "SELECT"; $sql .= " t.id,"; $sql .= " t.code,"; @@ -173,7 +172,7 @@ class Ctypent // extends CommonObject $sql .= " t.module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; if ($id) { - $sql .= " WHERE t.id = ".$id; + $sql .= " WHERE t.id = ".((int) $id); } elseif ($code) { $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; } elseif ($label) { diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 6ba04c044e9..b0a604e9e28 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -165,15 +165,12 @@ class Ctyperesource $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($id) { - $sql .= " WHERE t.id = ".$id; + $sql .= " WHERE t.id = ".((int) $id); } elseif ($code) { $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; } elseif ($label) { diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index 8c835ed649e..c6be235b89a 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -272,7 +272,7 @@ class DefaultValues extends CommonObject } elseif ($key == 'customsql') { $sqlwhere[] = $value; } elseif (is_array($value)) { - $sqlwhere[] = $key.' IN ('.implode(',', $value).')'; + $sqlwhere[] = $key.' IN ('.$this->db->sanitize(implode(',', $value)).')'; } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 310f141fc1c..63ef3dc1153 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -144,13 +144,13 @@ class DiscountAbsolute $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; if ($rowid) { - $sql .= " AND sr.rowid=".$rowid; + $sql .= " AND sr.rowid=".((int) $rowid); } if ($fk_facture_source) { - $sql .= " AND sr.fk_facture_source=".$fk_facture_source; + $sql .= " AND sr.fk_facture_source = ".((int) $fk_facture_source); } if ($fk_invoice_supplier_source) { - $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; + $sql .= " AND sr.fk_invoice_supplier_source = ".((int) $fk_invoice_supplier_source); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -337,11 +337,11 @@ class DiscountAbsolute // Delete but only if not used $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; if ($this->fk_facture_source) { - $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie + $sql .= " WHERE fk_facture_source = ".((int) $this->fk_facture_source); // Delete all lines of same serie } elseif ($this->fk_invoice_supplier_source) { - $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie + $sql .= " WHERE fk_invoice_supplier_source = ".((int) $this->fk_invoice_supplier_source); // Delete all lines of same serie } else { - $sql .= " WHERE rowid = ".$this->id; // Delete only line + $sql .= " WHERE rowid = ".((int) $this->id); // Delete only line } $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit @@ -421,17 +421,17 @@ class DiscountAbsolute $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; if (!empty($this->discount_type)) { if ($rowidline) { - $sql .= " SET fk_invoice_supplier_line = ".$rowidline; + $sql .= " SET fk_invoice_supplier_line = ".((int) $rowidline); } if ($rowidinvoice) { - $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; + $sql .= " SET fk_invoice_supplier = ".((int) $rowidinvoice); } } else { if ($rowidline) { - $sql .= " SET fk_facture_line = ".$rowidline; + $sql .= " SET fk_facture_line = ".((int) $rowidline); } if ($rowidinvoice) { - $sql .= " SET fk_facture = ".$rowidinvoice; + $sql .= " SET fk_facture = ".((int) $rowidinvoice); } } $sql .= " WHERE rowid = ".$this->id; @@ -597,12 +597,12 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received + $sql .= ' AND f.type IN ('.$this->db->sanitize($invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION).')'; // Find discount coming from credit note or excess received } elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid + $sql .= ' AND f.type IN ('.$this->db->sanitize($invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE).')'; // Find discount coming from credit note or excess paid } else { $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; dol_print_error($this->error); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 3672f7faa07..921c102fd43 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -113,7 +113,7 @@ class DolGraph $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; if (is_readable($color_file)) { - include_once $color_file; + include $color_file; if (isset($theme_bordercolor)) { $this->bordercolor = $theme_bordercolor; } diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 49eda053b8d..6ac331167d3 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -784,7 +784,7 @@ class dolReceiptPrinter extends Printer $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id); $sql .= " ORDER BY p.datep"; $resql = $this->db->query($sql); if ($resql) { @@ -879,7 +879,7 @@ class dolReceiptPrinter extends Printer $error = 0; $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' WHERE rowid = '.((int) $printerid); $sql .= ' AND entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 566407cffc4..7356e53dc0a 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -196,8 +196,8 @@ class Fiscalyear extends CommonObject $sql .= ", date_start = '".$this->db->idate($this->date_start)."'"; $sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql .= ", statut = '".$this->db->escape($this->statut ? $this->statut : 0)."'"; - $sql .= ", fk_user_modif = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= ", fk_user_modif = ".((int) $user->id); + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d75ec44798f..9c8293e4601 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -16,7 +16,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014-2020 Alexandre Spangaro - * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel @@ -96,7 +96,7 @@ class Form * @param string $preselected Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $moreparam More param to add on a href URL. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' @@ -237,6 +237,9 @@ class Form $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); $ret .= ''; + } elseif (preg_match('/^(checkbox)/', $typeofdata)) { + $tmp = explode(':', $typeofdata); + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = $tmp[2]; @@ -298,6 +301,9 @@ class Form $ret .= dol_print_email($value, 0, 0, 0, 0, 1); } elseif (preg_match('/^(amount|numeric)/', $typeofdata)) { $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); + } elseif (preg_match('/^(checkbox)/', $typeofdata)) { + $tmp = explode(':', $typeofdata); + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { $ret .= dol_htmlentitiesbr($value); } elseif (preg_match('/^safehtmlstring/', $typeofdata)) { @@ -1227,9 +1233,10 @@ class Form * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) + * @param array $excludeids Exclude IDs from the select combo * @return string HTML string with select box for thirdparty. */ - public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false) + public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false, $excludeids = array()) { // phpcs:enable global $conf, $user, $langs; @@ -1237,6 +1244,9 @@ class Form $out = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo) { + if (is_null($ajaxoptions)) { + $ajaxoptions = array(); + } // No immediate load of all database $placeholder = ''; if ($selected && empty($selected_input_value)) { @@ -1247,7 +1257,7 @@ class Form unset($societetmp); } // mode 1 - $urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&filter='.urlencode($filter).($showtype ? '&showtype='.urlencode($showtype) : ''); + $urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ? '' : '&excludeids='.join(',', $excludeids)).($showtype ? '&showtype='.urlencode($showtype) : ''); $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out .= ''; if (empty($hidelabel)) { @@ -1264,7 +1274,7 @@ class Form } } else { // Immediate load of all database - $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple); + $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids); } return $out; @@ -1277,7 +1287,7 @@ class Form * * @param string $selected Preselected type * @param string $htmlname Name of field in form - * @param string $filter Optional filters criteras (example: 's.rowid <> x', 's.client in (1,3)') + * @param string $filter Optional filters criteras (example: 's.rowid NOT IN (x)', 's.client IN (1,3)'). Do not use a filter coming from input of users. * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use standard HTML select component without beautification @@ -1288,9 +1298,10 @@ class Form * @param string $morecss Add more css styles to the SELECT component * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param array $excludeids Exclude IDs from the select combo * @return string HTML string with */ - public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) + public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false, $excludeids = array()) { // phpcs:enable global $conf, $user, $langs; @@ -1338,6 +1349,9 @@ class Form if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { $sql .= " AND s.status <> 0"; } + if (!empty($excludeids)) { + $sql .= " AND rowid NOT IN (".$this->db->sanitize(join(',', $excludeids)).")"; + } // Add criteria if ($filterkey && $filterkey != '') { $sql .= " AND ("; @@ -1823,7 +1837,7 @@ class Form * * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) * @param string $htmlname Field name in form - * @param int $show_empty 0=list with no empty value, 1=add also an empty value into list + * @param int|string $show_empty 0=list with no empty value, 1=add also an empty value into list * @param array $exclude Array list of users id to exclude * @param int $disabled If select list must be disabled * @param array|string $include Array list of users id to include. User '' for all users or 'hierarchy' to have only supervised users or 'hierarchyme' to have supervised + me @@ -1887,7 +1901,7 @@ class Form if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity"; if ($force_entity) { - $sql .= " WHERE u.entity IN (0,".$force_entity.")"; + $sql .= " WHERE u.entity IN (0, ".$force_entity.")"; } else { $sql .= " WHERE u.entity IS NOT NULL"; } @@ -1897,17 +1911,17 @@ class Form $sql .= " ON ug.fk_user = u.rowid"; $sql .= " WHERE ug.entity = ".$conf->entity; } else { - $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE u.entity IN (0, ".$conf->entity.")"; } } if (!empty($user->socid)) { $sql .= " AND u.fk_soc = ".$user->socid; } if (is_array($exclude) && $excludeUsers) { - $sql .= " AND u.rowid NOT IN (".$excludeUsers.")"; + $sql .= " AND u.rowid NOT IN (".$this->db->sanitize($excludeUsers).")"; } if ($includeUsers) { - $sql .= " AND u.rowid IN (".$includeUsers.")"; + $sql .= " AND u.rowid IN (".$this->db->sanitize($includeUsers).")"; } if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) { $sql .= " AND u.statut <> 0"; @@ -1923,9 +1937,9 @@ class Form } if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname - $sql .= " ORDER BY u.firstname ASC"; + $sql .= " ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC"; } else { - $sql .= " ORDER BY u.lastname ASC"; + $sql .= " ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC"; } dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); @@ -1941,7 +1955,14 @@ class Form // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined $out .= ''; $out .= ''; - $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); + $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0, 'minwidth100', '', '', 1, array(), false, $excludeids); $out .= ''; $out .= ''; } else { @@ -5661,7 +5685,7 @@ class Form $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE t.fk_pays = c.rowid"; $sql .= " AND t.active > 0"; - $sql .= " AND c.code IN (".$country_code.")"; + $sql .= " AND c.code IN (".$this->db->sanitize($country_code, 1).")"; $sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC"; $resql = $this->db->query($sql); @@ -5744,6 +5768,7 @@ class Form $defaultnpr = (preg_match('/\*/', $selectedrate) ? 1 : $defaultnpr); $defaulttx = str_replace('*', '', $selectedrate); $defaultcode = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $defaulttx, $reg)) { $defaultcode = $reg[1]; $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx); @@ -7207,7 +7232,7 @@ class Form } /** - * Show a multiselect form from an array. + * Show a multiselect form from an array. WARNING: Use this only for short lists. * * @param string $htmlname Name of select * @param array $array Array with key+value @@ -7322,7 +7347,7 @@ class Form /** - * Show a multiselect dropbox from an array. + * Show a multiselect dropbox from an array. If a saved selection of fields exists for user (into $user->conf->MAIN_SELECTEDFIELDS_contextofpage), we use this one instead of default. * * @param string $htmlname Name of HTML field * @param array $array Array with array of fields we could show. This array may be modified according to setup of user. @@ -7338,8 +7363,9 @@ class Form return ''; } - $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties - if (!empty($user->conf->$tmpvar)) { + $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved selected fields to show + + if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user $tmparray = explode(',', $user->conf->$tmpvar); foreach ($array as $key => $val) { //var_dump($key); @@ -7350,6 +7376,12 @@ class Form $array[$key]['checked'] = 0; } } + } else { // There is no list of fields already customized for user + foreach ($array as $key => $val) { + if ($array[$key]['checked'] < 0) { + $array[$key]['checked'] = 0; + } + } } $lis = ''; @@ -7368,7 +7400,8 @@ class Form $langs->load($val['langfile']); } - $lis .= '
  • '; + // Note: $val['checked'] <> 0 means we must show the field into the combo list + $lis .= '
  • '; $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); } } @@ -7642,17 +7675,17 @@ class Form } $possiblelinks = array( - 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'), - 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'), - 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), - 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'), + 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'), + 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), + 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), + 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), 'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', - 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), - 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), - 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'), - 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')') + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').')'), + 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), + 'ticket'=>array('enabled'=>$conf->ticket->enabled, 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('ticket').')') ); } @@ -7709,16 +7742,17 @@ class Form print '
    '; print ''; - print ''; - print ''; + print ''; + print ''; print ''; + print ''.price($objp->total_ht).''; + print ''; print ''; print ''; $i++; @@ -7748,7 +7782,7 @@ class Form '; // Severity @@ -307,7 +313,7 @@ class FormTicket if ($this->withfile == 2) { // Can add other files $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; @@ -439,8 +445,8 @@ class FormTicket print dol_get_fiche_end(); } - print '
    '; - print ''; + print '
    '; + print ''; if ($this->withcancel) { print "      "; print ''; @@ -551,7 +557,7 @@ class FormTicket * * @param string $selected Id categorie pre-selectionnée * @param string $htmlname Nom de la zone select - * @param string $filtertype To filter on field type in llx_c_ticket_category (array('code'=>xx,'label'=>zz)) + * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users. * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $empty 1=peut etre vide, 0 sinon * @param int $noadmininfo 0=Add admin info, 1=Disable admin info @@ -567,12 +573,6 @@ class FormTicket dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); - $filterarray = array(); - - if ($filtertype != '' && $filtertype != '-1') { - $filterarray = explode(',', $filtertype); - } - $ticketstat->loadCacheCategoriesTickets(); print ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 0f59859bd64..be81c1e2737 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -234,7 +234,7 @@ class Link extends CommonObject global $conf; $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE objecttype = '".$this->db->escape($objecttype)."' AND objectid = ".$objectid; + $sql .= " WHERE objecttype = '".$this->db->escape($objecttype)."' AND objectid = ".((int) $objectid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } @@ -284,7 +284,7 @@ class Link extends CommonObject global $conf; $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE objecttype = '".$db->escape($objecttype)."' AND objectid = ".$objectid; + $sql .= " WHERE objecttype = '".$db->escape($objecttype)."' AND objectid = ".((int) $objectid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } @@ -314,7 +314,7 @@ class Link extends CommonObject } $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); if ($conf->entity != 0) { $sql .= " AND entity = ".$conf->entity; } diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index add5ccda7b3..345ec5b38e3 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2018 Philippe Grand + * Copyright (C) 2021 Thibault FOUCART * * 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 @@ -25,7 +26,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - /** * Class to manage notifications */ @@ -80,8 +80,8 @@ class Notify 'SHIPPING_VALIDATE', 'EXPENSE_REPORT_VALIDATE', 'EXPENSE_REPORT_APPROVE', - 'HOLIDAY_VALIDATE', - 'HOLIDAY_APPROVE', + 'HOLIDAY_VALIDATE', + 'HOLIDAY_APPROVE', 'ACTION_CREATE' ); @@ -442,49 +442,54 @@ class Notify switch ($notifcode) { case 'BILL_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->facture->dir_output; + $link = ''.$newref.''; + $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); $object_type = 'facture'; + $labeltouse = $conf->global->BILL_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link); break; case 'BILL_PAYED': - $link = ''.$newref.''; - $dir_output = $conf->facture->dir_output; + $link = ''.$newref.''; + $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); $object_type = 'facture'; + $labeltouse = $conf->global->BILL_PAYED_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $link); break; case 'ORDER_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->commande->dir_output; + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); $object_type = 'order'; + $labeltouse = $conf->global->ORDER_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; case 'PROPAL_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->propal->multidir_output[$object->entity]; + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); $object_type = 'propal'; + $labeltouse = $conf->global->PROPAL_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $link); break; case 'PROPAL_CLOSE_SIGNED': - $link = ''.$newref.''; - $dir_output = $conf->propal->multidir_output[$object->entity]; + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); $object_type = 'propal'; + $labeltouse = $conf->global->PROPAL_CLOSE_SIGNED_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); break; case 'FICHINTER_ADD_CONTACT': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link); break; case 'FICHINTER_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $link); break; case 'ORDER_SUPPLIER_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; @@ -492,7 +497,7 @@ class Notify $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; @@ -500,7 +505,7 @@ class Notify $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; @@ -508,56 +513,78 @@ class Notify $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->expedition->dir_output.'/sending/'; + $link = ''.$newref.''; + $dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment'); $object_type = 'expedition'; + $labeltouse = $conf->global->SHIPPING_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link); break; case 'EXPENSE_REPORT_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->expensereport->dir_output; $object_type = 'expensereport'; + $labeltouse = $conf->global->EXPENSE_REPORT_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link); break; case 'EXPENSE_REPORT_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->expensereport->dir_output; $object_type = 'expensereport'; + $labeltouse = $conf->global->EXPENSE_REPORT_APPROVE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link); break; case 'HOLIDAY_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->holiday->dir_output; $object_type = 'holiday'; + $labeltouse = $conf->global->HOLIDAY_VALIDATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated", $link); break; case 'HOLIDAY_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->holiday->dir_output; $object_type = 'holiday'; + $labeltouse = $conf->global->HOLIDAY_APPROVE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved", $link); - break; + break; case 'ACTION_CREATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->agenda->dir_output; $object_type = 'action'; + $labeltouse = $conf->global->ACTION_CREATE_TEMPLATE; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextActionAdded", $link); break; } + + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + $arraydefaultmessage = null; + + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $object_type.'_send', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $message = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + } else { + $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; + $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; + } + $ref = dol_sanitizeFileName($newref); - $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; + $pdf_path = $dir_output."/".$ref.".pdf"; if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; } else { $filepdf = $pdf_path; + $filename_list[] = $filepdf; + $mimetype_list[] = mime_content_type($filepdf); + $mimefilename_list[] = $ref.".pdf"; } - $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; - $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message .= "\n"; - $message .= $mesg; - $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); if (!isset($action)) { $action = ''; @@ -653,49 +680,49 @@ class Notify switch ($notifcode) { case 'BILL_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->facture->dir_output; + $link = ''.$newref.''; + $dir_output = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link); break; case 'BILL_PAYED': - $link = ''.$newref.''; - $dir_output = $conf->facture->dir_output; + $link = ''.$newref.''; + $dir_output = $$conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link); break; case 'ORDER_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->commande->dir_output; + $link = ''.$newref.''; + $dir_output = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); $object_type = 'order'; $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; case 'PROPAL_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->propal->multidir_output[$object->entity]; + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link); break; case 'PROPAL_CLOSE_SIGNED': - $link = ''.$newref.''; - $dir_output = $conf->propal->multidir_output[$object->entity]; + $link = ''.$newref.''; + $dir_output = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); break; case 'FICHINTER_ADD_CONTACT': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link); break; case 'FICHINTER_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link); break; case 'ORDER_SUPPLIER_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; @@ -703,7 +730,7 @@ class Notify $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; @@ -711,7 +738,7 @@ class Notify $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE2': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; @@ -719,7 +746,7 @@ class Notify $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->dir_output.'/commande/'; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; @@ -727,37 +754,37 @@ class Notify $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': - $link = ''.$newref.''; - $dir_output = $conf->expedition->dir_output.'/sending/'; + $link = ''.$newref.''; + $dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment'); $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link); break; case 'EXPENSE_REPORT_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->expensereport->dir_output; $object_type = 'expensereport'; $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link); break; case 'EXPENSE_REPORT_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->expensereport->dir_output; $object_type = 'expensereport'; $mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link); break; case 'HOLIDAY_VALIDATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->holiday->dir_output; $object_type = 'holiday'; $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated", $link); break; case 'HOLIDAY_APPROVE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->holiday->dir_output; $object_type = 'holiday'; $mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved", $link); - break; + break; case 'ACTION_CREATE': - $link = ''.$newref.''; + $link = ''.$newref.''; $dir_output = $conf->agenda->dir_output; $object_type = 'action'; $mesg = $langs->transnoentitiesnoconv("EMailTextActionAdded", $link); @@ -770,6 +797,9 @@ class Notify $filepdf = ''; } else { $filepdf = $pdf_path; + $filename_list[] = $pdf_path; + $mimetype_list[] = mime_content_type($filepdf); + $mimefilename_list[] = $ref.".pdf"; } $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 5156e7b767a..abb006969db 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -405,7 +405,7 @@ class SimpleOpenID $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; } - $response = getURLContent($url); + $response = getURLContent($url, 'GET', '', 1, array(), array('http', 'https')); list($servers, $delegates) = $this->HTML2OpenIDServer($response); if (count($servers) == 0) { @@ -525,7 +525,7 @@ class SimpleOpenID dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); $addheaders = array('Accept: application/xrds+xml'); - $response = getURLContent($url, 'GET', '', 1, $addheaders); + $response = getURLContent($url, 'GET', '', 1, $addheaders, array('http', 'https'), 0); /* response should like this: diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 0f09d232712..c11bdd5563d 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -181,7 +181,7 @@ class RssParser * @param string $urlRSS Url to parse * @param int $maxNb Max nb of records to get (0 for no limit) * @param int $cachedelay 0=No cache, nb of seconds we accept cache files (cachedir must also be defined) - * @param string $cachedir Directory where to save cache file + * @param string $cachedir Directory where to save cache file (For example $conf->externalrss->dir_temp) * @return int <0 if KO, >0 if OK */ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '') @@ -189,6 +189,7 @@ class RssParser global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $rss = ''; $str = ''; // This will contain content of feed @@ -225,21 +226,10 @@ class RssParser $str = file_get_contents($newpathofdestfile); } else { try { - ini_set("user_agent", "Dolibarr ERP-CRM RSS reader"); - ini_set("max_execution_time", $conf->global->MAIN_USE_RESPONSE_TIMEOUT); - ini_set("default_socket_timeout", $conf->global->MAIN_USE_RESPONSE_TIMEOUT); - - $opts = array('http'=>array('method'=>"GET")); - if (!empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)) { - $opts['http']['timeout'] = $conf->global->MAIN_USE_CONNECT_TIMEOUT; + $result = getURLContent($this->_urlRSS, 'GET', '', 1, array(), array('http', 'https'), 0); + if (!empty($result['content'])) { + $str = $result['content']; } - if (!empty($conf->global->MAIN_PROXY_USE)) { - $opts['http']['proxy'] = 'tcp://'.$conf->global->MAIN_PROXY_HOST.':'.$conf->global->MAIN_PROXY_PORT; - } - //var_dump($opts);exit; - $context = stream_context_create($opts); - - $str = file_get_contents($this->_urlRSS, false, $context); } catch (Exception $e) { print 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage(); } diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index ef26dc4ac65..ba8d4349a38 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -392,7 +392,6 @@ class SMTPs } else { if (function_exists('stream_socket_client') && !empty($this->_options)) { $socket_context = stream_context_create($this->_options); // An array of options for stream_context_create() - set_error_handler([$this, 'errorHandler']); $this->socket = @stream_socket_client( preg_replace('@tls://@i', '', $this->getHost()).// Host to 'hit', IP or domain ':'.$this->getPort(), // which Port number to use diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index f391f2f6f50..f06bb32b62b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -631,7 +631,7 @@ class Translate // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities because // we want to keep '"' '' '' '' '' '
    ' '< ' '' that are reliable HTML tags inside translation strings. $str = str_replace( - array('"', '', '', '', '', '', '', '
    ', '
    ', '', '', '
    ', '
    ', '', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>' + array('"', '', '', '', '', '', '
    ', '
    ', '', '', '
    ', '
    ', '', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>' array('__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__tagb__', '__tagbend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'), $str ); @@ -646,7 +646,7 @@ class Translate // Restore reliable HTML tags into original translation string $str = str_replace( array('__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'), - array('"', '', '', '', '', '', '', '
    ', '
    ', '
    ', '
    ', '', '< ', '>'), + array('"', '', '', '', '', '', '
    ', '
    ', '
    ', '
    ', '', '< ', '>'), $str ); diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 7be7e8f28cc..9534970a856 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -194,6 +194,7 @@ class Utils { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; + global $dolibarr_main_db_character_set; $langs->load("admin"); @@ -316,7 +317,12 @@ class Utils } else { $param .= " -d"; // No row information (no data) } - $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + if ($dolibarr_main_db_character_set == 'utf8mb4') { + // We save output into utf8mb4 charset + $param .= " --default-character-set=utf8mb4"; + } else { + $param .= " --default-character-set=utf8"; // We always save output into utf8 charset + } $paramcrypted = $param; $paramclear = $param; if (!empty($dolibarr_main_db_pass)) { diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index c5e0137b98d..ca6e61e3b1c 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -15,7 +15,7 @@ * along with this program. If not, see . * * Note: This tool can be included into a list page with : - * define('USE_CUSTOME_REPORT_AS_INCLUDE', 1); + * define('USE_CUSTOM_REPORT_AS_INCLUDE', 1); * include DOL_DOCUMENT_ROOT.'/core/customreports.php'; */ @@ -25,7 +25,7 @@ * \brief Page to make custom reports */ -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { require '../main.inc.php'; // Get parameters @@ -151,8 +151,6 @@ if ($user->socid > 0) { // Protection if external user accessforbidden(); } -$result = restrictedArea($user, $object->element, 0, ''); - // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); //$extrafields->fetch_name_optionals_label($object->table_element_line); @@ -177,6 +175,7 @@ $arrayofgroupby = array(); $arrayofyaxis = array(); $arrayofvaluesforgroupby = array(); +$result = restrictedArea($user, $object->element, 0, ''); /* @@ -194,7 +193,7 @@ $arrayofvaluesforgroupby = array(); $form = new Form($db); $formother = new FormOther($db); -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { llxHeader('', $langs->transnoentitiesnoconv('CustomReports'), ''); print dol_get_fiche_head($head, 'customreports', $title, -1, $picto); @@ -790,7 +789,7 @@ if ($sql) { print '
    '; -if (!defined('USE_CUSTOME_REPORT_AS_INCLUDE')) { +if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { print dol_get_fiche_end(); } diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 36a74f8f85e..68af901a757 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014 Florian Henry - * Copyright (C) 2019 Eric Seigne - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2019 Eric Seigne + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -277,8 +277,8 @@ function getDefaultDatesForTransfer() // Period by default on transfer (0: previous month | 1: current month | 2: fiscal year) $periodbydefaultontransfer = (empty($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? 0 : $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER); if ($periodbydefaultontransfer == 2) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql = "SELECT date_start, date_end FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { @@ -288,6 +288,9 @@ function getDefaultDatesForTransfer() } else { $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); + if ($conf->global->SOCIETE_FISCAL_MONTH_START > dol_print_date(dol_now(), '%m')) { + $year_start = $year_start - 1; + } $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1) { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 72de6036e8f..ed01d9d6e9f 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -303,14 +303,17 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if ($offsetforchartofaccount > 0) { // Replace lines - // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401, 'PCG99-ABREGE', 'CAPIT', '1234', 1400, '...', 1);' + // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401, 'PCG99-ABREGE', 'CAPIT', '1234', 1400,...' // with - // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401 + 200100000, 'PCG99-ABREGE','CAPIT', '1234', 1400 + 200100000, '...', 1);' - // Note: string with 1234 instead of '1234' is also supported + // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401 + 200100000, 'PCG99-ABREGE','CAPIT', '1234', 1400 + 200100000,...' + // Note: string with 'PCG99-ABREGE','CAPIT', 1234 instead of 'PCG99-ABREGE','CAPIT', '1234' is also supported $newsql = preg_replace('/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims', 'VALUES (__ENTITY__, \1 + '.$offsetforchartofaccount.', \2, \3 + '.$offsetforchartofaccount, $newsql); $newsql = preg_replace('/([,\s])0 \+ '.$offsetforchartofaccount.'/ims', '\1 0', $newsql); //var_dump($newsql); $arraysql[$i] = $newsql; + + // FIXME Because we force the rowid during insert, we must also update the sequence with postgresql by running + // SELECT dol_util_rebuild_sequences(); } } @@ -531,24 +534,23 @@ function dolibarr_del_const($db, $name, $entity = 1) } /** - * Recupere une constante depuis la base de donnees. + * Get the value of a setup constant from database * * @param DoliDB $db Database handler - * @param string $name Nom de la constante + * @param string $name Name of constant * @param int $entity Multi company id - * @return string Valeur de la constante + * @return string Value of constant * * @see dolibarr_del_const(), dolibarr_set_const(), dol_set_user_param() */ function dolibarr_get_const($db, $name, $entity = 1) { - global $conf; $value = ''; $sql = "SELECT ".$db->decrypt('value')." as value"; $sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name = ".$db->encrypt($name, 1); - $sql .= " AND entity = ".$entity; + $sql .= " AND entity = ".((int) $entity); dol_syslog("admin.lib::dolibarr_get_const", LOG_DEBUG); $resql = $db->query($sql); @@ -568,7 +570,7 @@ function dolibarr_get_const($db, $name, $entity = 1) * @param DoliDB $db Database handler * @param string $name Name of constant * @param string $value Value of constant - * @param string $type Type of constante (chaine par defaut) + * @param string $type Type of constant. Deprecated, only strings are allowed for $value. Caller must json encode/decode to store other type of data. * @param int $visible Is constant visible in Setup->Other page (0 by default) * @param string $note Note on parameter * @param int $entity Multi company id (0 means all entities) @@ -596,7 +598,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE name = ".$db->encrypt($name, 1); if ($entity >= 0) { - $sql .= " AND entity = ".$entity; + $sql .= " AND entity = ".((int) $entity); } dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); @@ -607,7 +609,7 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $sql .= " VALUES ("; $sql .= $db->encrypt($name, 1); $sql .= ", ".$db->encrypt($value, 1); - $sql .= ",'".$db->escape($type)."',".$visible.",'".$db->escape($note)."',".$entity.")"; + $sql .= ",'".$db->escape($type)."',".((int) $visible).",'".$db->escape($note)."',".((int) $entity).")"; //print "sql".$value."-".pg_escape_string($value)."-".$sql;exit; //print "xx".$db->escape($value); @@ -632,16 +634,28 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, /** * Prepare array with list of tabs * - * @return array Array of tabs to show + * @param int $nbofactivatedmodules Number f oactivated modules + * @param int $nboftotalmodules Nb of total modules + * @return array Array of tabs to show */ -function modules_prepare_head() +function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules) { - global $langs, $conf, $user; + global $langs, $conf, $user, $form; + + $desc = $langs->trans("ModulesDesc", '{picto}'); + $desc = str_replace('{picto}', img_picto('', 'switch_off'), $desc); + $h = 0; $head = array(); $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common'; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$mode; - $head[$h][1] = $langs->trans("AvailableModules"); + if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled) + $head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc); + $head[$h][1] .= img_warning($langs->trans("YouMustEnableOneModule")); + } else { + //$head[$h][1] = $langs->trans("AvailableModules").$form->textwithpicto(''.$nbofactivatedmodules.' / '.$nboftotalmodules.'', $desc, 1, 'help', '', 1, 3); + $head[$h][1] = $langs->trans("AvailableModules").''.$nbofactivatedmodules.' / '.$nboftotalmodules.''; + } $head[$h][2] = 'modules'; $h++; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 658d7816001..4108724236d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -25,7 +25,7 @@ /** - * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php). + * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajax/ajaxcompanies.php). * The HTML field must be an input text with id=search_$htmlname. * This use the jQuery "autocomplete" function. If we want to use the select2, we must also convert the input into select on funcntions that call this method. * diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 6eac92e69bc..30a3d21de90 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -72,7 +72,7 @@ function bank_prepare_head(Account $object) // List of all standing receipts $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql .= " WHERE b.fk_account = ".$object->id; + $sql .= " WHERE b.fk_account = ".((int) $object->id); $resql = $db->query($sql); if ($resql) { @@ -83,7 +83,7 @@ function bank_prepare_head(Account $object) $db->free($resql); } - $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".((int) $object->id); $head[$h][1] = $langs->trans("AccountStatements"); if (($nbReceipts) > 0) { $head[$h][1] .= ''.($nbReceipts).''; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 05b3a717a49..3c2884e4b5b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1087,7 +1087,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= natural_search($searchAddressPhoneDBFields, $search_address); } if (count($search_roles) > 0) { - $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; + $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))"; } // Add where from extra fields $extrafieldsobjectkey = $contactstatic->table_element; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index ecf1cf999de..a615c04ca8e 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -658,20 +658,21 @@ function getGMTEasterDatetime($year) } /** - * Return the number of non working days including saturday and sunday (or not) between 2 dates in timestamp. + * Return the number of non working days including Friday, Saturday and Sunday (or not) between 2 dates in timestamp. * Dates must be UTC with hour, min, sec to 0. - * Called by function num_open_day() + * Called by function num_open_day() * - * @param int $timestampStart Timestamp start (UTC with hour, min, sec = 0) - * @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0) - * @param string $country_code Country code - * @param int $lastday Last day is included, 0: no, 1:yes - * @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes) - * @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes) - * @return int|string Number of non working days or error message string if error + * @param int $timestampStart Timestamp start (UTC with hour, min, sec = 0) + * @param int $timestampEnd Timestamp end (UTC with hour, min, sec = 0) + * @param string $country_code Country code + * @param int $lastday Last day is included, 0: no, 1:yes + * @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes) + * @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes) + * @param int $includefriday Include friday as non working day (-1=use setup, 0=no, 1=yes) + * @return int|string Number of non working days or error message string if error * @see num_between_day(), num_open_day() */ -function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1) +function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1) { global $db, $conf, $mysoc; @@ -685,12 +686,14 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', if (empty($country_code)) { $country_code = $mysoc->country_code; } - + if ($includefriday < 0) { + $includefriday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY : 0); + } if ($includesaturday < 0) { $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1); } if ($includesunday < 0) { - $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); + $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1); } $country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid'); @@ -775,6 +778,21 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', //print 'annee='.$annee.' $jour='.$jour.' $mois='.$mois.' $jour_lundi_paques='.$jour_lundi_paques.' $mois_lundi_paques='.$mois_lundi_paques."\n"; } + //Good Friday + if (in_array('goodfriday', $specialdayrule)) { + // Pulls the date of Easter + $easter = getGMTEasterDatetime($annee); + + // Calculates the date of Good Friday based on Easter + $date_good_friday = $easter - (2 * 3600 * 24); + $dom_good_friday = gmdate("d", $date_good_friday); + $month_good_friday = gmdate("m", $date_good_friday); + + if ($dom_good_friday == $jour && $month_good_friday == $mois) { + $ferie = true; + } + } + if (in_array('ascension', $specialdayrule)) { // Calcul du jour de l'ascension (39 days after easter day) $date_paques = getGMTEasterDatetime($annee); @@ -836,17 +854,22 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', } //print "ferie=".$ferie."\n"; - // If we have to include saturday and sunday + // If we have to include Friday, Saturday and Sunday if (!$ferie) { - if ($includesaturday || $includesunday) { + if ($includefriday || $includesaturday || $includesunday) { $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); - if ($includesaturday) { //Saturday (6) and Sunday (0) + if ($includefriday) { //Friday (5), Saturday (6) and Sunday (0) + if ($jour_semaine == 5) { + $ferie = true; + } + } + if ($includesaturday) { //Friday (5), Saturday (6) and Sunday (0) if ($jour_semaine == 6) { $ferie = true; } } - if ($includesunday) { //Saturday (6) and Sunday (0) + if ($includesunday) { //Friday (5), Saturday (6) and Sunday (0) if ($jour_semaine == 0) { $ferie = true; } diff --git a/htdocs/core/lib/eventorganization.lib.php b/htdocs/core/lib/eventorganization.lib.php index 80dc72b50e5..2f8ea573c1f 100644 --- a/htdocs/core/lib/eventorganization.lib.php +++ b/htdocs/core/lib/eventorganization.lib.php @@ -46,6 +46,11 @@ function eventorganizationAdminPrepareHead() $head[$h][2] = 'eventorganization_extrafields'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/eventorganization_confboothattendee_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Attendees").")"; + $head[$h][2] = 'conferenceorboothattendee_extrafields'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b7e7ffd5e7e..755cd8674df 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -50,7 +50,7 @@ function dol_basename($pathfile) * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx'). * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) - * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only + * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only, 4=Force load of perm * @param int $nohook Disable all hooks * @param string $relativename For recursive purpose only. Must be "" at first call. * @param string $donotfollowsymlinks Do not follow symbolic links @@ -67,6 +67,7 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl $loaddate = ($mode == 1 || $mode == 2) ?true:false; $loadsize = ($mode == 1 || $mode == 3) ?true:false; + $loadperm = ($mode == 1 || $mode == 4) ?true:false; // Clean parameters $path = preg_replace('/([\\/]+)$/i', '', $path); @@ -141,6 +142,9 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl if ($loadsize || $sortcriteria == 'size') { $filesize = dol_filesize($path."/".$file); } + if ($loadperm || $sortcriteria == 'perm') { + $fileperm = dol_fileperm($path."/".$file); + } if (!$filter || preg_match('/'.$filter.'/i', $file)) { // We do not search key $filter into all $path, only into $file part $reg = array(); @@ -154,6 +158,7 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize, + "perm" => $fileperm, "type" => 'dir' ); } @@ -587,6 +592,18 @@ function dol_filemtime($pathoffile) return @filemtime($newpathoffile); // @Is to avoid errors if files does not exists } +/** + * Return permissions of a file + * + * @param string $pathoffile Path of file + * @return integer File permissions + */ +function dol_fileperm($pathoffile) +{ + $newpathoffile = dol_osencode($pathoffile); + return fileperms($newpathoffile); +} + /** * Make replacement of strings into a file. * @@ -1544,7 +1561,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess if (!empty($_FILES[$varfiles])) { // For view $_FILES[$varfiles]['error'] dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); - if (dol_mkdir($upload_dir) >= 0) { + $result = dol_mkdir($upload_dir); + // var_dump($result);exit; + if ($result >= 0) { $TFile = $_FILES[$varfiles]; if (!is_array($TFile['name'])) { foreach ($TFile as $key => &$val) { @@ -1647,6 +1666,8 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $res = 1; setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } + } else { + setEventMessages($langs->trans("ErrorFailedToCreateDir", $upload_dir), null, 'errors'); } } elseif ($link) { require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; @@ -1840,14 +1861,15 @@ function deleteFilesIntoDatabaseIndex($dir, $file, $mode = 'uploaded') /** - * Convert an image file into another format. - * This need Imagick php extension. + * Convert an image file or a PDF into another image format. + * This need Imagick php extension. You can use dol_imageResizeOrCrop() for a function that need GD. * * @param string $fileinput Input file name * @param string $ext Format of target file (It is also extension added to file if fileoutput is not provided). * @param string $fileoutput Output filename * @param string $page Page number if we convert a PDF into png * @return int <0 if KO, 0=Nothing done, >0 if OK + * @see dol_imageResizeOrCrop() */ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '') { @@ -2243,6 +2265,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $modulepart = 'user'; } + //print 'dol_check_secure_access_document modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity; dol_syslog('dol_check_secure_access_document modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); // We define $accessallowed and $sqlprotectagainstexternals @@ -2726,16 +2749,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $conf->bank->dir_output.'/'.$original_file; } elseif ($modulepart == 'export' && !empty($conf->export->dir_temp)) { // Wrapping for export module - // Aucun test necessaire car on force le rep de download sur - // le rep export qui est propre a l'utilisateur - $accessallowed = 1; + // Note that a test may not be required because we force the dir of download on the directory of the user that export + $accessallowed = $user->rights->export->lire; $original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; } elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { // Wrapping for import module - $accessallowed = 1; + $accessallowed = $user->rights->import->run; $original_file = $conf->import->dir_temp.'/'.$original_file; } elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { - // Wrapping pour l'editeur wysiwyg + // Wrapping for wysiwyg editor $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; } elseif ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ab9a476c923..6a98976e261 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9,14 +9,14 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2018 Juanjo Menent * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014 Cédric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Thibault Foucart * Copyright (C) 2020 Open-Dsi - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -355,6 +355,7 @@ function GETPOSTISSET($paramname) * 'int'=check it's numeric (integer or float) * 'intcomma'=check it's integer+comma ('1,2,3,4...') * 'alpha'=Same than alphanohtml since v13 + * 'alphawithlgt'=alpha with lgt * 'alphanohtml'=check there is no html content and no " and no ../ * 'aZ'=check it's a-z only * 'aZ09'=check it's simple alpha string (recommended for keys) @@ -633,8 +634,8 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null $out = checkVal($out, $check, $filter, $options); } - // Sanitizing for special parameters. There is no reason to allow the backtopage parameter to contains an external URL. - if ($paramname == 'backtopage' || $paramname == 'backtolist') { + // Sanitizing for special parameters. There is no reason to allow the backtopage, backtolist or backtourl parameter to contains an external URL. + if ($paramname == 'backtopage' || $paramname == 'backtolist' || $paramname == 'backtourl') { $out = str_replace('\\', '/', $out); $out = str_replace(array(':', ';', '@'), '', $out); @@ -745,30 +746,44 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = case 'alpha': // No html and no ../ and " case 'alphanohtml': // Recommended for most scalar parameters and search parameters if (!is_array($out)) { - // '"' is dangerous because param in url can close the href= or src= and add javascript functions. - // '../' is dangerous because it allows dir transversals - $out = str_replace(array('"', '"'), '', trim($out)); - $out = str_replace(array('../'), '', $out); + $out = trim($out); + do { + $oldstringtoclean = $out; + // Remove html tags + $out = dol_string_nohtmltag($out, 0); + // Remove also other dangerous string sequences + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + // Note &, '&', '&'... is a simple char like '&' alone but there is no reason to accept such way to encode input data. + $out = str_ireplace(array('&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '/', '../'), '', $out); + } while ($oldstringtoclean != $out); // keep lines feed - $out = dol_string_nohtmltag($out, 0); } break; case 'alphawithlgt': // No " and no ../ but we keep balanced < > tags with no special chars inside. Can be used for email string like "Name " if (!is_array($out)) { - // '"' is dangerous because param in url can close the href= or src= and add javascript functions. - // '../' is dangerous because it allows dir transversals - $out = str_replace(array('"', '"'), '', trim($out)); - $out = str_replace(array('../'), '', $out); + $out = trim($out); + do { + $oldstringtoclean = $out; + // Remove html tags + $out = dol_html_entity_decode($out, ENT_COMPAT | ENT_HTML5, 'UTF-8'); + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + // Note &, '&', '&'... is a simple char like '&' alone but there is no reason to accept such way to encode input data. + $out = str_ireplace(array('&', '&', '&', '"', '"', '"', '"', '"', '/', '/', '/', '../'), '', $out); + } while ($oldstringtoclean != $out); } break; case 'restricthtml': // Recommended for most html textarea - $out = dol_string_onlythesehtmltags($out, 0, 1, 1); - - // We should also exclude non expected attributes - if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) { - $out = dol_string_onlythesehtmlattributes($out); - } + do { + $oldstringtoclean = $out; + $out = dol_string_onlythesehtmltags($out, 0, 1, 1); + // We should also exclude non expected attributes + if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) { + $out = dol_string_onlythesehtmlattributes($out); + } + } while ($oldstringtoclean != $out); break; case 'custom': if (empty($filter)) { @@ -1329,7 +1344,7 @@ function dol_ucwords($string, $encoding = "UTF-8") * @param string $message Line to log. ''=Show nothing * @param int $level Log level * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr - * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 + * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_NOTICE=5, LOG_INFO=6, LOG_DEBUG=7 * @param int $ident 1=Increase ident of 1, -1=Decrease ident of 1 * @param string $suffixinfilename When output is a file, append this suffix into default log filename. * @param string $restricttologhandler Force output of log only to this log handler @@ -1383,7 +1398,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = // If html log tag enabled and url parameter log defined, we show output log on HTML comments if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) { print "\n\n\n"; } @@ -1534,7 +1549,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab if ($picto) { $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath, 0, 0, '', 'imgTabTitle').' '; } - $out .= ''.dol_trunc($title, $limittitle).''; + $out .= ''.dol_escape_htmltag(dol_trunc($title, $limittitle)).''; $out .= ''; } @@ -1579,7 +1594,9 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab } if ($i < $limittoshow || $isactive) { + // Add a new entry $out .= '
    '; + if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) { $out .= ''.$links[$i][1].''."\n"; @@ -1588,16 +1605,18 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab } } elseif (!empty($links[$i][1])) { //print "x $i $active ".$links[$i][2]." z"; - if ($isactive) { - $out .= ''; - $out .= $links[$i][1]; - $out .= ''."\n"; - } else { - $out .= ''; - $out .= $links[$i][1]; + $out .= '
    '; + if (!empty($links[$i][0])) { + $out .= ''; + } + $out .= $links[$i][1]; + if (!empty($links[$i][0])) { $out .= ''."\n"; } + $out .= empty($links[$i][4]) ? '' : $links[$i][4]; + $out .= '
    '; } + $out .= '
    '; } else { // The popup with the other tabs @@ -1736,53 +1755,26 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } $modulepart = 'unknown'; - if ($object->element == 'societe') { - $modulepart = 'societe'; - } - if ($object->element == 'contact') { - $modulepart = 'contact'; - } - if ($object->element == 'member') { + if ($object->element == 'societe' || $object->element == 'contact' || $object->element == 'product' || $object->element == 'ticket') { + $modulepart = $object->element; + } elseif ($object->element == 'member') { $modulepart = 'memberphoto'; - } - if ($object->element == 'user') { + } elseif ($object->element == 'user') { $modulepart = 'userphoto'; } - if ($object->element == 'product') { - $modulepart = 'product'; - } - if ($object->element == 'ticket') { - $modulepart = 'ticket'; - } if (class_exists("Imagick")) { - if ($object->element == 'propal') { - $modulepart = 'propal'; - } - if ($object->element == 'commande') { - $modulepart = 'commande'; - } - if ($object->element == 'facture') { - $modulepart = 'facture'; - } - if ($object->element == 'fichinter') { + if ($object->element == 'expensereport' || $object->element == 'propal' || $object->element == 'commande' || $object->element == 'facture' || $object->element == 'supplier_proposal') { + $modulepart = $object->element; + } elseif ($object->element == 'fichinter') { $modulepart = 'ficheinter'; - } - if ($object->element == 'contrat') { + } elseif ($object->element == 'contrat') { $modulepart = 'contract'; - } - if ($object->element == 'supplier_proposal') { - $modulepart = 'supplier_proposal'; - } - if ($object->element == 'order_supplier') { + } elseif ($object->element == 'order_supplier') { $modulepart = 'supplier_order'; - } - if ($object->element == 'invoice_supplier') { + } elseif ($object->element == 'invoice_supplier') { $modulepart = 'supplier_invoice'; } - if ($object->element == 'expensereport') { - $modulepart = 'expensereport'; - } } if ($object->element == 'product') { @@ -1888,7 +1880,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $phototoshow .= '
    '; } } - } elseif (!$phototoshow) { // example if modulepart = 'photo' + } elseif (!$phototoshow) { // example if modulepart = 'societe' or 'photo' $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); } @@ -3518,17 +3510,18 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'asset', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'cron', 'cubes', - 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', - 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', + 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'establishment', 'external-link-alt', 'external-link-square-alt', + 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'autofill', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', - 'info', 'intervention', 'inventory', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', + 'info', 'intervention', 'inventory', 'intracommreport', + 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_asset', 'object_barcode', 'object_bill', 'object_billr', 'object_billa', 'object_billd', 'object_bom', - 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', + 'object_category', 'object_conferenceorbooth', 'object_conversation', 'object_bookmark', 'object_bug', 'object_building', 'object_clock', 'object_collab', 'object_dolly', 'object_dollyrevert', 'object_folder', 'object_folder-open','object_generic', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', - 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_cron', 'object_donation', 'object_dynamicprice', - 'object_globe', 'object_holiday', 'object_hrm', 'object_invoice', 'object_intervention', 'object_inventory', 'object_label', + 'object_cash-register', 'object_company', 'object_contact', 'object_contract', 'object_cron', 'object_donation', 'object_dynamicprice', 'object_establishment', + 'object_globe', 'object_holiday', 'object_hrm', 'object_invoice', 'object_intervention', 'object_inventory', 'object_intracommreport', 'object_label', 'object_margin', 'object_members', 'object_money-bill-alt', 'object_multicurrency', 'object_order', 'object_payment', 'object_lot', 'object_mrp', 'object_other', 'object_payment', 'object_pdf', 'object_product', 'object_propal', @@ -3536,9 +3529,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'object_recruitmentjobposition', 'object_recruitmentcandidature', 'object_salary', 'object_shipment', 'object_share-alt', 'object_supplier_invoice', 'object_supplier_invoicea', 'object_supplier_invoiced', 'object_supplier_order', 'object_supplier_proposal', 'object_service', 'object_stock', 'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member', - 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', + 'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement', 'object_workstation', 'off', 'on', 'order', - 'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', + 'paiment', 'play', 'pdf', 'phone', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', @@ -3548,8 +3541,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', - 'user-cog', 'website', - 'eventorganization', 'object_eventorganization' + 'user-cog', 'website', 'workstation', + 'conferenceorbooth', 'eventorganization' ))) { $pictowithouttext = str_replace('object_', '', $pictowithouttext); @@ -3557,7 +3550,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $facolor = ''; $fasize = ''; $fa = 'fas'; - if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { + if (in_array($pictowithouttext, array('clock', 'establishment', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { @@ -3565,7 +3558,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } $arrayconvpictotofa = array( - 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'asset'=>'money-check-alt', + 'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'asset'=>'money-check-alt', 'autofill'=>'fill', 'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'billr'=>'file-invoice-dollar', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical', 'bom'=>'shapes', 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'collab'=>'people-arrows', 'conversation'=>'comments', 'country'=>'globe-americas', 'cron'=>'business-time', @@ -3573,10 +3566,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly', 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode', - 'email'=>'at', + 'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'generic'=>'file', 'holiday'=>'umbrella-beach', - 'info'=>'info-circle', 'inventory'=>'boxes', 'label'=>'layer-group', 'loan'=>'money-bill-alt', + 'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'label'=>'layer-group', 'loan'=>'money-bill-alt', 'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'trip'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'sign-out'=>'sign-out-alt', @@ -3594,10 +3587,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', - 'uparrow'=>'mail-forward', 'vcard'=>'address-card', + 'uparrow'=>'share', 'vcard'=>'address-card', 'jabber'=>'comment-o', - 'website'=>'globe-americas', - 'eventorganization'=>'id-badge' + 'website'=>'globe-americas', 'workstation'=>'pallet', + 'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram' ); if ($pictowithouttext == 'off') { $fakey = 'fa-square'; @@ -3630,7 +3623,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (in_array($pictowithouttext, array('dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) { $morecss = 'em092'; } - if (in_array($pictowithouttext, array('collab', 'holiday', 'project'))) { + if (in_array($pictowithouttext, array('conferenceorbooth', 'collab', 'eventorganization', 'holiday', 'project', 'workstation'))) { $morecss = 'em088'; } if (in_array($pictowithouttext, array('intervention', 'info', 'payment', 'loan', 'stock', 'technic'))) { @@ -3652,6 +3645,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'asset'=>'infobox-bank_account', 'bank_account'=>'bg-infobox-bank_account', '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', 'ecm'=>'infobox-action', 'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat', @@ -3661,6 +3655,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'user'=>'infobox-adherent', 'users'=>'infobox-adherent', 'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'holiday'=>'infobox-holiday', 'info'=>'opacityhigh', 'invoice'=>'infobox-commande', 'loan'=>'infobox-bank_account', + 'eventorganization'=>'infobox-project', 'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent', 'resource'=>'infobox-action', @@ -3685,7 +3680,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'other'=>'#ddd', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba', 'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uparrow'=>'#555', 'user-cog'=>'#999', 'country'=>'#aaa', 'globe-americas'=>'#aaa', - 'website'=>'#304' + 'website'=>'#304', 'workstation'=>'#a69944' ); if (isset($arrayconvpictotocolor[$pictowithouttext])) { $facolor = $arrayconvpictotocolor[$pictowithouttext]; @@ -6265,16 +6260,20 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = * @param int $cleanalsosomestyles Remove absolute/fixed positioning from inline styles * @param int $removeclassattribute 1=Remove the class attribute from tags * @param int $cleanalsojavascript Remove also occurence of 'javascript:'. + * @param int $allowiframe Allow iframe tags. * @return string String cleaned * * @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_neverthesehtmltags() */ -function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0) +function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0) { $allowed_tags = array( "html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link", "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6" ); + if ($allowiframe) { + $allowed_tags[] = "iframe"; + } $allowed_tags_string = join("><", $allowed_tags); $allowed_tags_string = '<'.$allowed_tags_string.'>'; @@ -6320,9 +6319,11 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, * * @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags() */ -function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = array("alt", "class", "contenteditable", "data-html", "href", "id", "name", "src", "style", "target", "title")) +function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = array("allow", "allowfullscreen", "alt", "class", "contenteditable", "data-html", "frameborder", "height", "href", "id", "name", "src", "style", "target", "title", "width")) { if (class_exists('DOMDocument') && !empty($stringtoclean)) { + $stringtoclean = ''.$stringtoclean.''; + $dom = new DOMDocument(); $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL); if (is_object($dom)) { @@ -6336,7 +6337,12 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes } } - return $dom->saveHTML(); + $return = $dom->saveHTML(); + + //$return = 'aaaa

    bb

    ssdd

    '."\n

    aaa

    aa

    bb

    "; + $return = preg_replace('/^/', '', $return); + $return = preg_replace('/<\/body><\/html>$/', '', $return); + return $return; } else { return $stringtoclean; } @@ -8797,8 +8803,8 @@ function showDirectDownloadLink($object) $url = $object->getLastMainDocLink($object->element); if ($url) { - $out .= img_picto($langs->trans("PublicDownloadLinkdesc"), 'globe').' '.$langs->trans("DirectDownloadLink").'
    '; - $out .= ''; + $out .= img_picto($langs->trans("PublicDownloadLinkdesc"), 'globe').' '.$langs->trans("DirectDownloadLink").'
    '; + $out .= ''; $out .= ajax_autoselect("directdownloadlink", 0); } return $out; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 9fd7f5e7e8a..e279ced2a3d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -507,6 +507,61 @@ function dol_print_object_info($object, $usetable = 0) } } + // User signature + if (!empty($object->user_signature)) { + if ($usetable) { + print '
    '; + } else { + print '
    '; + } + } + + // Date signature + if (!empty($object->date_signature)) { + if ($usetable) { + print ''; + } else { + print '
    '; + } + } + // User close if (!empty($object->user_cloture) || !empty($object->user_closing)) { if (isset($object->user_cloture) && !empty($object->user_cloture)) { @@ -1230,7 +1285,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { - $sql .= " AND entity IN (".$forceentity.")"; + $sql .= " AND entity IN (".$db->sanitize($forceentity).")"; } if ($where) { $sql .= $where; @@ -1290,7 +1345,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { - $sql .= " AND entity IN (".$forceentity.")"; + $sql .= " AND entity IN (".$db->sanitize($forceentity).")"; } if ($where) { $sql .= $where; @@ -1351,7 +1406,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($bentityon) { // only if entity enable $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { - $sql .= " AND entity IN (".$forceentity.")"; + $sql .= " AND entity IN (".$db->sanitize($forceentity).")"; } if ($where) { $maskrefclient_sql .= $where; //use the same optional where as general mask @@ -2254,7 +2309,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; $sql .= " SET ".$fieldfkparent." = 0"; - $sql .= " WHERE rowid IN (".join(',', $listofidtoclean).")"; // So we update only records detected wrong + $sql .= " WHERE rowid IN (".$db->sanitize(join(',', $listofidtoclean)).")"; // So we update only records detected wrong $resql = $db->query($sql); if ($resql) { $nb = $db->affected_rows($sql); @@ -2271,7 +2326,7 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) // Check and clean orphelins $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; $sql .= " SET ".$fieldfkparent." = 0"; - $sql .= " WHERE ".$fieldfkparent." NOT IN (".join(',', $listofid).")"; // So we update only records linked to a non existing parent + $sql .= " WHERE ".$fieldfkparent." NOT IN (".$db->sanitize(join(',', $listofid), 1).")"; // So we update only records linked to a non existing parent $resql = $db->query($sql); if ($resql) { $nb = $db->affected_rows($sql); diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index d624e2e0ace..435f02f1da0 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -190,6 +190,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $info = curl_getinfo($ch); // Reading of request must be done after sending request $http_code = $info['http_code']; + if ($followlocation && ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307)) { $newUrl = $info['redirect_url']; $maxRedirection--; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 7041eabfc5e..36e8cef6bfe 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -30,6 +30,23 @@ $maxheightmini = 72; // 16/9eme $quality = 80; +/** + * Return if a filename is file name of a supported image format + * + * @param int $acceptsvg 0=Default (depends on setup), 1=Always accept SVG as image files + * @return string Return list fo image format + */ +function getListOfPossibleImageExt($acceptsvg = 0) +{ + global $conf; + + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php + if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { + $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript + } + + return $regeximgext; +} /** * Return if a filename is file name of a supported image format @@ -40,12 +57,7 @@ $quality = 80; */ function image_format_supported($file, $acceptsvg = 0) { - global $conf; - - $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php - if ($acceptsvg || !empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) { - $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript - } + $regeximgext = getListOfPossibleImageExt(); // Case filename is not a format image $reg = array(); @@ -97,7 +109,7 @@ function image_format_supported($file, $acceptsvg = 0) /** - * Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) + * Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp) * * @param string $file Full path name of file * @param bool $url Image with url (true or false) @@ -127,17 +139,19 @@ function dol_getImageSize($file, $url = false) /** - * Resize or crop an image file (Supported extensions are gif, jpg, png and bmp) + * Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp) * - * @param string $file Path of file to resize/crop - * @param int $mode 0=Resize, 1=Crop - * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) - * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) - * @param int $src_x Position of croping image in source image (not use if mode=0) - * @param int $src_y Position of croping image in source image (not use if mode=0) - * @return string File name if OK, error message if KO + * @param string $file Path of source file to resize/crop + * @param int $mode 0=Resize, 1=Crop + * @param int $newWidth Largeur maximum que dois faire l'image destination (0=keep ratio) + * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) + * @param int $src_x Position of croping image in source image (not use if mode=0) + * @param int $src_y Position of croping image in source image (not use if mode=0) + * @param string $filetowrite Path of file to write (overwrite source file if not provided) + * @return string File name if OK, error message if KO + * @see dol_convert_file() */ -function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) +function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0, $filetowrite = '') { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -159,8 +173,8 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, return 'This filename '.$file.' does not seem to be an image filename.'; } elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; - } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) { - return 'At least newHeight or newWidth must be defined for resizing'; + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0 && (empty($filetowrite) || $filetowrite == $file)) { + return 'At least newHeight or newWidth must be defined for resizing, or a target filename must be set to convert'; } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) { return 'Both newHeight or newWidth must be defined for croping'; } @@ -172,6 +186,11 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $imgHeight = $infoImg[1]; // Hauteur de l'image if ($mode == 0) { // If resize, we check parameters + if (!empty($filetowrite) && $filetowrite != $file && $newWidth <= 0 && $newHeight <= 0) { + $newWidth = $imgWidth; + $newHeight = $imgHeight; + } + if ($newWidth <= 0) { $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } @@ -280,34 +299,36 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //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 - $imgThumbName = $file; + $imgTargetName = ($filetowrite ? $filetowrite : $file); // Check if permission are ok - //$fp = fopen($imgThumbName, "w"); + //$fp = fopen($imgTargetName, "w"); //fclose($fp); - // Create image on disk - switch ($infoImg[2]) { - case 1: // Gif - imagegif($imgThumb, $imgThumbName); + $newExt = strtolower(pathinfo($imgTargetName, PATHINFO_EXTENSION)); + + // Create image on disk (overwrite file if exists) + switch ($newExt) { + case 'gif': // Gif + imagegif($imgThumb, $imgTargetName); break; - case 2: // Jpg - imagejpeg($imgThumb, $imgThumbName, $newquality); + case 'jpg': // Jpg + imagejpeg($imgThumb, $imgTargetName, $newquality); break; - case 3: // Png - imagepng($imgThumb, $imgThumbName, $newquality); + case 'png': // Png + imagepng($imgThumb, $imgTargetName, $newquality); break; - case 4: // Bmp - imagewbmp($imgThumb, $imgThumbName); + case 'bmp': // Bmp + imagewbmp($imgThumb, $imgTargetName); break; - case 18: // Webp - imagewebp($imgThumb, $imgThumbName, $newquality); + case 'webp': // Webp + imagewebp($imgThumb, $imgTargetName, $newquality); break; } // Set permissions on file if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + @chmod($imgTargetName, octdec($conf->global->MAIN_UMASK)); } // Free memory. This does not delete image. @@ -316,7 +337,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, clearstatcache(); // File was replaced by a modified one, so we clear file caches. - return $imgThumbName; + return $imgTargetName; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 89e7f8c8e55..0883d8c82be 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -215,3 +215,1055 @@ function invoice_rec_prepare_head($object) return $head; } + +/** + * Return a HTML table that contains a pie chart of customer invoices + * + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a pie chart of customer invoices + */ +function getCustomerInvoicePieChart($socid = 0) +{ + global $conf, $db, $langs, $user; + + if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) { + return ''; + } + + $sql = "SELECT count(f.rowid), f.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture').")"; + if ($user->socid) { + $sql .= ' AND f.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " GROUP BY f.fk_statut"; + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + return ''; + } + + $num = $db->num_rows($resql); + $i = 0; + + $total = 0; + $vals = []; + + while ($i < $num) { + $row = $db->fetch_row($resql); + if ($row) { + $vals[$row[1]] = $row[0]; + $total += $row[0]; + } + + $i++; + } + + $db->free($resql); + + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $result = '
    '; + $result .= '
    '; - print ''; + print ''; print ''.$objp->ref.''.$objp->ref_client.''.(!empty($objp->ref_client) ? $objp->ref_client : $objp->ref_supplier).''; if ($possiblelink['label'] == 'LinkToContract') { $form = new Form($this->db); print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' '; } - print price($objp->total_ht).''.$objp->name.'
    '; - $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', 2, 0, 0, 0, 'minwidth200'); + $filter = ''; + if ($public) { + $filter = 'public=1'; + } + $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 0, 0, 0, 'minwidth200'); print '
    '; + } + print $langs->trans('SignedBy'); + if ($usetable) { + print ''; + } else { + print ': '; + } + if (is_object($object->user_signature)) { + if ($object->user_signature->id) { + print $object->user_signature->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } else { + $userstatic = new User($db); + $userstatic->fetch($object->user_signature); + if ($userstatic->id) { + print $userstatic->getNomUrl(-1, '', 0, 0, 0); + } else { + print $langs->trans('Unknown'); + } + } + if ($usetable) { + print '
    '; + } + print $langs->trans('DateSigning'); + if ($usetable) { + print ''; + } else { + print ': '; + } + print dol_print_date($object->date_signature, 'dayhour'); + if ($deltadateforuser) { + print ' '.$langs->trans('CurrentHour').'   /   '.dol_print_date($object->date_signature, 'dayhour', 'tzuserrel').'  '.$langs->trans('ClientHour'); + } + if ($usetable) { + print '
    '; + $result .= ''; + $result .= ''; + $result .= ''; + + $objectstatic = new Facture($db); + $array = [Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED]; + $dataseries = []; + + foreach ($array as $status) { + $objectstatic->statut = $status; + $objectstatic->paye = $status == Facture::STATUS_CLOSED ? -1 : 0; + + $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)]; + if ($status == Facture::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Facture::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Facture::STATUS_CLOSED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == Facture::STATUS_ABANDONED) { + $colorseries[$status] = $badgeStatus6; + } + + if (!$conf->use_javascript_ajax) { + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + } + } + + if ($conf->use_javascript_ajax) { + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(['pie']); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphcustomerinvoices'); + + $result .= ''; + $result .= ''; + $result .= ''; + } + + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= '
    '.$langs->trans("Statistics").' - '.$langs->trans("CustomerInvoice").'
    '.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
    '.$dolgraph->show($total ? 0 : 1).'
    '.$langs->trans("Total").''.$total.'
    '; + $result .= ''; + + return $result; +} + + +/** + * Return a HTML table that contains a pie chart of supplier invoices + * + * @param int $socid (Optional) Show only results from the supplier with this id + * @return string A HTML table that contains a pie chart of supplier invoices + */ +function getPurchaseInvoicePieChart($socid = 0) +{ + global $conf, $db, $langs, $user; + + if (!(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { + return ''; + } + + $sql = "SELECT count(f.rowid), f.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; + if ($user->socid) { + $sql .= ' AND f.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " GROUP BY f.fk_statut"; + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + return ''; + } + + $num = $db->num_rows($resql); + $i = 0; + + $total = 0; + $vals = []; + + while ($i < $num) { + $row = $db->fetch_row($resql); + if ($row) { + $vals[$row[1]] = $row[0]; + $total += $row[0]; + } + + $i++; + } + + $db->free($resql); + + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $result = '
    '; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + $objectstatic = new FactureFournisseur($db); + $array = [FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED]; + $dataseries = []; + + foreach ($array as $status) { + $objectstatic->statut = $status; + $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0; + + $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)]; + if ($status == FactureFournisseur::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == FactureFournisseur::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == FactureFournisseur::STATUS_CLOSED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == FactureFournisseur::STATUS_ABANDONED) { + $colorseries[$status] = $badgeStatus6; + } + + if (!$conf->use_javascript_ajax) { + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + } + } + + if ($conf->use_javascript_ajax) { + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(['pie']); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphpurchaseinvoices'); + + $result .= ''; + $result .= ''; + $result .= ''; + } + + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= '
    '.$langs->trans("Statistics").' - '.$langs->trans("SupplierInvoice").'
    '.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
    '.$dolgraph->show($total ? 0 : 1).'
    '.$langs->trans("Total").''.$total.'
    '; + $result .= '
    '; + + return $result; +} + +/** + * Return a HTML table that contains a list with customer invoice drafts + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a list with customer invoice drafts + */ +function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) +{ + global $conf, $db, $langs, $user, $hookmanager; + + $result = ''; + $tmpinvoice = new Facture($db); + + $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client"; + $sql .= ", f.type, f.fk_statut as status, f.paye"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + + if ($socid) { + $sql .= " AND f.fk_soc = $socid"; + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; + $sql .= " cc.rowid, cc.code"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql.= ", sc.fk_soc, sc.fk_user"; + } + + // Add Group from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListGroupByCustomerDraft', $parameters); + $sql .= $hookmanager->resPrint; + + $resql = $db->query($sql); + + if ($resql) { + $num = $db->num_rows($resql); + + $result .= '
    '; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + if ($num) { + $companystatic = new Societe($db); + + $i = 0; + $othernb = 0; + $tot_ttc = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($i >= $maxCount) { + $othernb += 1; + $i++; + $tot_ttc += $obj->total_ttc; + continue; + } + + $tmpinvoice->id = $obj->rowid; + $tmpinvoice->ref = $obj->ref; + $tmpinvoice->date = $db->jdate($obj->date); + $tmpinvoice->type = $obj->type; + $tmpinvoice->total_ht = $obj->total_ht; + $tmpinvoice->total_tva = $obj->total_tva; + $tmpinvoice->total_ttc = $obj->total_ttc; + $tmpinvoice->ref_client = $obj->ref_client; + $tmpinvoice->statut = $obj->status; + $tmpinvoice->paye = $obj->paye; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; + $companystatic->client = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + $tot_ttc += $obj->total_ttc; + $i++; + } + + if ($othernb) { + $result .= ''; + $result .= ''; + $result .= "\n"; + } + + $result .= ''; + $result .= ''; + $result .= ''; + } else { + $result .= ''; + } + $result .= "
    '; + $result .= $langs->trans("CustomersDraftInvoices").' '; + $result .= ''; + $result .= ''.$num.''; + $result .= ''; + $result .= '
    '; + $result .= $tmpinvoice->getNomUrl(1, ''); + $result .= ''; + $result .= $companystatic->getNomUrl(1, 'customer'); + $result .= ''.price($obj->total_ttc).'
    '; + $result .= ''.$langs->trans("More").'... ('.$othernb.')'; + $result .= '
    '.$langs->trans("Total").''.price($tot_ttc).'
    '.$langs->trans("NoInvoice").'
    "; + $db->free($resql); + } else { + dol_print_error($db); + } + + return $result; +} + +/** + * Return a HTML table that contains a list with customer invoice drafts + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a list with customer invoice drafts + */ +function getDraftSupplierTable($maxCount = 500, $socid = 0) +{ + global $conf, $db, $langs, $user, $hookmanager; + + $result = ''; + $facturesupplierstatic = new FactureFournisseur($db); + + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierDraft', $parameters); + $sql .= $hookmanager->resPrint; + $resql = $db->query($sql); + + if ($resql) { + $num = $db->num_rows($resql); + + $result .= '
    '; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + if ($num) { + $companystatic = new Societe($db); + + $i = 0; + $othernb = 0; + $tot_ttc = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($i >= $maxCount) { + $othernb += 1; + $i++; + $tot_ttc += $obj->total_ttc; + continue; + } + + $facturesupplierstatic->ref = $obj->ref; + $facturesupplierstatic->id = $obj->rowid; + $facturesupplierstatic->total_ht = $obj->total_ht; + $facturesupplierstatic->total_tva = $obj->total_tva; + $facturesupplierstatic->total_ttc = $obj->total_ttc; + $facturesupplierstatic->ref_supplier = $obj->ref_supplier; + $facturesupplierstatic->type = $obj->type; + $facturesupplierstatic->statut = $obj->status; + $facturesupplierstatic->paye = $obj->paye; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; + $companystatic->fournisseur = 1; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->code_compta = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + $tot_ttc += $obj->total_ttc; + $i++; + } + + if ($othernb) { + $result .= ''; + $result .= ''; + $result .= "\n"; + } + + $result .= ''; + $result .= ''; + $result .= ''; + } else { + $result .= ''; + } + $result .= "
    '; + $result .= $langs->trans("SuppliersDraftInvoices").' '; + $result .= ''; + $result .= ''.$num.''; + $result .= ''; + $result .= '
    '; + $result .= $facturesupplierstatic->getNomUrl(1, ''); + $result .= ''; + $result .= $companystatic->getNomUrl(1, 'supplier'); + $result .= ''.price($obj->total_ttc).'
    '; + $result .= ''.$langs->trans("More").'... ('.$othernb.')'; + $result .= '
    '.$langs->trans("Total").''.price($tot_ttc).'
    '.$langs->trans("NoInvoice").'
    "; + $db->free($resql); + } else { + dol_print_error($db); + } + + return $result; +} + + +/** + * Return a HTML table that contains a list with latest edited customer invoices + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a list with latest edited customer invoices + */ +function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) +{ + global $conf, $db, $langs, $user; + + $sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; + $sql .= " f.datec"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture').")"; + if ($socid) { + $sql .= " AND f.fk_soc = ".((int) $socid); + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " ORDER BY f.tms DESC"; + $sql .= $db->plimit($maxCount, 0); + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + + $num = $db->num_rows($resql); + + $result = '
    '; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + if ($num < 1) { + $result .= '
    '.$langs->trans("LastCustomersBills", $maxCount).'
    '; + $result .= '
    '; + return $result; + } + + $formfile = new FormFile($db); + $objectstatic = new Facture($db); + $companystatic = new Societe($db); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->paye = $obj->paye; + $objectstatic->statut = $obj->status; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; + + $result .= '
    '; + $result .= ''; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= ''; + $result .= '
    '.$objectstatic->getNomUrl(1).' '.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).'
    '; + $result .= '
    '.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$objectstatic->getLibStatut(5).'
    '; + $result .= '
    '; + return $result; +} + +/** + * Return a HTML table that contains a list with latest edited supplier invoices + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the supplier with this id + * @return string A HTML table that contains a list with latest edited supplier invoices + */ +function getPurchaseInvoiceLatestEditTable($maxCount = 5, $socid = 0) +{ + global $conf, $db, $langs, $user; + + $sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; + $sql .= " f.datec"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " ORDER BY f.tms DESC"; + $sql .= $db->plimit($maxCount, 0); + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + return ''; + } + + $num = $db->num_rows($resql); + + $result = '
    '; + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + + if ($num < 1) { + $result .= '
    '.$langs->trans("BoxTitleLastSupplierBills", $maxCount).'
    '; + $result .= '
    '; + return $result; + } + + $objectstatic = new FactureFournisseur($db); + $companystatic = new Societe($db); + $formfile = new FormFile($db); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->paye = $obj->paye; + $objectstatic->statut = $obj->status; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; + + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= ''; + $result .= '
    '.$objectstatic->getNomUrl(1).' '.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).'
    '; + $result .= ''; + + $result .= ''.$companystatic->getNomUrl(1, 'supplier').''; + $result .= ''.dol_print_date($db->jdate($obj->datec), 'day').''; + $result .= ''.$objectstatic->getLibStatut(5).''; + + $result .= ''; + + $i++; + } + + $result .= ''; + $result .= ''; + return $result; +} + +/** + * Return a HTML table that contains of unpaid customers invoices + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the supplier with this id + * @return string A HTML table that conatins a list with open (unpaid) supplier invoices + */ +function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) +{ + global $conf, $db, $langs, $user, $hookmanager; + + $result = ''; + + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { + $tmpinvoice = new Facture($db); + + $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms"; + $sql .= ", f.date_lim_reglement as datelimite"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = ".Facture::STATUS_VALIDATED; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND f.fk_soc = ".$socid; + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerUnpaid', $parameters); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " ORDER BY f.datef ASC, f.ref ASC"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $othernb = 0; + + $formfile = new FormFile($db); + + print '
    '; + print ''; + + print ''; + print ''; + + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + if ($num) { + $societestatic = new Societe($db); + $total_ttc = $totalam = $total = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($i >= $maxCount) { + $othernb += 1; + $i++; + $total += $obj->total_ht; + $total_ttc += $obj->total_ttc; + continue; + } + + $tmpinvoice->ref = $obj->ref; + $tmpinvoice->id = $obj->rowid; + $tmpinvoice->total_ht = $obj->total_ht; + $tmpinvoice->total_tva = $obj->total_tva; + $tmpinvoice->total_ttc = $obj->total_ttc; + $tmpinvoice->type = $obj->type; + $tmpinvoice->statut = $obj->status; + $tmpinvoice->paye = $obj->paye; + $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite); + + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->country_id = $obj->country_id; + $societestatic->country_code = $obj->country_code; + $societestatic->client = 1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + + $total_ttc += $obj->total_ttc; + $total += $obj->total_ht; + $totalam += $obj->am; + + $i++; + } + + if ($othernb) { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } + print ''; + print ''; + print "\n"; + } + + print ''; + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + } else { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } + print ''; + } + print '
    '; + print $langs->trans("BillsCustomersUnpaid", $num).' '; + print ''; + print ''.$num.''; + print ''; + print ''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Received").' 
    '; + + print ''; + print ''; + print ''; + print '
    '; + print $tmpinvoice->getNomUrl(1, ''); + print ''; + if ($tmpinvoice->hasDelay()) { + print img_warning($langs->trans("Late")); + } + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; + print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir); + print '
    '; + + print '
    '; + print $societestatic->getNomUrl(1, 'customer'); + print ''.dol_print_date($db->jdate($obj->datelimite), 'day').''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$tmpinvoice->getLibStatut(3, $obj->am).'
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToTake").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total_ttc).''.price($totalam).' 
    '.$langs->trans("NoInvoice").'

    '; + $db->free($resql); + } else { + dol_print_error($db); + } + } + + return $result; +} + + +/** + * Return a HTML table that contains of unpaid purchase invoices + * + * @param int $maxCount (Optional) The maximum count of elements inside the table + * @param int $socid (Optional) Show only results from the supplier with this id + * @return string A HTML table that conatins a list with open (unpaid) supplier invoices + */ +function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0) +{ + global $conf, $db, $langs, $user, $hookmanager; + + $result = ''; + + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { + $facstatic = new FactureFournisseur($db); + + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; + $sql .= ", ff.date_lim_reglement"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE s.rowid = ff.fk_soc"; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.paye = 0"; + $sql .= " AND ff.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + if ($socid) { + $sql .= " AND ff.fk_soc = ".$socid; + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhereSupplierUnpaid', $parameters); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement,"; + $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY ff.date_lim_reglement ASC"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $othernb = 0; + + $formfile = new FormFile($db); + + print '
    '; + print ''; + + print ''; + print ''; + + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print "\n"; + $societestatic = new Societe($db); + if ($num) { + $i = 0; + $total = $total_ttc = $totalam = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($i >= $maxCount) { + $othernb += 1; + $i++; + $total += $obj->total_ht; + $total_ttc += $obj->total_ttc; + continue; + } + + $facstatic->ref = $obj->ref; + $facstatic->id = $obj->rowid; + $facstatic->type = $obj->type; + $facstatic->total_ht = $obj->total_ht; + $facstatic->total_tva = $obj->total_tva; + $facstatic->total_ttc = $obj->total_ttc; + $facstatic->statut = $obj->status; + $facstatic->paye = $obj->paye; + + $societestatic->id = $obj->socid; + $societestatic->name = $obj->name; + $societestatic->email = $obj->email; + $societestatic->client = 0; + $societestatic->fournisseur = 1; + $societestatic->code_client = $obj->code_client; + $societestatic->code_fournisseur = $obj->code_fournisseur; + $societestatic->code_compta = $obj->code_compta; + $societestatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + print ''; + print ''; + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + $total += $obj->total_ht; + $total_ttc += $obj->total_ttc; + $totalam += $obj->am; + $i++; + } + + if ($othernb) { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } + print ''; + print ''; + print "\n"; + } + + print ''; + print ''; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + } else { + $colspan = 6; + if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { + $colspan++; + } + print ''; + } + print '
    '; + print $langs->trans("BillsSuppliersUnpaid", $num).' '; + print ''; + print ''.$num.''; + print ''; + print ''.$langs->trans("DateDue").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").''.$langs->trans("Paid").' 
    '; + print $facstatic->getNomUrl(1, ''); + print ''.$societestatic->getNomUrl(1, 'supplier').''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->am).''.$facstatic->getLibStatut(3, $obj->am).'
    '; + print ''.$langs->trans("More").'... ('.$othernb.')'; + print '
    '.$langs->trans("Total").'   ('.$langs->trans("RemainderToPay").': '.price($total_ttc - $totalam).')  '.price($total).''.price($total_ttc).''.price($totalam).' 
    '.$langs->trans("NoInvoice").'

    '; + } else { + dol_print_error($db); + } + } + + return $result; +} diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index ca5fc61b60a..c5e2aeb0a16 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -96,7 +96,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte } if (in_array('bank', $filter)) { $sqlwhere .= " AND p.fk_bank = b.rowid"; - $sqlwhere .= " AND b.fk_account = ".$paymentbankid; + $sqlwhere .= " AND b.fk_account = ".((int) $paymentbankid); } $sqlorder = " ORDER BY p.datep ASC"; } @@ -130,7 +130,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte } else { $sqlwhere .= " AND"; } - $sqlwhere .= ' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')'; + $sqlwhere .= ' f.fk_soc NOT IN ('.$db->sanitize(join(',', $thirdpartiesid)).')'; } if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) { if (empty($sqlwhere)) { @@ -138,7 +138,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte } else { $sqlwhere .= " AND"; } - $sqlwhere .= ' f.fk_soc IN ('.join(',', $thirdpartiesid).')'; + $sqlwhere .= ' f.fk_soc IN ('.$db->sanitize(join(',', $thirdpartiesid)).')'; } if ($sqlwhere) { $sql .= $sqlwhere; diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index c86d0ecce13..4692c0b938b 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -90,20 +90,27 @@ function loan_prepare_head($object) /** * Calculate remaining loan mensuality and interests * - * @param int $mens Value of this mensuality (interests include, set 0 if we don't paid interests for this mensuality) - * @param float $capital Remaining capital for this mensuality - * @param float $rate Loan rate - * @param int $echance Actual loan term - * @param int $nbterm Total number of term for this loan - * @return array Array with remaining capital, interest, and mensuality for each remaining terms + * @param float $mens Value of this mensuality (interests include, set 0 if we don't paid interests for this mensuality) + * @param float $capital Remaining capital for this mensuality + * @param float $rate Loan rate + * @param int $numactualloadterm Actual loan term + * @param int $nbterm Total number of term for this loan + * @return array Array with remaining capital, interest, and mensuality for each remaining terms */ -function loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm) +function loanCalcMonthlyPayment($mens, $capital, $rate, $numactualloadterm, $nbterm) { global $conf, $db; require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; $object = new LoanSchedule($db); $output = array(); + // Sanitize data in case of + $mens = price2num($mens); + $capital = price2num($capital); + $rate = price2num($rate); + $numactualloadterm = ((int) $numactualloadterm); + $nbterm = ((int) $nbterm); + // If mensuality is 0 we don't pay interests and remaining capital not modified if ($mens == 0) { $int = 0; @@ -113,18 +120,18 @@ function loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm) $int = round($int, 2, PHP_ROUND_HALF_UP); $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); } - $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); + $output[$numactualloadterm] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency), 'mens'=>$mens); - $echance++; + $numactualloadterm++; $capital = $cap_rest; - while ($echance <= $nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); + while ($numactualloadterm <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $numactualloadterm + 1), 2, PHP_ROUND_HALF_UP); $int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance] = array( + $output[$numactualloadterm] = array( 'cap_rest' => $cap_rest, 'cap_rest_str' => price($cap_rest, 0, '', 1, -1, -1, $conf->currency), 'interet' => $int, @@ -133,7 +140,7 @@ function loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm) ); $capital = $cap_rest; - $echance++; + $numactualloadterm++; } return $output; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 85a16ac47cf..27a4ea7a9ab 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -119,7 +119,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if (count($object->fields)) { foreach ($object->fields as $key => $val) { $i++; - $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; + $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."',"; + $texttoinsert .= " 'label'=>'".$val['label']."',"; $texttoinsert .= " 'enabled'=>'".($val['enabled'] !== '' ? $val['enabled'] : 1)."',"; $texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).","; $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).","; @@ -145,6 +146,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if ($val['css']) { $texttoinsert .= " 'css'=>'".$val['css']."',"; } + if ($val['cssview']) { + $texttoinsert .= " 'cssview'=>'".$val['cssview']."',"; + } + if ($val['csslist']) { + $texttoinsert .= " 'csslist'=>'".$val['csslist']."',"; + } if ($val['help']) { $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; } diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 835986f5f83..166814525cf 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -171,9 +171,10 @@ function showOnlinePaymentUrl($type, $ref) $servicename = $langs->transnoentitiesnoconv('Online'); - $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url = getOnlinePaymentUrl(0, $type, $ref); - $out .= ''; + $out .= ''; $out .= ajax_autoselect("onlinepaymenturl", 0); return $out; } @@ -210,9 +211,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out = $urltouse.'/public/payment/newpayment.php?amount='.($mode ? '' : '').$amount.($mode ? '' : '').'&tag='.($mode ? '' : '').$freetag.($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { - $out .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $out .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2)); } } //if ($mode) $out.='&noidempotency=1'; @@ -227,7 +228,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -250,7 +251,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -273,7 +274,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -296,7 +297,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { @@ -320,7 +321,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag $out .= ($mode ? '' : ''); if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $out .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + $out .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } else { $out .= '&securekey='.($mode ? '' : ''); if ($mode == 1) { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 3a73f47a6a0..9be293a81ab 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -151,8 +151,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; - $sql .= " WHERE cv.taux = ".$txtva; - $sql .= " AND cv.fk_pays = ".$countryid; + $sql .= " WHERE cv.taux = ".((float) $txtva); + $sql .= " AND cv.fk_pays = ".((int) $countryid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index d5d52761140..e8ce515317f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -328,6 +328,11 @@ function product_lot_admin_prepare_head() $h = 0; $head = array(); + $head[$h][0] = DOL_URL_ROOT."/product/admin/product_lot.php"; + $head[$h][1] = $langs->trans('Parameters'); + $head[$h][2] = 'settings'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f2dbacc3ab4..3c5e9c71dad 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -206,11 +206,29 @@ function project_prepare_head(Project $project) if ($conf->eventorganization->enabled) { $langs->load('eventorganization'); - //TODO : Count - $nbConfOrBooth = 1; $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $project->id; $head[$h][1] = $langs->trans("ConferenceOrBoothTab"); - if ($nbContact > 0) { + + // Enable caching of conf or booth count + $nbConfOrBooth = 0; + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_conferenceorbooth_'.$project->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbConfOrBooth = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; + $conforbooth=new ConferenceOrBooth($db); + $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$project->id)); + //, + if (!is_array($result) && $result<0) { + setEventMessages($conforbooth->error, $conforbooth->errors, 'errors'); + } else { + $nbConfOrBooth = count($result); + } + dol_setcache($cachekey, $nbConfOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbConfOrBooth > 0) { $head[$h][1] .= '' . $nbConfOrBooth . ''; } $head[$h][2] = 'eventorganisation'; @@ -1494,27 +1512,29 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; } - // Time spent by everybody - print ''; - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user - if ($lines[$i]->duration) { - print ''; - print convertSecondToTime($lines[$i]->duration, 'allhourmin'); - print ''; - } else { - print '--:--'; - } - print "\n"; + if (!empty($arrayfields['timeconsumed']['checked'])) { + // Time spent by everybody + print ''; + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + if ($lines[$i]->duration) { + print ''; + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); + print ''; + } else { + print '--:--'; + } + print "\n"; - // Time spent by user - print ''; - $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) { - print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - } else { - print '--:--'; + // Time spent by user + print ''; + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } + print "\n"; } - print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -1885,27 +1905,29 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print ''; } - // Time spent by everybody - print ''; - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user - if ($lines[$i]->duration) { - print ''; - print convertSecondToTime($lines[$i]->duration, 'allhourmin'); - print ''; - } else { - print '--:--'; - } - print "\n"; + if (!empty($arrayfields['timeconsumed']['checked'])) { + // Time spent by everybody + print ''; + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + if ($lines[$i]->duration) { + print ''; + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); + print ''; + } else { + print '--:--'; + } + print "\n"; - // Time spent by user - print ''; - $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) { - print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); - } else { - print '--:--'; + // Time spent by user + print ''; + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); + if ($tmptimespent['total_duration']) { + print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); + } else { + print '--:--'; + } + print "\n"; } - print "\n"; $disabledproject = 1; $disabledtask = 1; @@ -2378,9 +2400,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity IN (".getEntity('project').")"; - $sql .= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; @@ -2436,7 +2458,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; - $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; + $sql2 .= " WHERE p.rowid IN (".$db->sanitize(join(',', $arrayidofprojects)).")"; $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur,"; $sql2 .= " s.logo, s.email, s.entity, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee"; $sql2 .= " ORDER BY p.title, p.ref"; @@ -2451,7 +2473,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $i = 0; print ''; - print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($title.''.$num.'', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { if (!in_array('prospectionstatus', $hiddenfields)) { @@ -2554,7 +2576,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $ponderated_opp_amount += price2num($opp_weighted_amount); } if ($objp->opp_amount) { - print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).''; + print ''.price($objp->opp_amount, 0, '', 1, -1, 0, $conf->currency).''; } print ''; } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5bcad053795..1b6aa0aa544 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -534,7 +534,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f /** * Check access by user to object. - * This function is also called by restrictedArea + * This function is also called by restrictedArea that check before if module is enabled and permissions of user compared to $action. * * @param User $user User to check * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...) @@ -563,6 +563,8 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand foreach ($featuresarray as $feature) { $sql = ''; + //var_dump($feature); + // For backward compatibility if ($feature == 'member') { $feature = 'adherent'; @@ -574,7 +576,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $feature = 'projet_task'; } - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salary', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object @@ -595,27 +597,27 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { // Special for multicompany if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if ($conf->entity == 1 && $user->admin && !$user->entity) { - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IS NOT NULL"; } else { $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND ((ug.fk_user = dbt.rowid"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; $sql .= " OR dbt.entity = 0)"; // Show always superadmin } } else { - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } else { $reg = array(); if ($parenttableforentity && preg_match('/(.*)@(.*)/', $parenttableforentity, $reg)) { $sql .= ", ".MAIN_DB_PREFIX.$reg[2]." as dbtp"; - $sql .= " WHERE dbt.".$reg[1]." = dbtp.rowid AND dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$reg[1]." = dbtp.rowid AND dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbtp.entity IN (".getEntity($sharedelement, 1).")"; } else { - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } @@ -630,7 +632,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql = "SELECT COUNT(sc.fk_soc) as nb"; $sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe as s)"; - $sql .= " WHERE sc.fk_soc IN (".$objectid.")"; + $sql .= " WHERE sc.fk_soc IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND sc.fk_user = ".$user->id; $sql .= " AND sc.fk_soc = s.rowid"; $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; @@ -638,7 +640,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand // If multicompany and internal users with all permissions, check user is in correct entity $sql = "SELECT COUNT(s.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.rowid IN (".$objectid.")"; + $sql .= " WHERE s.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checkother)) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...). @@ -646,21 +648,21 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid > 0) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.fk_soc = ".$user->socid; } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { // If internal user: Check permission for internal users that are restricted on their objects $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } elseif (!empty($conf->multicompany->enabled)) { // If multicompany and internal users with all permissions, check user is in correct entity $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } if ($feature == 'agenda') { @@ -686,7 +688,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checktask)) { @@ -704,7 +706,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } else { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (!in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield @@ -715,7 +717,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand } $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.rowid IN (".$objectid.")"; + $sql .= " WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid; } elseif (!empty($conf->societe->enabled) && !$user->rights->societe->client->voir) { // If internal user: Check permission for internal users that are restricted on their objects @@ -726,7 +728,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql = "SELECT COUNT(sc.fk_soc) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield; $sql .= " AND sc.fk_user = ".$user->id; @@ -735,7 +737,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield." AND sc.fk_user = ".$user->id; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql .= " AND (sc.fk_user = ".$user->id." OR sc.fk_user IS NULL)"; } @@ -743,10 +745,11 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand // If multicompany and internal users with all permissions, check user is in correct entity $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } + //print $sql; if ($sql) { $resql = $db->query($sql); @@ -756,6 +759,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand return false; } } else { + dol_syslog("Bad forged sql in checkUserAccessToObject", LOG_WARNING); return false; } } diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 8b49b01ae35..82f446f04c7 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -33,9 +33,15 @@ function showOnlineSignatureUrl($type, $ref) $servicename = 'Online'; - $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; $url = getOnlineSignatureUrl(0, $type, $ref); - $out .= ''; + $out .= ''; $out .= ajax_autoselect("onlinesignatureurl", 0); return $out; } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index c66d16b6736..743a847b2f2 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -143,9 +143,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype, p.tosell as pstatus, p.tobuy as pstatusbuy,"; + $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,"; $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; @@ -167,7 +171,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + $sql .= " AND f.datef > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -183,10 +188,14 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype, p.tosell as pstatus, p.tobuy as pstatusbuy,"; $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql .= " pa.datep as datep"; + $sql .= " pa.datep as datep, pa.ref as payment_ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; @@ -212,7 +221,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND pa.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; @@ -263,8 +273,20 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['dtype'][] = $assoc['dtype']; $list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']); $list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']); + $list[$assoc['company_id']]['company_name'][] = $assoc['company_name']; $list[$assoc['company_id']]['company_id'][] = $assoc['company_id']; + $list[$assoc['company_id']]['company_alias'][] = $assoc['company_alias']; + $list[$assoc['company_id']]['company_email'][] = $assoc['company_email']; + $list[$assoc['company_id']]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$assoc['company_id']]['company_client'][] = $assoc['company_client']; + $list[$assoc['company_id']]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$assoc['company_id']]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$assoc['company_id']]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$assoc['company_id']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$assoc['company_id']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$assoc['company_id']]['company_status'][] = $assoc['company_status']; + $list[$assoc['company_id']]['drate'][] = $assoc['rate']; $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); $list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']); @@ -306,9 +328,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype, p.tosell as pstatus, p.tobuy as pstatusbuy,"; + $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql .= " ".MAIN_DB_PREFIX."societe as s,"; $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; @@ -330,7 +356,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + $sql .= " AND f.datef > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -346,10 +373,14 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; - $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype, p.tosell as pstatus, p.tobuy as pstatusbuy,"; $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql .= " pa.datep as datep"; + $sql .= " pa.datep as datep, pa.ref as payment_ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; @@ -375,7 +406,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND pa.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; @@ -426,8 +458,20 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['dtype'][] = $assoc['dtype']; $list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']); $list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']); + $list[$assoc['company_id']]['company_name'][] = $assoc['company_name']; $list[$assoc['company_id']]['company_id'][] = $assoc['company_id']; + $list[$assoc['company_id']]['company_alias'][] = $assoc['company_alias']; + $list[$assoc['company_id']]['company_email'][] = $assoc['company_email']; + $list[$assoc['company_id']]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$assoc['company_id']]['company_client'][] = $assoc['company_client']; + $list[$assoc['company_id']]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$assoc['company_id']]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$assoc['company_id']]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$assoc['company_id']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$assoc['company_id']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$assoc['company_id']]['company_status'][] = $assoc['company_status']; + $list[$assoc['company_id']]['drate'][] = $assoc['rate']; $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); $list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']); @@ -448,6 +492,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['ptype'][] = $assoc['ptype']; $list[$assoc['company_id']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['company_id']]['payment_ref'][] = $assoc['payment_ref']; $list[$assoc['company_id']]['payment_amount'][] = $assoc['payment_amount']; $company_id = $assoc['company_id']; @@ -484,7 +529,8 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND p.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; @@ -534,8 +580,20 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['company_id']]['dtype'][] = 'ExpenseReportPayment'; $list[$assoc['company_id']]['datef'][] = $assoc['datef']; + $list[$assoc['company_id']]['company_name'][] = ''; $list[$assoc['company_id']]['company_id'][] = ''; + $list[$assoc['company_id']]['company_alias'][] = ''; + $list[$assoc['company_id']]['company_email'][] = ''; + $list[$assoc['company_id']]['company_tva_intra'][] = ''; + $list[$assoc['company_id']]['company_client'][] = ''; + $list[$assoc['company_id']]['company_fournisseur'][] = ''; + $list[$assoc['company_id']]['company_customer_code'][] = ''; + $list[$assoc['company_id']]['company_supplier_code'][] = ''; + $list[$assoc['company_id']]['company_customer_accounting_code'][] = ''; + $list[$assoc['company_id']]['company_supplier_accounting_code'][] = ''; + $list[$assoc['company_id']]['company_status'][] = ''; + $list[$assoc['company_id']]['user_id'][] = $assoc['fk_user_author']; $list[$assoc['company_id']]['drate'][] = $assoc['rate']; $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); @@ -557,6 +615,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $list[$assoc['company_id']]['ptype'][] = 'ExpenseReportPayment'; $list[$assoc['company_id']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['company_id']]['payment_ref'][] = $assoc['payment_ref']; $list[$assoc['company_id']]['payment_amount'][] = $assoc['payment_amount']; $company_id = $assoc['company_id']; @@ -630,7 +689,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax2 = 'total_localtax2'; - // CAS DES BIENS/PRODUITS + // CASE OF PRODUCTS/GOODS // Define sql request $sql = ''; @@ -640,9 +699,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$invoicedettable." as d ON d.".$fk_facture."=f.rowid"; @@ -662,7 +725,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + $sql .= " AND f.datef > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -678,10 +742,14 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql .= " pa.datep as datep"; + $sql .= " pa.datep as datep, pa.ref as payment_ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$paymentfacturetable." as pf ON pf.".$fk_facture2." = f.rowid";; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$paymenttable." as pa ON pa.rowid = pf.".$fk_payment; @@ -703,7 +771,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND pa.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; @@ -755,8 +824,20 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; $list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']); $list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']); + $list[$assoc['rate']]['company_name'][] = $assoc['company_name']; $list[$assoc['rate']]['company_id'][] = $assoc['company_id']; + $list[$assoc['rate']]['company_alias'][] = $assoc['company_alias']; + $list[$assoc['rate']]['company_email'][] = $assoc['company_email']; + $list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$assoc['rate']]['company_client'][] = $assoc['company_client']; + $list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$assoc['rate']]['company_status'][] = $assoc['company_status']; + $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); @@ -776,6 +857,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; @@ -787,7 +869,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire } - // CAS DES SERVICES + // CASE OF SERVICES // Define sql request $sql = ''; @@ -797,9 +879,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql .= " 0 as payment_id, 0 as payment_amount"; + $sql .= " 0 as payment_id, '' as payment_ref, 0 as payment_amount"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$invoicedettable." as d ON d.".$fk_facture." = f.rowid"; @@ -819,7 +905,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; + $sql .= " AND f.datef > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -835,10 +922,14 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .= " d.date_start as date_start, d.date_end as date_end,"; - $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef,"; + $sql .= " s.nom as company_name, s.name_alias as company_alias, s.rowid as company_id, s.client as company_client, s.fournisseur as company_fournisseur, s.email as company_email,"; + $sql .= " s.code_client as company_customer_code, s.code_fournisseur as company_supplier_code,"; + $sql .= " s.code_compta as company_customer_accounting_code, s.code_compta_fournisseur as company_supplier_accounting_code,"; + $sql .= " s.status as company_status, s.tva_intra as company_tva_intra,"; $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; - $sql .= " pa.datep as datep"; + $sql .= " pa.datep as datep, pa.ref as payment_ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$paymentfacturetable." as pf ON pf.".$fk_facture2." = f.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX.$paymenttable." as pa ON pa.rowid = pf.".$fk_payment; @@ -860,7 +951,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND pa.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; @@ -912,11 +1004,23 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; $list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']); $list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']); - $list[$assoc['rate']]['company_name'][] = $assoc['company_name']; - $list[$assoc['rate']]['company_id'][] = $assoc['company_id']; + $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); + $list[$assoc['rate']]['company_name'][] = $assoc['company_name']; + $list[$assoc['rate']]['company_id'][] = $assoc['company_id']; + $list[$assoc['rate']]['company_alias'][] = $assoc['company_alias']; + $list[$assoc['rate']]['company_email'][] = $assoc['company_email']; + $list[$assoc['rate']]['company_tva_intra'][] = $assoc['company_tva_intra']; + $list[$assoc['rate']]['company_client'][] = $assoc['company_client']; + $list[$assoc['rate']]['company_fournisseur'][] = $assoc['company_fournisseur']; + $list[$assoc['rate']]['company_customer_code'][] = $assoc['company_customer_code']; + $list[$assoc['rate']]['company_supplier_code'][] = $assoc['company_supplier_code']; + $list[$assoc['rate']]['company_customer_accounting_code'][] = $assoc['company_customer_accounting_code']; + $list[$assoc['rate']]['company_supplier_accounting_code'][] = $assoc['company_supplier_accounting_code']; + $list[$assoc['rate']]['company_status'][] = $assoc['company_status']; + $list[$assoc['rate']]['facid'][] = $assoc['facid']; $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; $list[$assoc['rate']]['type'][] = $assoc['type']; @@ -933,6 +1037,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; @@ -969,7 +1074,8 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; } if ($q) { - $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; + $sql .= " AND p.datep > '".$db->idate(dol_get_first_day($y, (($q - 1) * 3) + 1, false))."'"; + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, ($q * 3), false))."'"; } if ($date_start && $date_end) { $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; @@ -1042,6 +1148,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['ptype'][] = 'ExpenseReportPayment'; $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['rate']]['payment_ref'][] = $assoc['payment_ref']; $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; $rate = $assoc['rate']; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index e12a0d9c8a7..3188a9b39e2 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -343,14 +343,14 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Title if ($foruserprofile) { - print ''.$langs->trans("Parameter").''.$langs->trans("DefaultValue").''; + print ''.$langs->trans("Parameter").''.$langs->trans("DefaultValue").''; print ' '; print ''; print ''; print ''.$langs->trans("DefaultSkin").''; print ''.$conf->global->MAIN_THEME.''; - print ' '.$langs->trans("UsePersonalValue").''; + print ' '.$langs->trans("UsePersonalValue").''; print ' '; print ''; } else { @@ -359,7 +359,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $dirthemestring .= '"'.$dirtheme.'" '; } - print ''; + print ''; print $form->textwithpicto($langs->trans("DefaultSkin"), $langs->trans("ThemeDir").' : '.$dirthemestring); print ''; print ''; @@ -448,7 +448,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Nothing } else { // Show logo - print ''.$langs->trans("EnableShowLogo").''; + print ''.$langs->trans("EnableShowLogo").''; if ($edit) { print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 2eb44c517f7..4fa0f053236 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -846,9 +846,9 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so if (is_array($otherfilters) && !empty($otherfilters['category'])) { $sql .= ', '.MAIN_DB_PREFIX.'categorie_website_page as cwp'; } - $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " WHERE wp.fk_website = ".((int) $website->id); if ($status >= 0) { - $sql .= " AND wp.status = ".$status; + $sql .= " AND wp.status = ".((int) $status); } if ($langcode) { $sql .= " AND wp.lang ='".$db->escape($langcode)."'"; @@ -859,7 +859,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so foreach ($tmparrayoftype as $tmptype) { $typestring .= ($typestring ? ", " : "")."'".$db->escape(trim($tmptype))."'"; } - $sql .= " AND wp.type_container IN (".$typestring.")"; + $sql .= " AND wp.type_container IN (".$db->sanitize($typestring, 1).")"; } $sql .= " AND ("; $searchalgo = ''; @@ -1023,7 +1023,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { if ($grabimages) { - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); @@ -1094,7 +1094,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify if (empty($alreadygrabbed[$urltograbbis])) { if ($grabimages) { - $tmpgeturl = getURLContent($urltograbbis); + $tmpgeturl = getURLContent($urltograbbis, 'GET', '', 1, array(), array('http', 'https'), 0); if ($tmpgeturl['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 2efeec151a3..6510d5fff8d 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -66,7 +66,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) { global $conf; - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) + // Now create the .tpl file dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias); $aliascontent = 'lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { // Save also alias into all language subdirectories if it is a main language - if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) { + if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { $dirname = dirname($filealias); $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) { + // Avoid to erase main alias file if $sublang is empty string + if (empty(trim($sublang))) continue; $filealiassub = $dirname.'/'.$sublang.'/'.$filename; $aliascontent = 'lang) { @@ -214,7 +226,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) } } // Add "has translation pages" - $sql = 'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.'website_page where fk_page IN ('.$objectpage->id.($translationof ? ", ".$translationof : "").")"; + $sql = 'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.'website_page where fk_page IN ('.$db->sanitize($objectpage->id.($translationof ? ', '.$translationof : '')).")"; $resql = $db->query($sql); if ($resql) { $num_rows = $db->num_rows($resql); @@ -240,7 +252,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) // Add js $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index eeaba6f84b8..1b01a3eb782 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -106,7 +106,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes if ($cryptType == 'auto') { if (dol_verifyHash($passtyped, $passcrypted, '0')) { $passok = true; - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - ".$cryptType." of pass is ok"); + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - hash ".$cryptType." of pass is ok"); } } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index efa0c44a4ff..104655ee1da 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -19,7 +19,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|asset', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->asset->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', -1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->asset->read', '', 2, 54, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 19, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/index.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->user->user->lire || $user->rights->holiday->read || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Dashboard insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'MyDashboard', 0, '', '', '', 2, 0, __ENTITY__); @@ -233,7 +233,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2301__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/card.php?mainmenu=billing&leftmenu=tax_vat&action=create', 'New', 2, 'companies', '$user->rights->tax->charges->creer', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/list.php?mainmenu=billing&leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/index.php?mainmenu=billing&leftmenu=tax_vat', 'ReportByMonth', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?mainmenu=billing&leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?mainmenu=billing&leftmenu=tax_vat', 'ReportByThirdparties', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2305__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?mainmenu=billing&leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 4, __ENTITY__); -- Salary insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 6__+MAX_llx_menu__, '/salaries/list.php?mainmenu=billing&leftmenu=tax_salary', 'Salaries', 0, 'salaries', '$user->rights->salaries->read', '', 0, 10, __ENTITY__); @@ -413,9 +413,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5200__+MAX_llx_menu__, 'members', 'cat', 13__+MAX_llx_menu__, '/categories/index.php?mainmenu=members&leftmenu=cat&type=3', 'MembersCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->adherent->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 5201__+MAX_llx_menu__, 'members', '', 5200__+MAX_llx_menu__, '/categories/card.php?mainmenu=members&action=create&type=3', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- HRM - Employee -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->hrm->employee->read', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->hrm->employee->write', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4600__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee', 'Employees', 0, 'hrm', '$user->rights->user->user->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4601__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/card.php?mainmenu=hrm&action=create&employee=1', 'NewEmployee', 1, 'hrm', '$user->rights->user->user->creer', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->user->user->lire', '', 0, 2, __ENTITY__); -- HRM - Holiday insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&action=create', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 89e63c16db4..575f26542e2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -322,7 +322,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'bank', 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => img_picto('', 'bank', 'class="fa-fw paddingright"'), + 'prefix' => img_picto('', 'bank_account', 'class="fa-fw paddingright"'), 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") ? 0 : 1), 'loadLangs' => array("compta", "banks"), 'submenus' => array(), @@ -347,7 +347,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'id' => $id, 'idsel' => 'accountancy', 'classname' => $classname = ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 'class="tmenusel"' : 'class="tmenu"', - 'prefix' => img_picto('', 'account', 'class="fa-fw paddingright"'), + 'prefix' => img_picto('', 'accountancy', 'class="fa-fw paddingright"'), 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), 'loadLangs' => array("compta", "accountancy", "assets", "intracommreport"), 'submenus' => array(), @@ -356,7 +356,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // HRM $tmpentry = array( 'enabled'=>(!empty($conf->hrm->enabled) || (!empty($conf->holiday->enabled)) || !empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled) || !empty($conf->recruitment->enabled)), - 'perms'=>(!empty($user->rights->hrm->employee->read) || !empty($user->rights->holiday->write) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire) || !empty($user->rights->recruitment->recruitmentjobposition->read)), + 'perms'=>(!empty($user->rights->user->user->lire) || !empty($user->rights->holiday->read) || !empty($user->rights->deplacement->lire) || !empty($user->rights->expensereport->lire) || !empty($user->rights->recruitment->recruitmentjobposition->read)), 'module'=>'hrm|holiday|deplacement|expensereport|recruitment' ); @@ -1104,7 +1104,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/payments.php?mode=tvaonly&leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); - $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); + $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByThirdparties"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } @@ -1115,7 +1115,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("List"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/index.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); - $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); + $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByThirdparties"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } } @@ -1126,7 +1126,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("List"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/index.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); - $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); + $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByThirdparties"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } } @@ -1735,9 +1735,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if (!empty($conf->hrm->enabled)) { $langs->load("hrm"); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); - $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write); - $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->user->user->lire, '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); + $newmenu->add("/user/card.php?mainmenu=hrm&leftmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1, $user->rights->user->user->creer); + $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1, $user->rights->user->user->lire); } // Leave/Holiday/Vacation module diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3d3009fd667..b92937cdada 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1696,7 +1696,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if perm already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; - $sql .= " WHERE id = ".$r_id." AND entity = ".$entity; + $sql .= " WHERE id = ".((int) $r_id)." AND entity = ".((int) $entity); $resqlselect = $this->db->query($sql); if ($resqlselect) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index ebae616c45b..15c5d54b94e 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -278,6 +278,9 @@ class pdf_einstein extends ModelePDFCommandes global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Set nblines with the new command lines content after hook + $nblines = count($object->lines); + // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance @@ -1326,17 +1329,18 @@ class pdf_einstein extends ModelePDFCommandes $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 17837529354..f97d7abee28 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -323,6 +323,9 @@ class pdf_eratosthene extends ModelePDFCommandes global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Set nblines with the new command lines content after hook + $nblines = count($object->lines); + // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance @@ -1503,17 +1506,18 @@ class pdf_eratosthene extends ModelePDFCommandes $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/expensereport/doc/index.html b/htdocs/core/modules/expensereport/doc/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/expensereport/doc/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index bbe2245a97d..b25ac15345b 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -163,7 +163,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport } $newref = str_replace(' ', '_', $user_author_infos).$expld_car.$prefix.$newref.$expld_car.dol_print_date($object->date_debut, '%y%m%d'); - $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.$ref_number_int.' WHERE rowid = '.$object->id; + $sqlbis = 'UPDATE '.MAIN_DB_PREFIX.'expensereport SET ref_number_int = '.((int) $ref_number_int).' WHERE rowid = '.((int) $object->id); $resqlbis = $db->query($sqlbis); if (!$resqlbis) { dol_print_error($resqlbis); diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index ed85493f04f..370fc49df7e 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -193,7 +193,7 @@ class ExportExcel2007 extends ModeleExports $outputlangs->load("exports"); - require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/autoloader.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php'; require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 847901c0147..1203943ab91 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1025,7 +1025,11 @@ class pdf_crabe extends ModelePDFFactures if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + if ($mysoc->forme_juridique_code == 92) { + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0); + } else { + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + } $posy = $pdf->GetY() + 4; } @@ -1703,17 +1707,18 @@ class pdf_crabe extends ModelePDFFactures $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index d7d69fc4a18..22402e91a92 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1962,17 +1962,18 @@ class pdf_sponge extends ModelePDFFactures $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index cd36b4d322a..c7a69a82caa 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -55,6 +55,7 @@ class mod_facture_mars extends ModeleNumRefFactures */ public function __construct() { + global $conf; if (!empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX)) { $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX; } diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 2f142a1adc7..f3e38cf7db7 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -65,6 +65,7 @@ class mod_facture_terre extends ModeleNumRefFactures */ public function __construct() { + global $conf; if (!empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) { $this->prefixinvoice = $conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX; } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 63a28fbe3d2..1768029b97e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -790,7 +790,7 @@ class ImportCsv extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlSelect .= ' WHERE '.$keyfield.' = '.((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -824,7 +824,7 @@ class ImportCsv extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlend = ' WHERE '.$keyfield.' = '.((int) $lastinsertid); $sql = $sqlstart.$sqlend; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 257e8f5253e..d90a52755e3 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -112,9 +112,9 @@ class ImportXlsx extends ModeleImports $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version = '1.0'; // Driver version // If driver use an external library, put its name here - require_once DOL_DOCUMENT_ROOT . '/includes/phpoffice/autoloader.php'; - require_once DOL_DOCUMENT_ROOT . '/includes/Psr/autoloader.php'; - require_once PHPEXCELNEW_PATH . 'Spreadsheet.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php'; + require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; + require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; $this->workbook = new Spreadsheet(); //if ($this->id == 'excel2007new') @@ -830,7 +830,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= ' WHERE ' . $keyfield . ' = ' . $lastinsertid; + $sqlSelect .= ' WHERE ' . $keyfield . ' = ' .((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -864,7 +864,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlend = ' WHERE ' . $keyfield . ' = ' . $lastinsertid; + $sqlend = ' WHERE ' . $keyfield . ' = '.((int) $lastinsertid); $sql = $sqlstart . $sqlend; diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 9f434be9498..cbf668b6c67 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -79,7 +79,7 @@ class mailing_advthirdparties extends MailingTargets $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - $sql .= " AND s.rowid IN (".implode(',', $socid).")"; + $sql .= " AND s.rowid IN (".$this->db->sanitize(implode(',', $socid)).")"; $sql .= " ORDER BY email"; // Stock recipients emails into targets table @@ -125,10 +125,10 @@ class mailing_advthirdparties extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as socp"; $sql .= " WHERE socp.entity IN (".getEntity('socpeople').")"; if (count($contactid) > 0) { - $sql .= " AND socp.rowid IN (".implode(',', $contactid).")"; + $sql .= " AND socp.rowid IN (".$this->db->sanitize(implode(',', $contactid)).")"; } if (count($socid) > 0) { - $sql .= " AND socp.fk_soc IN (".implode(',', $socid).")"; + $sql .= " AND socp.fk_soc IN (".$this->db->sanitize(implode(',', $socid)).")"; } $sql .= " ORDER BY email"; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index cb7eb93b074..7c0aa2b19b5 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -132,14 +132,14 @@ class MailingTargets // This can't be abstract as it is used for some method // phpcs:enable // Mise a jour nombre de destinataire dans table des mailings $sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$mailing_id; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); $nb = $obj->nb; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; - $sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id; + $sql .= " SET nbemail = ".$nb." WHERE rowid = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); $this->error = $this->db->error(); @@ -250,7 +250,7 @@ class MailingTargets // This can't be abstract as it is used for some method { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$mailing_id; + $sql .= " WHERE fk_mailing = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 8b8a57f6628..b3b88224df6 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -83,13 +83,13 @@ class mailing_thirdparties extends MailingTargets if (GETPOSTISSET("filter_client") && GETPOST("filter_client") <> '-1') { $addFilter .= " AND s.client=".((int) GETPOST("filter_client", 'int')); $addDescription = $langs->trans('ProspectCustomer')."="; - if ($_POST["filter_client"] == 0) { + if (GETPOST("filter_client") == 0) { $addDescription .= $langs->trans('NorProspectNorCustomer'); - } elseif ($_POST["filter_client"] == 1) { + } elseif (GETPOST("filter_client") == 1) { $addDescription .= $langs->trans('Customer'); - } elseif ($_POST["filter_client"] == 2) { + } elseif (GETPOST("filter_client") == 2) { $addDescription .= $langs->trans('Prospect'); - } elseif ($_POST["filter_client"] == 3) { + } elseif (GETPOST("filter_client") == 3) { $addDescription .= $langs->trans('ProspectCustomer'); } else { $addDescription .= "Unknown status ".GETPOST("filter_client"); diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 2718a33247b..7b5d4f38737 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -197,7 +197,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $sql .= " WHERE s.entity IN (".getEntity('societe').")"; $sql .= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; $sql .= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; - $sql .= " AND p.ref IN ('".join("','", $this->arrayofproducts)."')"; + $sql .= " AND p.ref IN (".$this->db->sanitize("'".join("','", $this->arrayofproducts)."'", 1).")"; $sql .= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; $a = parent::getNbOfRecipients($sql); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 15710d71dfa..b4645b51a87 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2019 Alexandre Spangaro - * Copyright (C) 2014 Ari Elbaz (elarifr) - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2016-2017 Laurent Destailleur - * Copyright (C) 2017 Open-DSI +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2014 Ari Elbaz (elarifr) + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2016-2017 Laurent Destailleur + * Copyright (C) 2017-2021 Open-DSI * * 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 @@ -285,15 +285,15 @@ class modAccounting extends DolibarrModules //'b.doc_type'=>'Doctype', 'b.doc_ref'=>'Piece', 'b.code_journal'=>'Codejournal', - //'b.journal_label'=>'JournalLabel', + 'b.journal_label'=>'JournalLabel', 'b.numero_compte'=>'AccountAccounting', - //'b.label_compte'=>'LabelAccount', + 'b.label_compte'=>'LabelAccount', 'b.subledger_account'=>'SubledgerAccount', 'b.subledger_label'=>'SubledgerAccountLabel', 'b.label_operation'=>'LabelOperation', 'b.debit'=>"Debit", 'b.credit'=>"Credit", - 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit + 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replaced into accountancyexport.class.php by a detection using ->debit and ->credit ); $this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); @@ -303,9 +303,9 @@ class modAccounting extends DolibarrModules //'b.doc_type'=>'import', 'b.doc_ref'=>'My document ABC', 'b.code_journal'=>"VTE", - //'b.journal_label'=>"Sale journal", + 'b.journal_label'=>"Sale journal", 'b.numero_compte'=>"707", - //'b.label_compte'=>'Product account 707', + 'b.label_compte'=>'Product account 707', 'b.subledger_account'=>'', 'b.subledger_label'=>'', 'b.label_operation'=>"Sale of ABC", @@ -314,6 +314,76 @@ class modAccounting extends DolibarrModules 'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit ); + // General ledger - Fichier FEC + $r++; + $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_label[$r] = 'ImportAccountingEntriesFECFormat'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('b'=>MAIN_DB_PREFIX.'accounting_bookkeeping'); // List of tables to insert into (insert done in same order) + $this->import_fields_array[$r] = array( + 'b.code_journal'=>'FECFormatJournalCode*', + 'b.journal_label'=>'FECFormatJournalLabel', + 'b.piece_num'=>'FECFormatEntryNum*', + 'b.doc_date'=>'FECFormatEntryDate*', + 'b.numero_compte'=>'FECFormatGeneralAccountNumber*', + 'b.label_compte'=>'FECFormatGeneralAccountLabel*', + 'b.subledger_account'=>'FECFormatSubledgerAccountNumber', + 'b.subledger_label'=>'FECFormatSubledgerAccountLabel', + 'b.doc_ref'=>'FECFormatPieceRef*', + 'b.date_creation'=>'FECFormatPieceDate', + 'b.label_operation'=>'FECFormatLabelOperation', + 'b.debit'=>'FECFormatDebit*', + 'b.credit'=>'FECFormatCredit*', + 'b.lettering_code'=>'FECFormatReconcilableCode', + 'b.date_lettering'=>'FECFormatReconcilableDate', + 'b.date_validated'=>'FECFormatValidateDate', + 'b.multicurrency_amount'=>'FECFormatMulticurrencyAmount', + 'b.multicurrency_code'=>'FECFormatMulticurrencyCode' + ); + $this->import_fieldshidden_array[$r] = array( + 'b.doc_type'=>'const-import_from_external', + 'b.fk_doc'=>'const-0', + 'b.fk_docdet'=>'const-0', + 'b.fk_user_author'=>'user->id', + 'b.montant'=>'rule-computeMontant', + 'b.sens'=>'rule-computeSens' + ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_convertvalue_array[$r]=array( + 'b.montant' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeAmount', 'element' => 'Accountancy'), + 'b.sens' => array('rule' => 'compute', 'classfile' => '/accountancy/class/accountancyimport.class.php', 'class' => 'AccountancyImport', 'method' => 'computeDirection', 'element' => 'Accountancy'), + ); + $this->import_regex_array[$r] = array( + //'b.doc_date'=>'^\d{4}\d{2}\d{2}$', + 'b.doc_ref'=>'^.{1,300}$', + 'b.numero_compte'=>'^.{1,32}$', + 'b.label_compte'=>'^.{1,255}$', + 'b.subledger_compte'=>'^.{1,32}$', + 'b.subledger_label'=>'^.{1,255}$', + 'b.label_operation'=>'^.{1,255}$', + //'b.sens'=>'^[D|C]$', + ); + $this->import_examplevalues_array[$r] = array( + 'b.code_journal'=>"VT", + 'b.journal_label'=>"Sale journal", + 'b.piece_num'=>'123 (!!! use next value not already used)', + 'b.doc_date'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.numero_compte'=>"707", + 'b.label_compte'=>'Sale', + 'b.subledger_account'=>'', + 'b.subledger_label'=>'', + 'b.doc_ref'=>'My document ABC', + 'b.date_creation'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.label_operation'=>"Sale of ABC", + 'b.debit'=>"0", + 'b.credit'=>"100", + 'b.lettering_code'=>'ABC', + 'b.date_lettering'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.date_validated'=>dol_print_date(dol_now(), "%Y%m%d"), + 'b.multicurrency_amount'=>"90 (Necessary if devise is different than EUR)", + 'b.multicurrency_code'=>"US (Necessary if devise is different than EUR)", + ); + // Chart of accounts $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 0c6ebeb6f37..bf7fc2777ae 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -195,7 +195,7 @@ class modApi extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -203,7 +203,7 @@ class modApi extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' @@ -245,8 +245,8 @@ class modApi extends DolibarrModules { // Remove old constants with entity fields different of 0 $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_API', 1), - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('API_PRODUCTION_MODE', 1) + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('MAIN_MODULE_API'))."'", + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = '".$this->db->escape($this->db->encrypt('API_PRODUCTION_MODE'))."'" ); return $this->_remove($sql, $options); diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 16f95a5e926..9a90fa945bb 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -113,7 +113,7 @@ class modBlockedLog extends DolibarrModules // ----------------- $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 67a480dcc08..6b69c6b7af0 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -205,7 +205,7 @@ class modBom extends DolibarrModules // Permissions provided by this module $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read bom of Bom'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 8e9ca1131b9..ba6c7ddce6c 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -98,6 +98,8 @@ class modCashDesk extends DolibarrModules 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'cashdesk', + 'leftmenu'=>'', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 29f4dc60515..6a44075822c 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -368,7 +368,7 @@ class modCommande extends DolibarrModules //Import CPV Lines $r++; $this->import_code[$r] = 'commande_lines_'.$r; - $this->import_label[$r] = 'OrderLine'; + $this->import_label[$r] = 'SaleOrderLines'; $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields']; diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php index 1b591f02da1..ae2bdcfffc8 100644 --- a/htdocs/core/modules/modDebugBar.class.php +++ b/htdocs/core/modules/modDebugBar.class.php @@ -79,7 +79,7 @@ class modDebugBar extends DolibarrModules // Permissions $this->rights = array(); - $this->rights[1][0] = 430; // id de la permission + $this->rights[1][0] = 431; // id de la permission $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) $this->rights[1][3] = 1; // La permission est-elle une permission par defaut diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 0f92e8a7e6c..f0f06395565 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -143,7 +143,7 @@ class modDeplacement extends DolibarrModules $childids[] = $user->id; if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) { - $this->export_sql_end[$r] .= ' AND d.fk_user IN ('.join(',', $childids).')'; + $this->export_sql_end[$r] .= ' AND d.fk_user IN ('.$this->db->sanitize(join(',', $childids)).')'; } } } diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 386da21d798..3a81102f4bd 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -219,29 +219,13 @@ class modEventOrganization extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - // 0 => array( - // 'label' => 'MyJob label', - // 'jobtype' => 'method', - // 'class' => '/eventorganization/class/conferenceorbooth.class.php', - // 'objectname' => 'ConferenceOrBooth', - // 'method' => 'doScheduledJob', - // 'parameters' => '', - // 'comment' => 'Comment', - // 'frequency' => 2, - // 'unitfrequency' => 3600, - // 'status' => 0, - // 'test' => '$conf->eventorganization->enabled', - // 'priority' => 50, - // ), ); - // Example: $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->eventorganization->enabled', 'priority'=>50) - // ); + // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; + // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) @@ -256,21 +240,6 @@ class modEventOrganization extends DolibarrModules $this->rights[$r][1] = 'Delete objects of EventOrganization'; // Permission label $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) $r++; - /*$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete objects of EventOrganization - Conference Or Booth'; // Permission label - $this->rights[$r][4] = 'conferenceorbooth'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1) - $r++;*/ /* END MODULEBUILDER PERMISSIONS */ // Main menu entries to add @@ -278,69 +247,13 @@ class modEventOrganization extends DolibarrModules $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - /*$this->menu[$r++] = array( - 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry - 'titre'=>'ModuleEventOrganizationName', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'', - 'url'=>'/eventorganization/eventorganizationindex.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000 + $r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - );*/ /* END MODULEBUILDER TOPMENU */ - /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Top menu entry - 'titre'=>'ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'conferenceorbooth', - 'url'=>'/eventorganization/eventorganizationindex.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List_ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'eventorganization_conferenceorbooth_list', - 'url'=>'/eventorganization/conferenceorbooth_list.php', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - $this->menu[$r++]=array( - 'fk_menu'=>'fk_mainmenu=eventorganization,fk_leftmenu=conferenceorbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New_ConferenceOrBooth', - 'mainmenu'=>'eventorganization', - 'leftmenu'=>'eventorganization_conferenceorbooth_new', - 'url'=>'/eventorganization/conferenceorbooth_card.php?action=create', - 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->eventorganization->conferenceorbooth->write', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); - */ + /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH*/ $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'EventOrganizationMenuLeft', + 'prefix' => img_picto('', 'eventorganization', 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'project', 'leftmenu'=>'eventorganization', 'url'=>'', @@ -355,7 +268,7 @@ class modEventOrganization extends DolibarrModules 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry 'titre'=>'List', - 'url'=>'/projet/list.php?search_usage_event_organization=1&mainmenu=project', + 'url'=>'/projet/list.php?search_usage_event_organization=1&mainmenu=project&contextpage=organizedevents', 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. @@ -378,7 +291,8 @@ class modEventOrganization extends DolibarrModules $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'EventOrganizationMenuLeft', + 'titre'=>'ConferenceOrBooth', + 'prefix' => img_picto('', 'conferenceorbooth', 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'project', 'leftmenu'=>'eventorganizationconforbooth', 'url'=>'', @@ -417,52 +331,11 @@ class modEventOrganization extends DolibarrModules // Exports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */ - /* - $langs->load("eventorganization@eventorganization"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='conferenceorbooth@eventorganization'; - // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array - $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; - //unset($this->export_fields_array[$r]['t.fieldtoremove']); - //$keyforclass = 'ConferenceOrBoothLine'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorboothline@eventorganization'; $keyforalias='tl'; - //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$keyforselect='conferenceorboothline'; $keyforaliasextra='extraline'; $keyforelement='conferenceorboothline@eventorganization'; - //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r] = array('conferenceorboothline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - //$this->export_special_array[$r] = array('t.field'=>'...'); - //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); - //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t'; - //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'conferenceorbooth_line as tl ON tl.fk_conferenceorbooth = t.rowid'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')'; - $r++; */ /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */ // Imports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */ - /* - $langs->load("eventorganization@eventorganization"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='ConferenceOrBoothLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='conferenceorbooth@eventorganization'; - $keyforclass = 'ConferenceOrBooth'; $keyforclassfile='/eventorganization/class/conferenceorbooth.class.php'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='conferenceorbooth'; $keyforaliasextra='extra'; $keyforelement='conferenceorbooth@eventorganization'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'conferenceorbooth as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('conferenceorbooth').')'; - $r++; */ /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */ } @@ -483,15 +356,6 @@ class modEventOrganization extends DolibarrModules return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') } - // Create extrafields during init - //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - //$extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('eventorganization_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result2=$extrafields->addExtraField('eventorganization_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result3=$extrafields->addExtraField('eventorganization_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result4=$extrafields->addExtraField('eventorganization_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - //$result5=$extrafields->addExtraField('eventorganization_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'eventorganization@eventorganization', '$conf->eventorganization->enabled'); - // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index ba8568ba13e..238eef2d6fe 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -313,7 +313,7 @@ class modExpedition extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$this->db->sanitize($idcontacts).')'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index 6a47b7b74fd..278a70e6339 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -78,14 +78,14 @@ class modExport extends DolibarrModules $r++; $this->rights[$r][0] = 1201; - $this->rights[$r][1] = 'Lire les exports'; + $this->rights[$r][1] = 'Read exports'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 1202; - $this->rights[$r][1] = 'Creer/modifier un export'; + $this->rights[$r][1] = 'Creeate/modify export'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index 6ca023a65a8..d7710687ca6 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -100,6 +100,7 @@ class modExternalRss extends DolibarrModules $result = $this->db->query($sql); if ($result) { while ($obj = $this->db->fetch_object($result)) { + $reg = array(); if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) { // Definie la boite si on a trouvee une ancienne configuration //$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)"; diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index a996a55ddaa..71c3387ff5e 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -67,7 +67,7 @@ class modExternalSite extends DolibarrModules $this->dirs = array(); // Config pages. Put here list of php page names stored in admmin directory used to setup module - $this->config_page_url = array("externalsite.php@externalsite"); + $this->config_page_url = array("index.php@externalsite"); // Dependencies $this->depends = array(); // List of modules id that must be enabled if this module is enabled diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index efa3aeea536..d1ad993af68 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2021 Alexandre Spangaro * * 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 @@ -206,6 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -218,15 +220,15 @@ class modFacture extends DolibarrModules 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', - 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT", - 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', + 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", + 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', 'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode', 'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', - 'p.accountancy_code_sell'=>'ProductAccountancySellCode' + $alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode' ); if (!empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; @@ -243,13 +245,13 @@ class modFacture extends DolibarrModules 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", - 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', + 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>"NumericCompute", 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', - 'p.accountancy_code_sell'=>'Text' + $alias_product_perentity . '.accountancy_code_sell'=>'Text' ); if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { $this->export_TypeFields_array[$r]['f.module_source'] = 'Text'; @@ -261,7 +263,7 @@ class modFacture extends DolibarrModules 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line", 'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line', - 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_sell'=>'product', + 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product', 'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user' ); $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay'); @@ -293,6 +295,9 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facturedet as fd'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; @@ -312,8 +317,8 @@ class modFacture extends DolibarrModules 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', - 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT", - 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', + 'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT", + 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment', 'none.rest'=>'Rest', 'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef', @@ -337,7 +342,7 @@ class modFacture extends DolibarrModules 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", - 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', + 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text', 'none.rest'=>'NumericCompute', 'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text', 'pj.ref'=>'Text', 'pj.title'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.title'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 46d6dd7bead..71f101014ad 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -666,7 +666,7 @@ class modFournisseur extends DolibarrModules $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Supplier Invoice"; // Translation key + $this->import_label[$r] = "SupplierInvoices"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = ['f' => MAIN_DB_PREFIX.'facture_fourn', 'extra' => MAIN_DB_PREFIX.'facture_fourn_extrafields']; @@ -759,7 +759,7 @@ class modFournisseur extends DolibarrModules //Import Supplier Invoice Lines $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "Supplier Invoice Lines"; // Translation key + $this->import_label[$r] = "SupplierInvoiceLines"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = ['fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields']; @@ -839,7 +839,7 @@ class modFournisseur extends DolibarrModules //Import Purchase Orders $r++; $this->import_code[$r] = 'commande_fournisseur_'.$r; - $this->import_label[$r] = 'Purchase Orders'; + $this->import_label[$r] = 'SuppliersOrders'; $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; $this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX.'commande_fournisseur', 'extra' => MAIN_DB_PREFIX.'commande_fournisseur_extrafields']; @@ -922,7 +922,7 @@ class modFournisseur extends DolibarrModules //Import PO Lines $r++; $this->import_code[$r] = 'commande_fournisseurdet_'.$r; - $this->import_label[$r] = 'PO Lines'; + $this->import_label[$r] = 'PurchaseOrderLines'; $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; $this->import_tables_array[$r] = ['cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields']; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 74ad1566e82..25163a766bd 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -174,7 +174,7 @@ class modGravatar extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty", // 'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd", // 'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -182,7 +182,7 @@ class modGravatar extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 25f04726fd6..a50b06201a2 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -89,6 +89,7 @@ class modHRM extends DolibarrModules $this->rights = array(); // Permission array used by this module $r = 0; + /* $this->rights[$r][0] = 4001; $this->rights[$r][1] = 'See employees'; $this->rights[$r][3] = 0; @@ -116,7 +117,7 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'export'; $r++; - + */ // Menus //------- diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 8f40e698dcb..23cbf7eddf8 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -243,7 +243,7 @@ class modHoliday extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -251,7 +251,7 @@ class modHoliday extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", // 'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line", // 'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", // 'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' @@ -260,7 +260,7 @@ class modHoliday extends DolibarrModules // 's.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel', // 's.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy', // 's.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.ref'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice", - // 'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', + // 'f.total_ht'=>"totalht",'f.total_ttc'=>"totalttc",'f.total_tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid', // 'fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc", // 'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid', // 'p.ref'=>'productref' diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php index 077f51ab519..47ef889e2dd 100644 --- a/htdocs/core/modules/modIntracommreport.class.php +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -44,13 +44,13 @@ class modIntracommreport extends DolibarrModules $this->numero = 68000; $this->family = "financial"; - $this->module_position = '100'; + $this->module_position = '60'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Intracomm report management (Support for French DEB/DES format)"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version - $this->version = 'development'; + $this->version = 'experimental'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'intracommreport'; diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 30aa547cb3a..b061e1b73a6 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -97,7 +97,7 @@ class modLoan extends DolibarrModules $r = 0; $r++; - $this->rights[$r][0] = 520; + $this->rights[$r][0] = 521; $this->rights[$r][1] = 'Read loans'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 9d590631fe4..ad14724d154 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -48,7 +48,7 @@ class modMailing extends DolibarrModules // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '22'; + $this->module_position = '23'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 0a4a7592a20..eb3baae78cd 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -236,7 +236,7 @@ class modMrp extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 6b05fe068aa..5bf91ec341e 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -221,7 +221,7 @@ class modMultiCurrency extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -230,7 +230,7 @@ class modMultiCurrency extends DolibarrModules // 't.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', // 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text', - // 'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric", + // 'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric", // 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric", // 'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date", // 'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text', @@ -239,8 +239,8 @@ class modMultiCurrency extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", - // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice", + // 'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' //); diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index e124b8304f3..072e0607b60 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -45,7 +45,7 @@ class modNotification extends DolibarrModules // It is used to group modules in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '01'; + $this->module_position = '22'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "EMail notifications (push) on business Dolibarr events"; diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 3da6ddfb695..24af8a3c953 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -168,8 +168,8 @@ class modPayBox extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town', // 's.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3', // 's.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT", - // 'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', + // 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT", + // 'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId', // 'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT", // 'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef', // ); @@ -177,7 +177,7 @@ class modPayBox extends DolibarrModules // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company', // 's.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company', // 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice", - // 'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', + // 'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice', // 'f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line", // 'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line", // 'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product', diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index 0ebb577e48b..a1e979715fe 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -175,7 +175,7 @@ class modPaypal extends DolibarrModules // 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone', // 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode', // 's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation", - // 'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', + // 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus', // 'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate", // 'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart", // 'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef' @@ -183,8 +183,8 @@ class modPaypal extends DolibarrModules // $this->export_entities_array[$r]=array( // 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company', // 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice", - // 'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", + // 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice", + // 'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line", // 'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line", // 'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product' // ); diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 2599f2f19fb..fd1c7cceca0 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -1,13 +1,13 @@ - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012-2013 Juanjo Menent - * Copyright (C) 2014 Christophe Battarel - * Copyright (C) 2014 Cedric Gross - * Copyright (C) 2020 Alexandre Spangaro +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012-2013 Juanjo Menent + * Copyright (C) 2014 Christophe Battarel + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2020-2021 Alexandre Spangaro * * 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 @@ -176,6 +176,8 @@ class modProduct extends DolibarrModules //-------- $r = 0; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Products"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -185,9 +187,9 @@ class modProduct extends DolibarrModules 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', - 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.weight_units'=>"WeightUnits", 'p.length'=>"Length", 'p.length_units'=>"LengthUnits", 'p.width'=>"Width", 'p.width_units'=>"WidthUnits", 'p.height'=>"Height", 'p.height_units'=>"HeightUnits", 'p.surface'=>"Surface", 'p.surface_units'=>"SurfaceUnits", 'p.volume'=>"Volume", 'p.volume_units'=>"VolumeUnits", @@ -230,8 +232,8 @@ class modProduct extends DolibarrModules 'p.ref'=>"Text", 'p.label'=>"Text", 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", 'p.description'=>"Text", 'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', @@ -293,6 +295,9 @@ class modProduct extends DolibarrModules } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; } @@ -386,9 +391,9 @@ class modProduct extends DolibarrModules $this->export_permission[$r] = array(array("produit", "export")); $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", @@ -403,8 +408,8 @@ class modProduct extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", @@ -419,8 +424,8 @@ class modProduct extends DolibarrModules $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r] = array( 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", @@ -441,7 +446,10 @@ class modProduct extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; @@ -634,7 +642,16 @@ class modProduct extends DolibarrModules } // End add extra fields $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - + $this->import_regex_array[$r] = array( + 'p.ref'=>'[^ ]', + 'p.price_base_type' => 'HT|TTC', + 'p.tosell'=>'^[0|1]$', + 'p.tobuy'=>'^[0|1]$', + 'p.fk_product_type'=>'^[0|1]$', + 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "ref:PREF123456", @@ -886,7 +903,7 @@ class modProduct extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('l.fk_product'=>'PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 166b8f6e637..79529898bb0 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -64,8 +64,8 @@ class modProductBatch extends DolibarrModules // Data directories to create when module is enabled. $this->dirs = array(); - // Config pages. Put here list of php page, stored into /product/admin/ directory, to setup the module. - $this->config_page_url = array("product_lot_extrafields.php@product"); + // Config pages. Put here list of php page, stored into productdluo/admin directory, to use to setup module. + $this->config_page_url = array("product_lot.php@product"); // Dependencies $this->hidden = false; // A condition to hide module @@ -76,8 +76,24 @@ class modProductBatch extends DolibarrModules $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module $this->langfiles = array("productbatch"); + // Constants // Constants $this->const = array(); + $r = 0; + + $this->const[$r][0] = "PRODUCTBATCH_LOT_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_lot_free"; + $this->const[$r][3] = 'Module to control product codes'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "PRODUCTBATCH_SN_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_sn_free"; + $this->const[$r][3] = 'Module to control product codes'; + $this->const[$r][4] = 0; + $r++; $this->tabs = array(); diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 687d8ea3669..c13a92e744e 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -350,7 +350,7 @@ class modPropale extends DolibarrModules //Import Proposal Lines $r++; $this->import_code[$r] = $this->rights_class.'line_'.$r; - $this->import_label[$r] = "ProposalLine"; // Translation key + $this->import_label[$r] = "ProposalLines"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = [ diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 4fe437700e4..ee87f4c57ba 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -95,7 +95,7 @@ class modReceiptPrinter extends DolibarrModules // $this->rights[$r][5] Niveau 2 pour nommer permission dans code $r++; - $this->rights[$r][0] = 67000; + $this->rights[$r][0] = 67001; $this->rights[$r][1] = 'ReceiptPrinter'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 247a4faeddc..02f17cf0fbe 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -236,7 +236,7 @@ class modReception extends DolibarrModules $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$this->db->sanitize($idcontacts).')'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index f7cd37c16be..3d4e88872ef 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -62,7 +62,7 @@ class modRecruitment extends DolibarrModules // Used only if file README.md and README-LL.md not found. $this->descriptionlong = "Manage and follow recruitment campaign for new job positions"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = 'experimental'; + $this->version = 'dolibarr'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 13ff4618483..3b21cf046c8 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2020 Alexandre Spangaro +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2020-2021 Alexandre Spangaro * * 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 @@ -143,6 +143,8 @@ class modService extends DolibarrModules //-------- $r = 0; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "Services"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -152,9 +154,9 @@ class modService extends DolibarrModules 'p.fk_product_type'=>'Type', 'p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy", 'p.description'=>"Description", 'p.url'=>"PublicUrl", 'p.customcode'=>'CustomCode', 'p.fk_country'=>'IDCountry', - 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.width'=>"Width", 'p.height'=>"Height", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.duration'=>"Duration", @@ -194,9 +196,9 @@ class modService extends DolibarrModules $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.fk_product_type'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", - 'p.description'=>"Text", 'p.url'=>"Text", 'p.accountancy_code_sell'=>"Text", - 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", 'p.accountancy_code_buy'=>"Text", - 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + 'p.description'=>"Text", 'p.url'=>"Text", + $alias_product_perentity . '.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . '.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.width'=>"Numeric", 'p.height'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', @@ -256,6 +258,9 @@ class modService extends DolibarrModules } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; } @@ -277,7 +282,7 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "ProductsMultiPrice"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 'pr.price_base_type'=>"PriceBase", 'pr.price_level'=>"PriceLevel", 'pr.price'=>"PriceLevelUnitPriceHT", 'pr.price_ttc'=>"PriceLevelUnitPriceTTC", @@ -311,7 +316,7 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref", 's.nom'=>'ThirdParty', 'pr.price_base_type'=>"PriceBase", @@ -344,12 +349,12 @@ class modService extends DolibarrModules $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r] = array(array("produit", "export")); + $this->export_permission[$r] = array(array("service", "export")); $this->export_fields_array[$r] = array( 'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", - 'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", + $alias_product_perentity . '.accountancy_code_sell'=>"ProductAccountancySellCode", $alias_product_perentity . '.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + $alias_product_perentity . '.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", $alias_product_perentity . '.accountancy_code_buy'=>"ProductAccountancyBuyCode", + $alias_product_perentity . '.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", $alias_product_perentity . '.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode", 'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic', 'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell", @@ -364,8 +369,8 @@ class modService extends DolibarrModules $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r] = array( 'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text", - 'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text", - 'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text", + $alias_product_perentity . 'p.accountancy_code_sell'=>"Text", $alias_product_perentity . '.accountancy_code_sell_intra'=>"Text", $alias_product_perentity . '.accountancy_code_sell_export'=>"Text", + $alias_product_perentity . 'p.accountancy_code_buy'=>"Text", $alias_product_perentity . '.accountancy_code_buy_intra'=>"Text", $alias_product_perentity . '.accountancy_code_buy_export'=>"Text", 'p.note'=>"Text", 'p.note_public'=>"Text", 'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text', 'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean", @@ -380,8 +385,8 @@ class modService extends DolibarrModules $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r] = array( 'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct', - 'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_sell'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_sell_export'=>'virtualproduct', + $alias_product_perentity . '.accountancy_code_buy'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_intra'=>'virtualproduct', $alias_product_perentity . '.accountancy_code_buy_export'=>'virtualproduct', 'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct", @@ -402,6 +407,9 @@ class modService extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pac ON pac.fk_product = p.rowid AND pac.entity = " . ((int) $conf->entity); + } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile @@ -443,13 +451,13 @@ class modService extends DolibarrModules 'p.weight' => "Weight", 'p.weight_units' => "WeightUnits", 'p.length' => "Length", - 'p.length_units' => "LengthUnit", + 'p.length_units' => "LengthUnits", 'p.width' => "Width", 'p.width_units' => "WidthUnits", 'p.height' => "Height", - 'p.height_units' => "HeightUnit", + 'p.height_units' => "HeightUnits", 'p.surface' => "Surface", - 'p.surface_units' => "SurfaceUnit", + 'p.surface_units' => "SurfaceUnits", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", 'p.duration' => "Duration", //duration of service @@ -463,13 +471,6 @@ class modService extends DolibarrModules 'p.datec' => 'DateCreation', 'p.cost_price' => "CostPrice", ); - if (!empty($conf->stock->enabled)) {//if Stock module enabled - $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( - 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning - 'p.pmp' => 'PMPValue', //weighted average price - 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature - )); - } $this->import_convertvalue_array[$r] = array( 'p.weight_units' => array( @@ -528,6 +529,41 @@ class modService extends DolibarrModules 'dict' => 'DictionaryCountry' ) ); + + $this->import_regex_array[$r] = array( + 'p.ref' => '[^ ]', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell' => '^[0|1]$', + 'p.tobuy' => '^[0|1]$', + 'p.fk_product_type' => '^[0|1]$', + 'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'p.recuperableonly' => '^[0|1]$', + ); + + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.fk_default_warehouse'=>'DefaultWarehouse', + 'p.tobatch'=>'ManageLotSerial', + 'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning + 'p.pmp' => 'PMPValue', //weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + + $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array( + 'p.tobatch' => '^[0|1|2]$' + )); + + $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( + 'p.fk_default_warehouse' => array( + 'rule' => 'fetchidfromref', + 'classfile' => '/product/stock/class/entrepot.class.php', + 'class' => 'Entrepot', + 'method' => 'fetch', + 'element'=> 'Warehouse' + ) + )); + } + if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) { $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); } @@ -562,7 +598,7 @@ class modService extends DolibarrModules $this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r] = array( 'p.ref'=>'[^ ]', - 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.price_base_type' => 'HT|TTC', 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', @@ -572,7 +608,7 @@ class modService extends DolibarrModules ); // field order as per structure of table llx_product $import_sample = array( - 'p.ref' => "PREF123456", + 'p.ref' => "ref:PREF123456", 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), 'p.label' => "Product name in default language", 'p.description' => "Product description in default language", @@ -609,7 +645,7 @@ class modService extends DolibarrModules 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', - 'p.finished' => '0 (raw material) / 1 (finished goods)' + 'p.finished' => '0 (raw material) / 1 (finished goods), matches field "code" in dictionary table "'.MAIN_DB_PREFIX.'c_product_nature"' ); //clauses copied from import_fields_array if (!empty($conf->stock->enabled)) { @@ -711,7 +747,7 @@ class modService extends DolibarrModules 'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); $this->import_examplevalues_array[$r] = array( - 'sp.fk_product' => "PRODUCT_REF or id:123456", + 'sp.fk_product' => "ref:PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", 'sp.ref_fourn' => "XYZ-F123456", 'sp.quantity' => "5", @@ -748,8 +784,13 @@ class modService extends DolibarrModules 'sp.multicurrency_price'=>'' )); } + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.packagning'=>'1', + )); + } - $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); + $this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier'); } if (!empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -776,7 +817,7 @@ class modService extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"SERVICE_REF or id:123456", + $this->import_examplevalues_array[$r] = array('pr.fk_product'=>"ref:SERVICE_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1", 'pr.price'=>"100", 'pr.price_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", @@ -799,7 +840,7 @@ class modService extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'l.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('l.fk_product'=>'SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); + $this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:SERVICE_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US'); $this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language'); } } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 38ca03ffe3b..f30709445b3 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -343,7 +343,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; + $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.$this->db->sanitize(implode(',', $subordinatesids)).')' : ''; } $this->export_sql_end[$r] .= ')'; } @@ -413,7 +413,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { $subordinatesids = $user->getAllChildIds(); - $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; + $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.$this->db->sanitize(implode(',', $subordinatesids)).')' : ''; } $this->export_sql_end[$r] .= ')'; } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 3d46d606265..c9379fb25d6 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -172,6 +172,12 @@ class modStock extends DolibarrModules $this->rights[9][3] = 0; // Permission by default for new user (0/1) $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + + $this->rights[10][0] = 1016; + $this->rights[10][1] = 'inventoryDeletePermission'; // Permission label + $this->rights[10][3] = 0; // Permission by default for new user (0/1) + $this->rights[10][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[10][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } // Main menu entries diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index a1318266334..b374000c74c 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -127,16 +127,21 @@ class modTicket extends DolibarrModules 'tabsql' => array( 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f', - 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', + 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.public FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f' ), 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"), - 'tabfield' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), - 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), - 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default"), + 'tabfield' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public", "code,label,pos,use_default"), + 'tabfieldvalue' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public", "code,label,pos,use_default"), + 'tabfieldinsert' => array("code,label,pos,use_default", "code,label,pos,use_default", "code,label,pos,use_default,public", "code,label,pos,use_default"), 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"), 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled), - 'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))), + 'tabhelp' => array( + array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), + array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), + array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"), 'public'=>$langs->trans("Enter0or1").'
    '.$langs->trans("TicketGroupIsPublicDesc")), + array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")) + ), ); // Boxes diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index 02f5e059297..b0fae39bb52 100755 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -45,12 +45,12 @@ class modWorkstation 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 = 690; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'workstation'; // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "other"; + $this->family = "products"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '90'; // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) @@ -71,7 +71,7 @@ class modWorkstation extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto = 'mrp'; + $this->picto = 'workstation'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( // Set this to 1 if module has its own trigger directory (core/triggers) @@ -239,7 +239,7 @@ class modWorkstation extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) @@ -330,6 +330,7 @@ class modWorkstation extends DolibarrModules // This is a Left menu entry 'type'=>'left', 'titre'=>$langs->trans('Workstations'), + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mrp', 'leftmenu'=>'workstation_workstation', 'url'=>'', diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index 5685a30c701..430622465ca 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -242,7 +242,7 @@ class modZapier extends DolibarrModules // Permission array used by this module $this->rights = array(); - $r = 0; + $r = 1; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission label diff --git a/htdocs/core/modules/movement/doc/index.html b/htdocs/core/modules/movement/doc/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/movement/doc/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/core/modules/product/doc/index.html b/htdocs/core/modules/product/doc/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/product/doc/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php new file mode 100644 index 00000000000..d8629b92dd6 --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -0,0 +1,145 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2021 Christophe Battarel + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product_batch/mod_lot_advanced.php + * \ingroup productbatch + * \brief File containing class for numbering model of Lot advanced + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + + +/** + * Class to manage Batch numbering rules advanced + */ +class mod_lot_advanced extends ModeleNumRefBatch +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name = 'lot_advanced'; + + + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; + + $langs->load("bills"); + + $form = new Form($db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
    \n"; + $texte .= '
    '; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte .= ''; + $texte .= ''; + + $texte .= ''; + + $texte .= ''; + + $texte .= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; + $texte .= '
    '; + + return $texte; + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; + + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; + + if (!$numExample) { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db, $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask = $conf->global->BATCH_ADVANCED_MASK; + + if (!$mask) { + $this->error = 'NotConfigured'; + return 0; + } + + $date = $object->date; + + $numFinal = get_next_value($db, $mask, 'product_lot', 'ref', '', null, $date); + + return $numFinal; + } +} diff --git a/htdocs/core/modules/product_batch/mod_lot_free.php b/htdocs/core/modules/product_batch/mod_lot_free.php new file mode 100644 index 00000000000..0f069143ab1 --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_lot_free.php @@ -0,0 +1,105 @@ + + * Copyright (C) 2006-2009 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product/mod_lot_free.php + * \ingroup productbatch + * \brief File containing class for numbering model of Lot free + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + +/** + * \class mod_codeproduct_leopard + * \brief Classe permettant la gestion leopard des codes produits + */ +class mod_lot_free extends ModeleNumRefBatch +{ + /* + * Attention ce module est utilise par defaut si aucun module n'a + * ete definit dans la configuration + * + * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible + */ + + + /** + * @var string model name + */ + public $name = 'lot_free'; + + public $code_modifiable; // Code modifiable + + public $code_modifiable_invalide; // Code modifiable si il est invalide + + public $code_modifiable_null; // Code modifiables si il est null + + public $code_null; // Code facultatif + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var int Automatic numbering + */ + public $code_auto; + + + /** + * Constructor + */ + public function __construct() + { + $this->code_null = 1; + $this->code_modifiable = 1; + $this->code_modifiable_invalide = 1; + $this->code_modifiable_null = 1; + $this->code_auto = 0; + } + + + /** + * Return description of module + * + * @return string Description of module + */ + public function info() + { + global $langs; + $langs->load("companies"); + return $langs->trans("LeopardNumRefModelDesc"); + } + + + /** + * Return an example of result returned by getNextValue + * + * @param product $objproduct Object product + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return next value + */ + public function getNextValue($objproduct = 0, $type = -1) + { + global $langs; + return ''; + } +} diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php new file mode 100644 index 00000000000..0d2b5a55139 --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -0,0 +1,145 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2021 Christophe Battarel + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product_batch/mod_lot_standard.php + * \ingroup productbatch + * \brief File of class to manage Lot numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + +/** + * Class to manage MO numbering rules standard + */ +class mod_lot_standard extends ModeleNumRefBatch +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix = 'LOT'; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string name + */ + public $name = 'lot_standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Checks if the numbers already in the database do not + * cause conflicts that would prevent this numbering working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + global $conf, $langs, $db; + + $coyymm = ''; $max = ''; + + $posindice = strlen($this->prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + } + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db, $conf; + + // First, we get the max value + $posindice = strlen($this->prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max = 0; + } else { + dol_syslog("mod_lot_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date = $object->date_creation; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); + + dol_syslog("mod_lot_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php new file mode 100644 index 00000000000..89d70a8239d --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -0,0 +1,145 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France + * Copyright (C) 2021 Christophe Battarel + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product_batch/mod_batch_advanced.php + * \ingroup productbatch + * \brief File containing class for numbering model of SN advanced + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + + +/** + * Class to manage Batch numbering rules advanced + */ +class mod_sn_advanced extends ModeleNumRefBatch +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name = 'sn_advanced'; + + + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; + + $langs->load("bills"); + + $form = new Form($db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
    \n"; + $texte .= '
    '; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); + $tooltip .= $langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte .= ''; + $texte .= ''; + + $texte .= ''; + + $texte .= ''; + + $texte .= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; + $texte .= '
    '; + + return $texte; + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf, $langs, $mysoc; + + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; + + if (!$numExample) { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db, $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask = $conf->global->BATCH_ADVANCED_MASK; + + if (!$mask) { + $this->error = 'NotConfigured'; + return 0; + } + + $date = $object->date; + + $numFinal = get_next_value($db, $mask, 'product_sn', 'ref', '', null, $date); + + return $numFinal; + } +} diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php new file mode 100644 index 00000000000..95e1bd20359 --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_sn_free.php @@ -0,0 +1,104 @@ + + * Copyright (C) 2006-2009 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product/mod_sn_free.php + * \ingroup productbatch + * \brief File containing class for numbering model of SN free + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + +/** + * \class mod_codeproduct_leopard + * \brief Classe permettant la gestion leopard des codes produits + */ +class mod_sn_free extends ModeleNumRefBatch +{ + /* + * Attention ce module est utilise par defaut si aucun module n'a + * ete definit dans la configuration + * + * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible + */ + + /** + * @var string model name + */ + public $name = 'sn_free'; + + public $code_modifiable; // Code modifiable + + public $code_modifiable_invalide; // Code modifiable si il est invalide + + public $code_modifiable_null; // Code modifiables si il est null + + public $code_null; // Code facultatif + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var int Automatic numbering + */ + public $code_auto; + + + /** + * Constructor + */ + public function __construct() + { + $this->code_null = 1; + $this->code_modifiable = 1; + $this->code_modifiable_invalide = 1; + $this->code_modifiable_null = 1; + $this->code_auto = 0; + } + + + /** + * Return description of module + * + * @return string Description of module + */ + public function info() + { + global $langs; + $langs->load("companies"); + return $langs->trans("LeopardNumRefModelDesc"); + } + + + /** + * Return an example of result returned by getNextValue + * + * @param product $objproduct Object product + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Return next value + */ + public function getNextValue($objproduct = 0, $type = -1) + { + global $langs; + return ''; + } +} diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php new file mode 100644 index 00000000000..bef5efcd9f8 --- /dev/null +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -0,0 +1,145 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2021 Christophe Battarel + * + * 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 . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/product_batch/mod_sn_standard.php + * \ingroup productbatch + * \brief File of class to manage SN numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; + +/** + * Class to manage MO numbering rules standard + */ +class mod_sn_standard extends ModeleNumRefBatch +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix = 'SN'; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string name + */ + public $name = 'sn_standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Checks if the numbers already in the database do not + * cause conflicts that would prevent this numbering working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + global $conf, $langs, $db; + + $coyymm = ''; $max = ''; + + $posindice = strlen($this->prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } + } + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db, $conf; + + // First, we get the max value + $posindice = strlen($this->prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lot"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; + + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max = 0; + } else { + dol_syslog("mod_sn_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date = $object->date_creation; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); + + dol_syslog("mod_sn_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php index f5ef6ac3dda..42d4d052bfe 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -65,3 +65,89 @@ abstract class ModelePDFProductBatch extends CommonDocGenerator return $list; } } + +/** + * Parent class to manage numbering of batch products + */ +abstract class ModeleNumRefBatch +{ + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Returns the default description of the numbering template + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("productbatch"); + return $langs->trans("NoDescription"); + } + + /** + * Returns an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("productbatch"); + return $langs->trans("NoExample"); + } + + /** + * Checks if the numbers already in the database do not + * cause conflicts that would prevent this numbering working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Returns next assigned value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns version of numbering module + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a02390d0ff8..f3aade80bf8 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1490,17 +1490,18 @@ class pdf_azur extends ModelePDFPropales $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index f5838d576d0..5d63a2fe3f5 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1598,17 +1598,18 @@ class pdf_cyan extends ModelePDFPropales $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); } } if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index ff9e4da5f0c..1822a5b8c95 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -245,6 +245,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) { $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; + $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax) } if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { $format = $conf->global->MAIN_DOC_USE_TIMING; @@ -290,7 +291,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".$object->id; + $sql .= " WHERE p.fk_soc = ".((int) $object->id); $result = $this->db->query($sql); $num = $this->db->num_rows($result); diff --git a/htdocs/core/modules/stock/doc/index.html b/htdocs/core/modules/stock/doc/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/stock/doc/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index e5fa94135ad..b9c40645544 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -1023,7 +1023,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; + $sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".((int) $object->id); $sql .= " ORDER BY p.datep"; $resql = $this->db->query($sql); if ($resql) { @@ -1111,7 +1111,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + $title = $outputlangs->transnoentities("PdfInvoiceTitle"); + if ($object->type == 1) { + $title = $outputlangs->transnoentities("InvoiceReplacement"); + } + if ($object->type == 2) { + $title = $outputlangs->transnoentities("InvoiceAvoir"); + } + if ($object->type == 3) { + $title = $outputlangs->transnoentities("InvoiceDeposit"); + } + $pdf->MultiCell(100, 3, $title." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); $posy += 1; if ($object->ref_supplier) { @@ -1125,14 +1135,25 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index e560b8178e8..3cf0a4a209e 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013-2018 Philippe Grand - * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2016 Alexandre Spangaro +/* Copyright (C) 2003-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013-2018 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2016-2021 Alexandre Spangaro * * 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 @@ -23,7 +23,7 @@ /** * \file htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php - * \ingroup commande + * \ingroup Supplier invoice * \brief File containing the Tulip Class of numbering models of suppliers invoices references */ @@ -90,7 +90,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice")); $tooltip .= $langs->trans("GenericMaskCodes5"); - // Parametrage du prefix + // Setting the prefix $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; $texte .= ':'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; @@ -99,7 +99,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte .= ''; - // Parametrage du prefix des avoirs + // Prefix setting of credit note $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte .= ''; @@ -109,14 +109,13 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):'; $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; $texte .= ''; - - - // Parametrage du prefix des acomptes - $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'; - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - $texte .= ''; } + // Prefix setting of deposit + $texte .= ''.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):'; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''; + $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index fc5cbd1027e..f2f75031d3b 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1269,14 +1269,25 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 9ca3031f037..de283265931 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -1178,9 +1178,20 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 25dde592779..138a6210904 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -688,16 +688,27 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetFont('','', $default_font_size - 1); + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + if (! empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (! empty($object->project->ref)) { + $outputlangs->load("projects"); $posy+=4; $pdf->SetXY($posx,$posy); $langs->load("projects"); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->project->ref), '', 'R'); } } diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 008e524f299..b3079691cd5 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -487,8 +487,8 @@ print load_fiche_titre($title); $infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha')); $height = $infoarray['height']; $width = $infoarray['width']; -print $langs->trans("CurrentInformationOnImage").': '; -print $langs->trans("Width").': '.$width.' x '.$langs->trans("Height").': '.$height.'
    '; +print ''.$langs->trans("CurrentInformationOnImage").': '; +print $langs->trans("Width").': '.$width.' x '.$langs->trans("Height").': '.$height.'
    '; print '
    '."\n"; diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index 65b8b566180..9fef2d2f2b9 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -78,7 +78,7 @@ foreach ($object->fields as $key => $val) { } $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; } elseif ($val['type'] == 'price') { - $value = price2num(GETPOST($key)); + $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key); } else { $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 3940f0c38e5..d1613cee7e9 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -81,7 +81,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra])) { $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$tmpkeyextra], 1); } - //print $tmpkeyextra.'-'.$enabled.'-'.$perms.'-'.$tmplabelextra.$_POST["options_" . $tmpkeyextra].'
    '."\n"; + //print $tmpkeyextra.'-'.$enabled.'-'.$perms.'
    '."\n"; if (empty($enabled)) { continue; // 0 = Never visible field @@ -182,6 +182,9 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] if ($object->element == 'mo') { $permok = $user->rights->mrp->write; } + if ($object->element == 'contact') { + $permok = $user->rights->societe->contact->creer; + } $isdraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0)); if (($isdraft || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$tmpkeyextra])) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 6ff7bba2390..bfd10e25424 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -86,6 +86,9 @@ if ($module == 'ecm') { print ''; print ''; } +if ($permtoadd) { + print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateImgWebp")).'">'; +} // Start "Add new file" area $nameforformuserfile = 'formuserfileecm'; @@ -133,6 +136,45 @@ if ($action == 'delete_section') { } // End confirm +if ($action == 'confirmconvertimgwebp') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', '', "yes", 1); + $action = 'file_manager'; +} + +if ($action == 'convertimgwebp' && $permtoadd) { + if ($module == 'medias') { + $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/image/'.$websitekey.'/'; + } else { + $imagefolder = $conf->ecm->dir_output; + } + + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + + $regeximgext = getListOfPossibleImageExt(); + + $filelist = dol_dir_list($imagefolder, "all", 1, $regeximgext); + + 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); + $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp'); + if (!dol_is_file($result)) { + $error++; + setEventMessages($result, null, 'errors'); + } + } + } + if ($error) { + break; + } + } + if (!$error) { + setEventMessages($langs->trans('SucessConvertImgWebp'), null); + } + $action = 'file_manager'; +} if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { $langs->load("ecm"); diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index b1d9664af57..60b541d8afb 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -24,7 +24,7 @@ if (empty($object) || !is_object($object)) { } // $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create -// $cssclass must be defined by caller. For example $cssclass='fieldtitle" +// $cssclass must be defined by caller. For example $cssclass='fieldtitle' $module = $object->element; $note_public = 'note_public'; $note_private = 'note_private'; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index fdd18638053..7f7cd5a77be 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -942,6 +942,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $societeforaction->fetch($object->socid); } elseif (isset($object->fk_soc) && $object->fk_soc > 0) { $societeforaction->fetch($object->fk_soc); + } elseif (isset($object->thirdparty) && isset($object->thirdparty->id) && $object->thirdparty->id > 0) { + $societeforaction = $object->thirdparty; } $projectid = isset($object->fk_project) ? $object->fk_project : 0; diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 64d30eeeb93..0e571f26c98 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -198,7 +198,7 @@ class InterfaceStripe extends DolibarrTriggers } $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE site='stripe' AND fk_soc = ".$object->id; + $sql .= " WHERE site='stripe' AND fk_soc = ".((int) $object->id); $this->db->query($sql); } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 67ba6e64edc..30ffee00248 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -93,7 +93,7 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') { // If we browsi if (GETPOST('l', 'aZ09')) { $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; - $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " WHERE wp.fk_website = ".((int) $website->id); $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; if (is_object($websitepage) && $websitepage->fk_page > 0) { $sql .= " OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index 3f0e46e0104..6adc9da030e 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -36,15 +36,17 @@ if (!$user->rights->cron->read) { $id = GETPOST('id', 'int'); -$mesg = ''; +$object = new Cronjob($db); + /* * View -*/ + */ + +$form = new Form($db); // $form is required as global value into dol_banner_tab llxHeader('', $langs->trans("CronInfo")); -$object = new Cronjob($db); $object->fetch($id); $object->info($id); diff --git a/htdocs/debugbar/class/DataCollector/index.html b/htdocs/debugbar/class/DataCollector/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/class/DataCollector/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/debugbar/class/index.html b/htdocs/debugbar/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/class/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/debugbar/js/index.html b/htdocs/debugbar/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/debugbar/js/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 5b14b509de4..18887a99e28 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -614,7 +614,7 @@ class Delivery extends CommonObject { if ($this->statut == 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".$lineid; + $sql .= " WHERE rowid = ".((int) $lineid); if ($this->db->query($sql)) { $this->update_price(); @@ -940,7 +940,7 @@ class Delivery extends CommonObject $sqlSourceLine .= ", p.ref, p.label"; $sqlSourceLine .= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectsIds[0]['type']."det as st"; $sqlSourceLine .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; - $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; + $sqlSourceLine .= " WHERE fk_".$this->linked_object[0]['type']." = ".((int) $this->linked_object[0]['linkid']); $resultSourceLine = $this->db->query($sqlSourceLine); if ($resultSourceLine) { diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 283a8e6b2da..1dfade00bec 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -275,7 +275,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Remove file in doc form /*if ($action == 'remove_file') { - $object = new Don($db, 0, $_GET['id']); + $object = new Don($db, 0, GETPOST('id', 'int')); if ($object->fetch($id)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -329,7 +329,7 @@ if ($action == 'builddoc') * View */ -$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; llxHeader('', $langs->trans("Donation"), $help_url); diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index ab0d6e5f483..2773ab62c14 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -103,6 +103,10 @@ class Donations extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->don->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -179,6 +183,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } + // Check mandatory fields $result = $this->_validate($request_data); @@ -247,6 +252,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); } + $result = $this->don->fetch($id); if (!$result) { throw new RestException(404, 'Donation not found'); @@ -295,6 +301,7 @@ class Donations extends DolibarrApi if (!DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); } + $result = $this->don->fetch($id); if (!$result) { throw new RestException(404, 'Donation not found'); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index a5fb676e314..1ec3ebe1cc5 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -702,7 +702,7 @@ class Don extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0"; + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".((int) $userid)." WHERE rowid = ".((int) $id)." AND fk_statut = 0"; $resql = $this->db->query($sql); if ($resql) { @@ -759,9 +759,9 @@ class Don extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; if ($modepayment) { - $sql .= ", fk_payment=".$modepayment; + $sql .= ", fk_payment = ".((int) $modepayment); } - $sql .= " WHERE rowid = ".$id." AND fk_statut = 1"; + $sql .= " WHERE rowid = ".((int) $id)." AND fk_statut = 1"; $resql = $this->db->query($sql); if ($resql) { @@ -843,7 +843,7 @@ class Don extends CommonObject $sql = "SELECT sum(amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."don"; - $sql .= " WHERE fk_statut = ".$param; + $sql .= " WHERE fk_statut = ".((int) $param); $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index e3deff2dc2d..07eb6d6588e 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -85,7 +85,7 @@ class DonationStats extends Stats //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; $this->where .= " AND d.entity = ".$conf->entity; if ($this->userid > 0) { - $this->where .= ' WHERE c.fk_user_author = '.$this->userid; + $this->where .= ' WHERE c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 08667c6ab4c..63551a12fa3 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -102,8 +102,10 @@ if (!empty($conf->projet->enabled)) { } $title = $langs->trans('Donation')." - ".$langs->trans('Documents'); -$helpurl = ""; -llxHeader('', $title, $helpurl); + +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; + +llxHeader('', $title, $help_url); if ($object->id) { diff --git a/htdocs/don/index.php b/htdocs/don/index.php index 9415a1e928b..dfdeb76f2a9 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -53,7 +53,8 @@ $donation_static = new Don($db); $donstatic = new Don($db); -$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; + llxHeader('', $langs->trans("Donations"), $help_url); $nb = array(); @@ -119,7 +120,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel $dataseries = array(); $colorseries = array(); -include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; +include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print ''; print ''; diff --git a/htdocs/don/info.php b/htdocs/don/info.php index 866ff4baf22..8d8f4065dda 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -57,8 +57,10 @@ if ($action == 'classin' && $user->rights->don->creer) { * View */ $title = $langs->trans('Donation')." - ".$langs->trans('Info'); -$helpurl = ""; -llxHeader('', $title, $helpurl); + +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; + +llxHeader('', $title, $help_url); $form = new Form($db); if (!empty($conf->projet->enabled)) { diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9798cd02eea..0c8f51281a3 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -97,7 +97,9 @@ if (!empty($conf->projet->enabled)) { $projectstatic = new Project($db); } -llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'); +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; + +llxHeader('', $langs->trans("Donations"), $help_url); // Genere requete de liste des dons $sql = "SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,"; @@ -106,7 +108,7 @@ $sql .= " p.rowid as pid, p.ref, p.title, p.public"; $sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; $sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; if ($search_status != '' && $search_status != '-4') { - $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; + $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")"; } if (trim($search_ref) != '') { $sql .= natural_search('d.ref', $search_ref); @@ -292,7 +294,7 @@ if ($resql) { } print "\n"; } - print ''; + print ''; print ''; print ''; print ""; diff --git a/htdocs/don/note.php b/htdocs/don/note.php index fa0122eaba2..2e153d73b95 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -70,8 +70,10 @@ if ($action == 'classin' && $user->rights->don->creer) { */ $title = $langs->trans('Donation')." - ".$langs->trans('Notes'); -$helpurl = ""; -llxHeader('', $title, $helpurl); + +$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden'; + +llxHeader('', $title, $help_url); $form = new Form($db); if (!empty($conf->projet->enabled)) { diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php index ca33d6ffc23..cf6328d15c4 100644 --- a/htdocs/don/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -29,9 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); -$chid = GETPOST("rowid"); +$chid = GETPOST("rowid", 'int'); $action = GETPOST('action', 'aZ09'); $amounts = array(); +$cancel = GETPOST('cancel'); // Security check $socid = 0; @@ -49,15 +50,15 @@ $object = new Don($db); if ($action == 'add_payment') { $error = 0; - if ($_POST["cancel"]) { + if ($cancel) { $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; header("Location: ".$loc); exit; } - $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); - if (!$_POST["paymenttype"] > 0) { + if (!(GETPOST("paymenttype") > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } @@ -65,7 +66,7 @@ if ($action == 'add_payment') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0) { + if (!empty($conf->banque->enabled) && !(GETPOST("accountid", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; } @@ -143,7 +144,7 @@ llxHeader(); $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p"; -$sql .= " WHERE p.fk_donation = ".$chid; +$sql .= " WHERE p.fk_donation = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -183,8 +184,8 @@ if ($action == 'create') { print '
    '.price($objp->amount).''.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
    '; print '"; print ''; diff --git a/htdocs/emailcollector/class/index.html b/htdocs/emailcollector/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/emailcollector/class/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/emailcollector/lib/index.html b/htdocs/emailcollector/lib/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/emailcollector/lib/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 7f28d40dd29..15724233b31 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -61,7 +61,7 @@ class ConferenceOrBooth extends ActionComm /** * @var string String with name of icon for conferenceorbooth. Must be the part after the 'object_' into object_conferenceorbooth.png */ - public $picto = 'conferenceorbooth@eventorganization'; + public $picto = 'conferenceorbooth'; const STATUS_DRAFT = 0; @@ -117,7 +117,7 @@ class ConferenceOrBooth extends ActionComm 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), ); public $rowid; public $id; @@ -152,12 +152,6 @@ class ConferenceOrBooth extends ActionComm $this->fields['entity']['enabled'] = 0; } - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->eventorganization->conferenceorbooth->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - // Unset fields that are disabled foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -272,6 +266,7 @@ class ConferenceOrBooth extends ActionComm $sql = 'SELECT '; $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; } else { @@ -281,7 +276,7 @@ class ConferenceOrBooth extends ActionComm $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key == 't.id') { + if ($key == 't.id' || $key == 't.fk_project' || $key == 't.fk_soc' || $key == 't.fk_action') { $sqlwhere[] = $key.'='.$value; } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; @@ -565,6 +560,9 @@ class ConferenceOrBooth extends ActionComm if ($add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } + if ($option=='withproject') { + $url .= '&withproject=1'; + } } $linkclose = ''; @@ -573,7 +571,7 @@ class ConferenceOrBooth extends ActionComm $label = $langs->trans("ShowConferenceOrBooth"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + //$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); @@ -587,25 +585,23 @@ class ConferenceOrBooth extends ActionComm if (empty($this->showphoto_on_popup)) { if ($withpicto) { - $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $picto = img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + // var_dump($picto); + $result .= $picto; } } else { if ($withpicto) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + //list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->eventorganisation->multidir_output[$conf->entity]."/".dol_sanitizeFileName($this->ref); $filearray = dol_dir_list($upload_dir, "files"); $filename = $filearray[0]['name']; if (!empty($filename)) { $pospoint = strpos($filearray[0]['name'], '.'); - $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { - $result .= '
    No photo
    '; - } else { - $result .= '
    No photo
    '; - } + $pathtophoto = '/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + $result .= '
    No photo
    '; $result .= ''; } else { @@ -694,7 +690,7 @@ class ConferenceOrBooth extends ActionComm $sql = 'SELECT rowid, datec as datec, tms as datem,'; $sql .= ' fk_user_author, fk_user_mod'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.id = '.$id; + $sql .= ' WHERE t.id = '.((int) $id); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php new file mode 100644 index 00000000000..ef5e85c7229 --- /dev/null +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -0,0 +1,1100 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file class/conferenceorboothattendee.class.php + * \ingroup eventorganization + * \brief This file is a CRUD class file for ConferenceOrBoothAttendee (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for ConferenceOrBoothAttendee + */ +class ConferenceOrBoothAttendee extends CommonObject +{ + /** + * @var string ID of module. + */ + public $module = 'eventorganization'; + + /** + * @var string ID to identify managed object. + */ + public $element = 'conferenceorboothattendee'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'eventorganization_conferenceorboothattendee'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for conferenceorboothattendee. Must be the part after the 'object_' into object_conferenceorboothattendee.png + */ + public $picto = 'contact'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",), + 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,), + 'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,), + 'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',), + 'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), + 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'default'=>0,'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'),), + ); + public $rowid; + public $ref; + public $fk_soc; + public $fk_actioncomm; + public $email; + public $date_subscription; + public $amount; + public $note_public; + public $note_private; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $last_main_doc; + public $import_key; + public $model_pdf; + public $status; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + // /** + // * @var string Name of subtable line + // */ + // public $table_element_line = 'eventorganization_conferenceorboothattendeeline'; + + // /** + // * @var string Field with ID of parent key if this object has a parent + // */ + // public $fk_element = 'fk_conferenceorboothattendee'; + + // /** + // * @var string Name of subtable class that manage subtable lines + // */ + // public $class_element_line = 'ConferenceOrBoothAttendeeline'; + + // /** + // * @var array List of child tables. To test if we can delete object. + // */ + // protected $childtables = array(); + + // /** + // * @var array List of child tables. To know object to delete on cascade. + // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will + // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object + // */ + // protected $childtablesoncascade = array('eventorganization_conferenceorboothattendeedet'); + + // /** + // * @var ConferenceOrBoothAttendeeLine[] Array of subtable lines + // */ + // public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + if (!empty($conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT)) { + $this->fields['fk_soc']['type'] .= ' AND rowid IN (SELECT DISTINCT c.fk_soc FROM '.MAIN_DB_PREFIX.'categorie_societe as c WHERE c.fk_categorie='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_CAT.')'; + } + if ($conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE!=='') { + $this->fields['fk_soc']['type'] .= ' AND client='.(int) $conf->global->EVENTORGANIZATION_FILTERATTENDEES_TYPE; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->eventorganization->conferenceorboothattendee->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + global $langs; + + if (!isValidEMail($this->email)) { + $langs->load("errors"); + $this->errors[] = $langs->trans("ErrorBadEMail", $this->email); + return -1; + } + + $result = $this->createCommon($user, $notrigger); + if ($result>0) { + $result =$this->fetch($result); + if ($result>0) { + $this->ref = $this->id; + $result = $this->update($user); + } + } + return $result; + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { + $error++; + } + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines = array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList('t'); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm"; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.fk_soc' || $key == 't.fk_project' || $key == 't.fk_actioncomm') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->conferenceorboothattendee->conferenceorboothattendee_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".$user->id; + } + $sql .= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('CONFERENCEORBOOTHATTENDEE_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'conferenceorboothattendee/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'conferenceorboothattendee/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$oldref; + $dirdest = $conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->eventorganization->dir_output.'/conferenceorboothattendee/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'CONFERENCEORBOOTHATTENDEE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->eventorganization->eventorganization_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'CONFERENCEORBOOTHATTENDEE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("ConferenceOrBoothAttendee").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + + if ($option == 'conforboothid') { + $url .= '&conforboothid='.$this->fk_actioncomm; + } + + if ($option == 'conforboothidproject') { + $url .= '&conforboothid='.$this->fk_actioncomm.'&withproject=1' ; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowConferenceOrBoothAttendee"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink') { + $linkstart = ''; + if ($option == 'nolink') { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
    No photo
    '; + } else { + $result .= '
    No photo
    '; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('conferenceorboothattendeedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("eventorganization@eventorganization"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.((int) $id); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines = array(); + + $objectline = new ConferenceOrBoothAttendeeLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorboothattendee = '.$this->id)); + + if (is_numeric($result)) { + $this->error = $this->error; + $this->errors = $this->errors; + return $result; + } else { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("eventorganization@eventorganization"); + + if (empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON = 'mod_conferenceorboothattendee_standard'; + } + + if (!empty($conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON)) { + $mybool = false; + + $file = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON.".php"; + $classname = $conf->global->EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/eventorganization/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("eventorganization@eventorganization"); + + if (!dol_strlen($modele)) { + $modele = 'standard_conferenceorboothattendee'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF)) { + $modele = $conf->global->CONFERENCEORBOOTHATTENDEE_ADDON_PDF; + } + } + + $modelpath = "core/modules/eventorganization/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * Use public function doScheduledJob($param1, $param2, ...) to get parameters + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doScheduledJob() + { + global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error = ''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} + + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; + +/** + * Class ConferenceOrBoothAttendeeLine. You can also remove this and generate a CRUD class for lines objects. + */ +class ConferenceOrBoothAttendeeLine extends CommonObjectLine +{ + // To complete with content of an object ConferenceOrBoothAttendeeLine + // We should have a field rowid, fk_conferenceorboothattendee and position + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } +} diff --git a/htdocs/eventorganization/conferenceorbooth_agenda.php b/htdocs/eventorganization/conferenceorbooth_agenda.php deleted file mode 100644 index bd50df31a91..00000000000 --- a/htdocs/eventorganization/conferenceorbooth_agenda.php +++ /dev/null @@ -1,306 +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 . - */ - -/** - * \file conferenceorbooth_agenda.php - * \ingroup eventorganization - * \brief Tab of events on ConferenceOrBooth - */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - - -// Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "other")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); -} -$search_agenda_label = GETPOST('search_agenda_label'); - -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC'; -} - -// Initialize technical objects -$object = new ConferenceOrBooth($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothagenda', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; -} - -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php - - - -/* - * Actions - */ - -$parameters = array('id'=>$id); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } -} - - - -/* - * View - */ - -$form = new Form($db); - -if ($object->id > 0) { - $title = $langs->trans("Agenda"); - //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = ''; - llxHeader('', $title, $help_url); - - if (!empty($conf->notification->enabled)) { - $langs->load("mails"); - } - $head = conferenceorboothPrepareHead($object); - - - print dol_get_fiche_head($head, 'agenda', $langs->trans("ConferenceOrBooth"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
    '; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - } - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
    '; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
    '; - print '
    '; - - $object->info($object->id); - dol_print_object_info($object, 1); - - print '
    '; - - print dol_get_fiche_end(); - - - - // Actions buttons - - $objthirdparty = $object; - $objcon = new stdClass(); - - $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); - $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; - $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; - } - - - print '
    '; - - if (!empty($conf->agenda->enabled)) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { - print ''.$langs->trans("AddAction").''; - } else { - print ''.$langs->trans("AddAction").''; - } - } - - print '
    '; - - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - - - //print load_fiche_titre($langs->trans("ActionsOnConferenceOrBooth"), '', ''); - - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 495d0334a10..29d6758e259 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -27,8 +27,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; // Load translation files required by the page @@ -43,11 +44,13 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$withproject = GETPOST('withproject', 'int'); +$mode = GETPOST('mode', 'alpha'); // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothcard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -72,12 +75,6 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -/*$permissiontoread = $user->rights->eventorganization->conferenceorbooth->read; -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->eventorganization->conferenceorbooth->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_dellink.inc.php*/ $permissiontoread = $user->rights->eventorganization->read; $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); @@ -153,9 +150,6 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } - - - /* * View * @@ -170,21 +164,187 @@ $title = $langs->trans("ConferenceOrBooth"); $help_url = ''; llxHeader('', $title, $help_url); -// Example : Adding jquery code -/*print '';*/ +if ($action == 'create') { + $result = $projectstatic->fetch(GETPOST('fk_project')); +} else { + $result = $projectstatic->fetch($object->fk_project); +} +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print '
    '.$langs->trans("Date").''; - $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaid) : 0; + $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (GETPOST("remonth") ? $datepaid : -1) : 0; print $form->selectDate($datepayment, '', 0, 0, 0, "add_payment", 1, 1, 0, '', '', $object->date, '', 1, $langs->trans("DonationDate")); print "
    '; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print ''; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print ''; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} // Part to create if ($action == 'create') { @@ -202,9 +362,6 @@ if ($action == 'create') { print dol_get_fiche_head(array(), ''); - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; - print ''."\n"; // Common attributes @@ -234,6 +391,9 @@ if (($id || $ref) && $action == 'edit') { print ''; print ''; + if (!empty($withProjectUrl)) { + print ''; + } print ''; print ''; if ($backtopage) { @@ -268,27 +428,24 @@ if (($id || $ref) && $action == 'edit') { if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBooth"), -1, $object->picto); $formconfirm = ''; // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('DeleteConferenceOrBooth'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation of action xxxx + //TODO Send mass email if ($action == 'xxx') { $formquestion = array(); /* @@ -305,7 +462,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; @@ -316,52 +473,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Print form confirm print $formconfirm; - // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + http://dolibarr.local/eventorganization/conferenceorbooth_list.php?projectid=7 + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
    '; print '
    '; print '
    '; @@ -384,55 +506,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
    - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
    '; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - 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 (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - print ''; - - print "\n"; - } - - // Buttons for actions if ($action != 'presend' && $action != 'editline') { @@ -446,49 +519,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&mode=init#formmailbeforetitle'); } - // Back to draft - if ($object->status == $object::STATUS_CONFIRMED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); - } - - 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)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); - } else { - $langs->load("errors"); - //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0); - print ''.$langs->trans("Validate").''; - } - } + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit', '', $permissiontoadd); // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - - /* - if ($permissiontoadd) { - if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; - } else { - print ''.$langs->trans("Enable").''."\n"; - } - } - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print ''.$langs->trans("Cancel").''."\n"; - } else { - print ''.$langs->trans("Re-Open").''."\n"; - } - } - */ + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); } print ''."\n"; } @@ -503,7 +543,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; print ''; // ancre - $includedocgeneration = 0; + $includedocgeneration = 1; // Documents if ($includedocgeneration) { @@ -511,9 +551,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->eventorganization->conferenceorbooth->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->eventorganization->conferenceorbooth->write; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('eventorganization:ConferenceOrBooth', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + $genallowed = $user->rights->eventorganization->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->eventorganization->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('eventorganization', $object->element.'/'.$objref, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } // Show links to link elements @@ -521,20 +561,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; - - $MAXEVENT = 10; - - $morehtmlright = ''; - $morehtmlright .= $langs->trans("SeeAll"); - $morehtmlright .= ''; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); - - print '
    '; + print '
    '; + print '
    '; } //Select mail models is same action as presend diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php index d42cc78adcb..4906a4e05e3 100644 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Florian HENRY * * 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 @@ -55,9 +55,10 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); - +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; // Load translation files required by the page $langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); @@ -66,10 +67,12 @@ $ref = GETPOST('ref', 'alpha'); $lineid = GETPOST('lineid', 'int'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); +$withproject = GETPOST('withproject', 'int'); // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -85,7 +88,7 @@ if ($user->socid > 0) { $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permission = $user->rights->eventorganization->conferenceorbooth->write; +$permission = $user->rights->eventorganization->write; /* @@ -98,7 +101,7 @@ if ($action == 'addcontact' && $permission) { // Add a new contact $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -110,13 +113,13 @@ if ($action == 'addcontact' && $permission) { // Add a new contact } } elseif ($action == 'swapstatut' && $permission) { // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $permission) { // Deletes a contact $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.(!empty($withproject)?'&withproject=1':'')); exit; } else { dol_print_error($db); @@ -145,11 +148,188 @@ $userstatic = new User($db); /* */ /* *************************************************************************** */ +$result = $projectstatic->fetch($object->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + if ($object->id) { /* * Show tabs */ - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'contact', $langs->trans("ConferenceOrBooth"), -1, $object->picto); diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index 1f354453fd1..fc3673d618f 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Florian Henry * * 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 @@ -22,73 +22,27 @@ * \brief Tab for documents linked to ConferenceOrBooth */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("eventorganization@eventorganization", "companies", "other", "mails")); - +$langs->loadLangs(array("eventorganization", "companies", "other", "mails")); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); +$withproject = GETPOST('withproject', 'int'); +$project_ref = GETPOST('project_ref', 'alpha'); + // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -112,6 +66,7 @@ if (!$sortfield) { // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); +$projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -152,11 +107,187 @@ $help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); +$result = $projectstatic->fetch($object->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} + +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + //TODO fill with ics + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + if ($object->id) { /* * Show tabs */ - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); @@ -169,47 +300,11 @@ if ($object->id) { } // Object card - // ------------------------------------------------------------ + // ------------- + //----------------------------------------------- $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ $morehtmlref .= '
    '; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -237,7 +332,10 @@ if ($object->id) { //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; $permtoedit = 1; $param = '&id='.$object->id; - + //$param = ''; + if ($withproject) { + $param .= '&withproject=1'; + } //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index f4cda255cdb..814a61ae894 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2021 Florian Henry * * 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 @@ -132,18 +132,41 @@ $permissiontoadd = $user->rights->eventorganization->write; $permissiontodelete = $user->rights->eventorganization->delete; // Security check -//$socid = 0; +if (empty($conf->eventorganization->enabled)) { + accessforbidden('Module not enabled'); +} +$socid = 0; if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } $result = restrictedArea($user, 'eventorganization'); - +if (!$permissiontoread) accessforbidden(); /* * Actions */ +if (preg_match('/^set/', $action) && $projectid > 0) { + $project = new Project($db); + //If "set" fields keys is in projects fields + $project_attr=preg_replace('/^set/', '', $action); + if (array_key_exists($project_attr, $project->fields)) { + $result = $project->fetch($projectid); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } else { + $project->{$project_attr}=GETPOST($project_attr); + $result=$project->update($user); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } + } + } +} +/*if ($action=='setaccept_conference_suggestions' && !empty(GETPOST('cancel', 'alpha'))) { +}*/ +//setaccept_booth_suggestions if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; @@ -152,6 +175,9 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $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) { @@ -265,7 +291,7 @@ if ($projectid > 0) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->project->all->lire) { $objectsListId = $project->getProjectsAuthorizedForUser($user, 0, 0); - $project->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $project->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($project, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -362,6 +388,39 @@ if ($projectid > 0) { print ""; } + print ''; + $typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + $typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print ""; + + print ''.$langs->trans("EventOrganizationICSLink").''; + print ''; + print ""; + + print ''; print ''; @@ -403,10 +462,11 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } - +if ($projectid > 0) { + $sql .= ' AND t.fk_project='.$project->id; +} foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { - //var_dump($key,$object->fields); if ($key == 'status' && $search[$key] == -1) { continue; } @@ -421,7 +481,6 @@ foreach ($search as $key => $val) { $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { - //var_dump($key,$object->fields); if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { @@ -447,22 +506,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -/* If a group by is required -$sql.= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; -} -// Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); -} -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); -*/ - $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -554,9 +597,9 @@ print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/eventorganization/conferenceorbooth_card.php', 1).'?action=create'.(!empty($project->id)?'&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendConferenceOrBoothRef"; @@ -725,6 +768,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; if ($key == 'status') { print $object->getLibStatut(5); + } elseif ($key == 'ref') { + print $object->getNomUrl(1, 0, '', (($projectid > 0)?'withproject':'')); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php new file mode 100644 index 00000000000..68f6c4eef13 --- /dev/null +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -0,0 +1,706 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file conferenceorboothattendee_card.php + * \ingroup eventorganization + * \brief Page to create/edit/view conferenceorboothattendee + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothattendeecard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +$conf_or_booth_id = GETPOST('conforboothid', 'int'); +$withproject = GETPOST('withproject', 'int'); + +// Initialize technical objects +$object = new ConferenceOrBoothAttendee($db); +$extrafields = new ExtraFields($db); +$projectstatic = new Project($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothattendeecard', 'globalcard')); // Note that conf->hooks_modules contains array + +if ($conf_or_booth_id > 0) { + $confOrBooth = new ConferenceOrBooth($db); + $result = $confOrBooth->fetch($conf_or_booth_id); + if ($result < 0) { + setEventMessages(null, $confOrBooth->errors, 'errors'); + } else { + $object->fk_actioncomm = $confOrBooth->id; + $object->fk_project = $confOrBooth->fk_project; + } +} + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + + +$permissiontoread = $user->rights->eventorganization->read; +$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; + +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + $error = 0; + + if (!empty($withproject)) { + $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php?withproject=1', 1); + } else { + $backurlforlist = dol_buildpath('/eventorganization/conferenceorboothattendee_list.php', 1); + } + + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } + } + + $triggermodname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; + + // Action to build doc + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + if ($action == 'set_thirdparty' && $permissiontoadd) { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); + } + if ($action == 'classin' && $permissiontoadd) { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Actions to send emails + $triggersendname = 'EVENTORGANIZATION_CONFERENCEORBOOTHATTENDEE_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_CONFERENCEORBOOTHATTENDEE_TO'; + $trackid = 'conferenceorboothattendee'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); + +$title = $langs->trans("ConferenceOrBoothAttendee"); +$help_url = ''; +llxHeader('', $title, $help_url); + +$result = $projectstatic->fetch($confOrBooth->fk_project); +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); +} +if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); +} + +$withProjectUrl=''; +$object->project = clone $projectstatic; + +if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; +} + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto); + + print '
    '; + print ''; + + if ($confOrBooth->id > 0) { + print ''; + } + + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + // Set some default values + //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
    '."\n"; + + print dol_get_fiche_end(); + + print '
    '; + print ''; + print '  '; + print ''; // Cancel for create does not post form if we don't know the backtopage + print '
    '; + + print '
    '; + + //dol_set_focus('input[name="ref"]'); +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("ConferenceOrBoothAttendee"), '', 'object_'.$object->picto); + + print '
    '; + print ''; + print ''; + print ''; + if ($confOrBooth->id > 0) { + print ''; + } + if ($object->fk_actioncomm > 0) { + print ''; + } + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; + print '   '; + print '
    '; + + print '
    '; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $res = $object->fetch_optionals(); + + $head = conferenceorboothattendeePrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteConferenceOrBoothAttendee'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') { + $formquestion = array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project') . ' '; + if ($permissiontoadd) { + //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ': '.$proj->getNomUrl(); + } else { + $morehtmlref .= ''; + } + } + }*/ + $morehtmlref .= '
    '; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + + /* + * Lines + */ + + if (!empty($object->table_element_line)) { + // Show object lines + $result = $object->getLinesArray(); + + print '
    + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
    '; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + 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 (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
    '; + } + print '
    '; + + print "
    \n"; + } + + + // Buttons for actions + + if ($action != 'presend' && $action != 'editline') { + print '
    '."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + // Send + if (empty($user->socid)) { + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle'); + } + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&conforboothid='.$confOrBooth->id.'&action=edit', '', $permissiontoadd); + + // Clone + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); + + /* + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ENABLED) { + print ''.$langs->trans("Disable").''."\n"; + } else { + print ''.$langs->trans("Enable").''."\n"; + } + } + if ($permissiontoadd) { + if ($object->status == $object::STATUS_VALIDATED) { + print ''.$langs->trans("Cancel").''."\n"; + } else { + print ''.$langs->trans("Re-Open").''."\n"; + } + } + */ + + // Delete (need delete permission, or if draft, just need create/modify permission) + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + } + print '
    '."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
    '; + print ''; // ancre + + $includedocgeneration = 0; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->eventorganization->conferenceorboothattendee->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->eventorganization->conferenceorboothattendee->write; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('eventorganization:ConferenceOrBoothAttendee', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('conferenceorboothattendee')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
    '; + + print '
    '; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'conferenceorboothattendee'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->eventorganization->dir_output; + $trackid = 'conferenceorboothattendee'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php new file mode 100644 index 00000000000..0505f6c7461 --- /dev/null +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -0,0 +1,868 @@ + + * Copyright (C) 2021 Florian Henry + * + * 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 conferenceorboothattendee_list.php + * \ingroup eventorganization + * \brief List page for conferenceorboothattendee + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; +if ($conf->categorie->enabled) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} + +// load eventorganization libraries +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + +// for other modules +//dol_include_once('/othermodule/class/otherobject.class.php'); + +// Load translation files required by the page +$langs->loadLangs(array("eventorganization", "other")); + +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothattendeelist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id', 'int'); +$conf_or_booth_id = GETPOST('conforboothid', 'int'); + +$withproject = GETPOST('withproject', 'int'); +$project_ref = GETPOST('project_ref', 'alpha'); + +$withProjectUrl=''; + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical objects +$object = new ConferenceOrBoothAttendee($db); +$extrafields = new ExtraFields($db); +$projectstatic = new Project($db); +$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('conferenceorboothattendeelist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Initialize array of search criterias +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } +} + +// Definition of array of fields for columns +$arrayfields = array(); +foreach ($object->fields as $key => $val) { + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) { + $visible = (int) dol_eval($val['visible'], 1); + $arrayfields['t.'.$key] = array( + 'label'=>$val['label'], + 'checked'=>(($visible < 0) ? 0 : 1), + 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=>$val['help'] + ); + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + +$permissiontoread = $user->rights->eventorganization->read; +$permissiontoadd = $user->rights->eventorganization->write; +$permissiontodelete = $user->rights->eventorganization->delete; + +// Security check +if (empty($conf->eventorganization->enabled)) { + accessforbidden('Module not enabled'); +} +$socid = 0; +if ($user->socid > 0) { // Protection if external user + //$socid = $user->socid; + accessforbidden(); +} +$result = restrictedArea($user, 'eventorganization'); +if (!$permissiontoread) accessforbidden(); + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'ConferenceOrBoothAttendee'; + $objectlabel = 'ConferenceOrBoothAttendee'; + $uploaddir = $conf->eventorganization->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * View + */ + +$form = new Form($db); + +$now = dol_now(); +$confOrBooth = new ConferenceOrBooth($db); +if ($conf_or_booth_id > 0) { + $result = $confOrBooth->fetch($conf_or_booth_id); + if ($result < 0) { + setEventMessages(null, $confOrBooth->errors, 'errors'); + } +} + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +$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.', ' : ''); + } +} +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".$confOrBooth->id; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +} +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if (array_key_exists($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0)) { + if ($search[$key] == '-1' || $search[$key] === '0') { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } + } + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} +//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + $page = 0; + $offset = 0; + } +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { + $num = $nbtotalofrecords; +} else { + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Direct jump if only one record found +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".dol_buildpath('/eventorganization/conferenceorboothattendee_card.php', 1).'?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +//$help_url="EN:Module_ConferenceOrBoothAttendee|FR:Module_ConferenceOrBoothAttendee_FR|ES:Módulo_ConferenceOrBoothAttendee"; +$help_url = ''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")); +$morejs = array(); +$morecss = array(); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); + +if ($confOrBooth->id > 0) { + $result = $projectstatic->fetch($confOrBooth->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $withProjectUrl=''; + $object->project = clone $projectstatic; + + if (!empty($withproject)) { + // Tabs for project + $tab = 'eventorganisation'; + $withProjectUrl="&withproject=1"; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
    '; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) { + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
    '; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ''; + print ''; + } + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
    '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
    '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); + } + print '
    '.$langs->trans("Visibility").''; + if ($projectstatic->public) { + print $langs->trans('SharedProject'); + } else { + print $langs->trans('PrivateProject'); + } + print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) { + print img_warning("Late"); + } + print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print '
    '; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
    '.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
    '.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); + $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); + print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); + print ''; + print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '; + print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); + print "
    '.$langs->trans("EventOrganizationICSLink").''; + print ''; + print "
    '; + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); + + print '
    '; + } + + $head = conferenceorboothPrepareHead($confOrBooth, $withproject); + print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + + + //$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; + $title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id; + + $object_evt=$object; + $object=$confOrBooth; + + dol_banner_tab($object, 'ref', '', 0); + + print '
    '; + print '
    '; + print '
    '; + print ''."\n"; + + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + $object=$object_evt; + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + print dol_get_fiche_end(); +} + +$arrayofselected = is_array($toselect) ? $toselect : array(); + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } +} +if ($confOrBooth->id > 0) { + $param .= '&conforboothid='.urlencode($confOrBooth->id).$withProjectUrl; +} + +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>$langs->trans("Validate"), + //'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), +); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +print '
    '."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendConferenceOrBoothAttendeeRef"; +$modelmail = "conferenceorboothattendee"; +$objecttmp = new ConferenceOrBoothAttendee($db); +$trackid = 'xxxx'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
    '.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
    '; +} + +$moreforfilter = ''; +/*$moreforfilter.='
    '; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
    ';*/ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
    '; + print $moreforfilter; + print '
    '; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + } +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine = 0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } + } +} + + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < ($limit ? min($num, $limit) : $num)) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + + // Show here line of result + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'ref') { + print $object->getNomUrl(1, (!empty($withproject)?'conforboothidproject':'conforboothid')); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + $totalarray['val']['t.'.$key] += $object->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} + + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
    '; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { + print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); + } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print ''; + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
    '; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
    '; + print '
    '; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
    '; + } + print '
    '; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
    '; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
    '.$langs->trans("NoRecordFound").'
    '."\n"; +print '
    '."\n"; + +print '
    '."\n"; + +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_eventorganization', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/eventorganization/conferenceorbooth_note.php b/htdocs/eventorganization/conferenceorboothattendee_note.php similarity index 90% rename from htdocs/eventorganization/conferenceorbooth_note.php rename to htdocs/eventorganization/conferenceorboothattendee_note.php index 634877d82fe..46620112311 100644 --- a/htdocs/eventorganization/conferenceorbooth_note.php +++ b/htdocs/eventorganization/conferenceorboothattendee_note.php @@ -17,9 +17,9 @@ */ /** - * \file conferenceorbooth_note.php + * \file conferenceorboothattendee_note.php * \ingroup eventorganization - * \brief Tab for notes on ConferenceOrBooth + * \brief Tab for notes on ConferenceOrBoothAttendee */ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db @@ -74,8 +74,8 @@ if (!$res) { die("Include of main fails"); } -dol_include_once('/eventorganization/class/conferenceorbooth.class.php'); -dol_include_once('/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'); +dol_include_once('/eventorganization/class/conferenceorboothattendee.class.php'); +dol_include_once('/eventorganization/lib/eventorganization_conferenceorboothattendee.lib.php'); // Load translation files required by the page $langs->loadLangs(array("eventorganization@eventorganization", "companies")); @@ -88,10 +88,10 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object = new ConferenceOrBooth($db); +$object = new ConferenceOrBoothAttendee($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothnote', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('conferenceorboothattendeenote', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -106,15 +106,9 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->eventorganization->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_addupdatedelete.inc.php -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); /* @@ -132,18 +126,18 @@ $form = new Form($db); //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; $help_url = ''; -llxHeader('', $langs->trans('ConferenceOrBooth'), $help_url); +llxHeader('', $langs->trans('ConferenceOrBoothAttendee'), $help_url); if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); - $head = conferenceorboothPrepareHead($object); + $head = conferenceorboothattendeePrepareHead($object); - print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBooth"), -1, $object->picto); + print dol_get_fiche_head($head, 'note', $langs->trans("ConferenceOrBoothAttendee"), -1, $object->picto); // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; /* diff --git a/htdocs/eventorganization/img/object_conferenceorboothattendee.png b/htdocs/eventorganization/img/object_conferenceorboothattendee.png new file mode 100644 index 00000000000..b421fe3c9e0 Binary files /dev/null and b/htdocs/eventorganization/img/object_conferenceorboothattendee.png differ diff --git a/htdocs/eventorganization/img/object_ttruc.png b/htdocs/eventorganization/img/object_ttruc.png new file mode 100644 index 00000000000..b421fe3c9e0 Binary files /dev/null and b/htdocs/eventorganization/img/object_ttruc.png differ diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php index 541915fc953..7d6339a2ed0 100644 --- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php +++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php @@ -25,28 +25,65 @@ * Prepare array of tabs for ConferenceOrBooth * * @param ConferenceOrBooth $object ConferenceOrBooth + * @param int $with_project Add project id to URL * @return array Array of tabs */ -function conferenceorboothPrepareHead($object) +function conferenceorboothPrepareHead($object, $with_project = 0) { global $db, $langs, $conf; - $langs->load("eventorganization@eventorganization"); + $langs->load("eventorganization"); $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id; + $withProjectUrl=''; + if ($with_project>0) { + $withProjectUrl="&withproject=1"; + } + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_card.php", 1).'?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_contact.php", 1).'?id='.$object->id.$withProjectUrl; + $head[$h][1] = $langs->trans("ContactsAddresses"); + $head[$h][2] = 'contact'; + $h++; + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?conforboothid='.$object->id.$withProjectUrl; + $head[$h][1] = $langs->trans("Attendees"); + $head[$h][2] = 'attendees'; + // Enable caching of conf or booth count attendees + $nbAttendees = 0; + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_attendees_conferenceorbooth_'.$object->id; + $dataretrieved = dol_getcache($cachekey); + if (!is_null($dataretrieved)) { + $nbAttendees = $dataretrieved; + } else { + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + $attendees=new ConferenceOrBoothAttendee($db); + $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$object->id)); + if (!is_array($result) && $result<0) { + setEventMessages($attendees->error, $attendees->errors, 'errors'); + } else { + $nbAttendees = count($result); + } + dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result. + } + if ($nbAttendees > 0) { + $head[$h][1] .= ''.$nbAttendees.''; + } + $h++; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $upload_dir = $conf->eventorganization->dir_output."/conferenceorbooth/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id; + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id.$withProjectUrl; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles + $nbLinks) > 0) { $head[$h][1] .= ''.($nbFiles + $nbLinks).''; @@ -68,3 +105,33 @@ function conferenceorboothPrepareHead($object) return $head; } + + +/** + * Prepare array of tabs for ConferenceOrBoothAttendees + * + * @param ConferenceOrBoothAttendee $object ConferenceOrBoothAttendee + * @return array Array of tabs + */ +function conferenceorboothattendeePrepareHead($object) +{ + global $db, $langs, $conf; + + $langs->load("eventorganization"); + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_card.php", 1).'?id='.$object->id.'&conforboothid='.$object->fk_actioncomm; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + //TODO : Note and docuement + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove'); + + return $head; +} diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7e10b5b5f1f..675372273f0 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -130,6 +130,7 @@ $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_d if ($user->socid) { $socid = $user->socid; } + $result = restrictedArea($user, 'expedition', $object->id, ''); @@ -281,8 +282,8 @@ if (empty($reshook)) { $totalqty += $subtotalqty; } else { - // No detail were provided for lots - if (!empty($_POST[$qty])) { + // No detail were provided for lots, so if a qty was provided, we can show an error. + if (GETPOST($qty)) { // We try to set an amount // Case we dont use the list of available qty for each warehouse/lot // GUI does not allow this yet @@ -1035,7 +1036,7 @@ if ($action == 'create') { print ''.$langs->trans("QtyShipped").''; print ''.$langs->trans("QtyToShip"); if (empty($conf->productbatch->enabled)) { - print '
    '.$langs->trans("Fill").''; + print '
    '.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').$langs->trans("Fill").''; print ' / '; } else { print '
    '; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 42564f7dd72..961790cc3bd 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -103,6 +103,10 @@ class Shipments extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -129,7 +133,7 @@ class Shipments extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c251fdaf7cd..ed6f7a25eaf 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2682,7 +2682,7 @@ class ExpeditionLigne extends CommonObjectLine { $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; - $sql .= ' WHERE ed.rowid = '.$rowid; + $sql .= ' WHERE ed.rowid = '.((int) $rowid); $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index 50382cef164..d25c7b52098 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -77,10 +77,10 @@ class ExpeditionStats extends Stats $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($this->socid) { - $this->where .= " AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".((int) $this->socid); } if ($this->userid > 0) { - $this->where .= ' AND c.fk_user_author = '.$this->userid; + $this->where .= ' AND c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 174b97b4a7e..cd9febc685d 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -96,10 +96,10 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { } } elseif ($action == 'swapstatut' && $user->rights->expedition->creer) { // bascule du statut d'un contact - $result = $objectsrc->swapContactStatus(GETPOST('ligne')); + $result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $user->rights->expedition->creer) { // Efface un contact - $result = $objectsrc->delete_contact(GETPOST("lineid")); + $result = $objectsrc->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -121,7 +121,10 @@ elseif ($action == 'setaddress' && $user->rights->expedition->creer) * View */ -llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes'); + +$help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen'; + +llxHeader('', $langs->trans('Order'), $help_url); $form = new Form($db); $formcompany = new FormCompany($db); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 327e9a030e0..365964857a2 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -313,13 +313,13 @@ if ($search_state) { $sql .= natural_search("state.nom", $search_state); } if ($search_country) { - $sql .= " AND s.fk_pays IN (".$search_country.')'; + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } if ($search_tracking) { $sql .= natural_search("e.tracking_number", $search_tracking); } if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; } if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; @@ -511,31 +511,37 @@ $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $tmptitle = $langs->trans('IncludingProductWithTag'); + $moreforfilter .= img_picto($tmptitle, 'category'); + //$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + //$moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= $formother->select_categories(Categorie::TYPE_PRODUCT, $search_product_category, 'parent', 1, $tmptitle); + $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category'); + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 809b4803ff5..cba2e14cf74 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -65,6 +65,7 @@ if (!empty($user->socid)) { $result = restrictedArea($user, 'commande', $id); $object = new Commande($db); +$shipment = new Expedition($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -77,7 +78,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'expedition', $object->id, ''); + +$result = restrictedArea($user, 'expedition', 0, ''); // We use 0 for id, because there is no particular shipment on this tab, only id of order is known @@ -94,13 +96,11 @@ if ($reshook < 0) { if (empty($reshook)) { // Categorisation dans projet if ($action == 'classin') { - $object = new Commande($db); $object->fetch($id); $object->setProject(GETPOST('projectid', 'int')); } if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes') { - $object = new Commande($db); $object->fetch($id); $result = $object->cloture($user); } elseif ($action == 'setref_client' && $user->rights->commande->creer) { @@ -132,7 +132,6 @@ if (empty($reshook)) { } */ if ($action == 'setmode' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) { @@ -141,7 +140,6 @@ if (empty($reshook)) { } if ($action == 'setavailability' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->availability(GETPOST('availability_id')); if ($result < 0) { @@ -150,7 +148,6 @@ if (empty($reshook)) { } if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) { @@ -159,7 +156,6 @@ if (empty($reshook)) { } if ($action == 'setconditions' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { @@ -175,7 +171,6 @@ if (empty($reshook)) { // shipping method if ($action == 'setshippingmethod' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { @@ -185,7 +180,6 @@ if (empty($reshook)) { // warehouse if ($action == 'setwarehouse' && $user->rights->commande->creer) { - $object = new Commande($db); $object->fetch($id); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) { diff --git a/htdocs/expensereport/ajax/ajaxik.php b/htdocs/expensereport/ajax/ajaxik.php index 72c38959ef8..c2cc8345671 100644 --- a/htdocs/expensereport/ajax/ajaxik.php +++ b/htdocs/expensereport/ajax/ajaxik.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/expensereport/ajax/ajaxprojet.php + * \file htdocs/expensereport/ajax/ajaxik.php * \ingroup expensereport * \brief File to return Ajax response on third parties request */ @@ -49,19 +49,19 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php' // Load translation files required by the page $langs->loadlangs(array('errors', 'trips')); +$fk_expense = GETPOST('fk_expense', 'int'); +$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); + +// Security check +$result = restrictedArea($user, 'expensereport', $fk_expense, 'expensereport'); + + /* * View */ top_httphead(); - -dol_syslog(join(',', $_POST)); - -$fk_expense = GETPOST('fk_expense'); -$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); - - if (empty($fk_expense) || $fk_expense < 0) { echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorBadValueForParameter', $fk_expense, 'fk_expense'))); } elseif (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) { @@ -82,7 +82,7 @@ if (empty($fk_expense) || $fk_expense < 0) { echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range)); } else { $ikoffset = price($range->ikoffset, 0, $langs, 1, -1, -1, $conf->currency); - echo json_encode(array('up' => $range->coef, 'ikoffset' => $range->ikoffset, 'title' => $langs->transnoentitiesnoconv('ExpenseRangeOffset', $offset), 'comment' => 'offset should be apply on addline or updateline')); + echo json_encode(array('up' => $range->coef, 'ikoffset' => $range->ikoffset, 'title' => $langs->transnoentitiesnoconv('ExpenseRangeOffset', $ikoffset), 'comment' => 'offset should be applied on addline or updateline')); } } } diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php deleted file mode 100644 index 8549d62fa62..00000000000 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ /dev/null @@ -1,95 +0,0 @@ - - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2007-2010 Laurent Destailleur - * Copyright (C) 2010 Cyrille de Lambert - * - * 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/expensereport/ajax/ajaxprojet.php - * \ingroup expensereport - * \brief File to return Ajax response on third parties request - */ - -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', 1); // Disables token renewal -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} - -$res = 0; -require '../../main.inc.php'; - - -/* - * View - */ - -// Ajout directives pour resoudre bug IE -//header('Cache-Control: Public, must-revalidate'); -//header('Pragma: public'); - -//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. -top_httphead(); - -//print ''."\n"; - -dol_syslog(join(',', $_GET)); - - -// Generation liste des projets -if (GETPOST('fk_projet') != '') { - $return_arr = array(); - - $sql = "SELECT p.rowid, p.ref, p.title, s.nom"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!empty($_GET["fk_projet"])) { - $sql .= " WHERE p.ref LIKE '%".$db->escape($_GET["fk_projet"])."%' OR p.title LIKE '%".$db->escape($_GET["fk_projet"])."%' OR s.nom LIKE '%".$db->escape($_GET["fk_projet"])."%'"; // Add other filters - } - $sql .= " ORDER BY p.ref ASC"; - - $resql = $db->query($sql); - if ($resql) { - while ($row = $db->fetch_array($resql)) { - $label = $row['ref'].' - '.$row['title']; - $row_array['label'] = $label; - $row_array['value'] = $label; - $row_array['key'] = $row['rowid']; - - array_push($return_arr, $row_array); - } - - echo json_encode($return_arr); - } else { - echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); - } -} else { - echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); -} diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 020c34dc0c6..a4c565bc1be 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -67,14 +67,6 @@ $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('socid_id', $childids = $user->getAllChildIds(1); -// Security check -$id = GETPOST("id", 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'expensereport', $id, 'expensereport'); - - // Hack to use expensereport dir $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; @@ -111,10 +103,8 @@ $permissionnote = $user->rights->expensereport->creer; // Used by the include of $permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php $permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); - if ($object->id > 0) { // Check current user can read this expense report $canread = 0; @@ -129,6 +119,13 @@ if ($object->id > 0) { } } +// Security check +$id = GETPOST("id", 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'expensereport', $object->id, 'expensereport'); + /* * Actions @@ -1194,7 +1191,7 @@ if (empty($reshook)) { } $object->update_totaux_del($object_ligne->total_ht, $object_ligne->total_tva); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int')); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -2257,7 +2254,7 @@ if ($action == 'create') { // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"]) ? $_POST["vatrate"] : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 98da4534e0c..7321cb40625 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -99,6 +99,10 @@ class ExpenseReports extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $societe param is ignored and replaced by user's socid @@ -108,7 +112,7 @@ class ExpenseReports extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t"; $sql .= ' WHERE t.entity IN ('.getEntity('expensereport').')'; if ($user_ids) { - $sql .= " AND t.fk_user_author IN (".$user_ids.")"; + $sql .= " AND t.fk_user_author IN (".$this->db->sanitize($user_ids).")"; } // Add sql filters @@ -164,6 +168,7 @@ class ExpenseReports extends DolibarrApi if (!DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); } + // Check mandatory fields $result = $this->_validate($request_data); @@ -427,6 +432,7 @@ class ExpenseReports extends DolibarrApi if (!DolibarrApiAccess::$user->rights->expensereport->supprimer) { throw new RestException(401); } + $result = $this->expensereport->fetch($id); if (!$result) { throw new RestException(404, 'Expense Report not found'); @@ -469,6 +475,7 @@ class ExpenseReports extends DolibarrApi if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); } + $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 89178693a43..8ec99aa1007 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -663,7 +663,7 @@ class ExpenseReport extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."expensereport"; $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", paid=1"; - $sql .= " WHERE rowid = ".$id." AND fk_statut = ".self::STATUS_APPROVED; + $sql .= " WHERE rowid = ".((int) $id)." AND fk_statut = ".self::STATUS_APPROVED; dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -880,7 +880,7 @@ class ExpenseReport extends CommonObject if ($user->rights->expensereport->lire) { $sql = "SELECT de.fk_expensereport, de.date, de.comments, de.total_ht, de.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as de"; - $sql .= " WHERE de.fk_projet = ".$projectid; + $sql .= " WHERE de.fk_projet = ".((int) $projectid); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -973,7 +973,7 @@ class ExpenseReport extends CommonObject { $sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt'; - $sql .= ' WHERE tt.'.$this->fk_element.' = '.$id; + $sql .= ' WHERE tt.'.$this->fk_element.' = '.((int) $id); $total_ht = 0; $total_tva = 0; $total_ttc = 0; @@ -1117,8 +1117,8 @@ class ExpenseReport extends CommonObject // Delete extrafields of lines and lines if (!$error && !empty($this->table_element_line)) { $tabletodelete = $this->table_element_line; - //$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; + //$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".((int) $this->id).")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".((int) $this->id); if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); @@ -1154,7 +1154,7 @@ class ExpenseReport extends CommonObject // Delete main record if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".((int) $this->id); $res = $this->db->query($sql); if (!$res) { $error++; @@ -1384,7 +1384,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; + $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".((int) $fuser->id).","; $sql .= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql .= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) { @@ -1434,7 +1434,7 @@ class ExpenseReport extends CommonObject // date de refus if ($this->status != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; + $sql .= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".((int) $fuser->id).","; $sql .= " date_refuse='".$this->db->idate($now)."',"; $sql .= " detail_refuse='".$this->db->escape($details)."',"; $sql .= " fk_user_approve = NULL"; @@ -1558,7 +1558,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; + $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".((int) $fuser->id); $sql .= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql .= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql .= ' WHERE rowid = '.$this->id; @@ -2124,7 +2124,7 @@ class ExpenseReport extends CommonObject // Select des infos sur le type fees $sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; - $sql .= " WHERE c.id = ".$type_fees_id; + $sql .= " WHERE c.id = ".((int) $type_fees_id); $resql = $this->db->query($sql); if ($resql) { $objp_fees = $this->db->fetch_object($resql); @@ -2136,7 +2136,7 @@ class ExpenseReport extends CommonObject // Select des informations du projet $sql = "SELECT p.ref as ref_projet, p.title as title_projet"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.rowid = ".$projet_id; + $sql .= " WHERE p.rowid = ".((int) $projet_id); $resql = $this->db->query($sql); if ($resql) { $objp_projet = $this->db->fetch_object($resql); @@ -2173,7 +2173,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid = '.$rowid; + $sql .= ' WHERE rowid = '.((int) $rowid); dol_syslog(get_class($this)."::deleteline sql=".$sql); $result = $this->db->query($sql); @@ -2331,7 +2331,7 @@ class ExpenseReport extends CommonObject $ret = array(); $sql = "SELECT id, code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -2367,8 +2367,8 @@ class ExpenseReport extends CommonObject $sql .= " AND ex.entity IN (".getEntity('expensereport').")"; if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); - $sql .= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; - $sql .= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; + $sql .= " AND (ex.fk_user_author IN (".$this->db->sanitize(join(',', $userchildids)).")"; + $sql .= " OR ex.fk_user_validator IN (".$this->db->sanitize(join(',', $userchildids))."))"; } $resql = $this->db->query($sql); @@ -2414,8 +2414,8 @@ class ExpenseReport extends CommonObject $sql .= " AND ex.entity IN (".getEntity('expensereport').")"; if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); - $sql .= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; - $sql .= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; + $sql .= " AND (ex.fk_user_author IN (".$this->db->sanitize(join(',', $userchildids)).")"; + $sql .= " OR ex.fk_user_validator IN (".$this->db->sanitize(join(',', $userchildids))."))"; } $resql = $this->db->query($sql); @@ -2495,7 +2495,7 @@ class ExpenseReport extends CommonObject $type = 'expense_report'; - $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id; + $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -2628,7 +2628,7 @@ class ExpenseReportLine $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; // Sometimes type of expense report has been removed, so we use a left join here. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; - $sql .= ' WHERE fde.rowid = '.$rowid; + $sql .= ' WHERE fde.rowid = '.((int) $rowid); $result = $this->db->query($sql); @@ -2757,7 +2757,7 @@ class ExpenseReportLine $sql = 'SELECT SUM(d.total_ttc) as total_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det d'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport e ON (d.fk_expensereport = e.rowid)'; - $sql .= ' WHERE e.fk_user_author = '.$fk_user; + $sql .= ' WHERE e.fk_user_author = '.((int) $fk_user); if (!empty($this->id)) { $sql .= ' AND d.rowid <> '.$this->id; } diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php index 18a0503cdd7..6c6623c30c7 100644 --- a/htdocs/expensereport/class/expensereport_ik.class.php +++ b/htdocs/expensereport/class/expensereport_ik.class.php @@ -137,7 +137,7 @@ class ExpenseReportIk extends CoreObject * @param int $fk_c_exp_tax_cat category * @return boolean|array */ - public static function getRangeByUser(User $userauthor, $fk_c_exp_tax_cat) + public static function getRangeByUser(User $userauthor, int $fk_c_exp_tax_cat) { $default_range = (int) $userauthor->default_range; // if not defined, then 0 $ranges = self::getRangesByCategory($fk_c_exp_tax_cat); @@ -157,23 +157,24 @@ class ExpenseReportIk extends CoreObject * @param int $active active * @return array */ - public static function getRangesByCategory($fk_c_exp_tax_cat, $active = 1) + public static function getRangesByCategory(int $fk_c_exp_tax_cat, $active = 1) { global $db; $ranges = array(); + dol_syslog(get_called_class().'::getRangesByCategory for fk_c_exp_tax_cat='.$fk_c_exp_tax_cat, LOG_DEBUG); + $sql = 'SELECT r.rowid FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; if ($active) { $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; } - $sql .= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat; + $sql .= ' WHERE r.fk_c_exp_tax_cat = '.((int) $fk_c_exp_tax_cat); if ($active) { $sql .= ' AND r.active = 1 AND c.active = 1'; } $sql .= ' ORDER BY r.range_ik'; - dol_syslog(get_called_class().'::getRangesByCategory sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php index 4e4d1009750..653f030b6d2 100644 --- a/htdocs/expensereport/class/expensereport_rule.class.php +++ b/htdocs/expensereport/class/expensereport_rule.class.php @@ -167,7 +167,7 @@ class ExpenseReportRule extends CoreObject if ($fk_user > 0) { $sql .= ' AND (er.is_for_all = 1'; $sql .= ' OR er.fk_user = '.$fk_user; - $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )'; + $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.((int) $fk_user).') )'; } $sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user'; diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 3d627cbce8d..8f3574f2952 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -78,11 +78,11 @@ class ExpenseReportStats extends Stats if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { $childids = $user->getAllChildIds(); $childids[] = $user->id; - $this->where .= " AND e.fk_user_author IN (".(join(',', $childids)).")"; + $this->where .= " AND e.fk_user_author IN (".$this->db->sanitize(join(',', $childids)).")"; } if ($this->userid > 0) { - $this->where .= ' AND e.fk_user_author = '.$this->userid; + $this->where .= ' AND e.fk_user_author = '.((int) $this->userid); } } @@ -114,7 +114,7 @@ class ExpenseReportStats extends Stats { $sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".$year; + $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index c9cf0cdaf41..c673316d491 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -607,7 +607,7 @@ class PaymentExpenseReport extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 541c2c0738e..f9792d5b68c 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -91,7 +91,7 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { $childids = $user->getAllChildIds(); $childids[] = $user->id; - $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; + $sql .= " AND d.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n"; } $sql .= " GROUP BY tf.code, tf.label"; @@ -180,11 +180,11 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { $childids = $user->getAllChildIds(); $childids[] = $user->id; - $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; + $sql .= " AND d.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n"; } $sql .= ' AND d.entity IN ('.getEntity('expensereport').')'; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } if ($socid) { $sql .= " AND d.fk_user_author = ".$socid; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 35642ead0c4..51022f8c40b 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -290,12 +290,12 @@ if ($search_user != '' && $search_user >= 0) { } // Status if ($search_status != '' && $search_status >= 0) { - $sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; + $sql .= " AND d.fk_statut IN (".$db->sanitize($search_status).")"; } // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { - $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; + $sql .= " AND d.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n"; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 926559769b4..b7057af86fc 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -36,6 +36,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $amounts = array(); $accountid = GETPOST('accountid', 'int'); +$cancel = GETPOST('cancel'); // Security check $socid = 0; @@ -51,7 +52,7 @@ if ($user->socid > 0) { if ($action == 'add_payment') { $error = 0; - if ($_POST["cancel"]) { + if ($cancel) { $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id; header("Location: ".$loc); exit; @@ -64,9 +65,9 @@ if ($action == 'add_payment') { setEventMessages($expensereport->error, $expensereport->errors, 'errors'); } - $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); - if (!($_POST["fk_typepayment"] > 0)) { + if (!(GETPOST("fk_typepayment", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; } @@ -205,7 +206,7 @@ if ($action == 'create' || empty($action)) { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; - $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id; + $sql .= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".((int) $id); $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/externalsite/admin/index.html b/htdocs/externalsite/admin/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/externalsite/admin/externalsite.php b/htdocs/externalsite/admin/index.php similarity index 83% rename from htdocs/externalsite/admin/externalsite.php rename to htdocs/externalsite/admin/index.php index 47f0a3d57be..a9a41c5e555 100644 --- a/htdocs/externalsite/admin/externalsite.php +++ b/htdocs/externalsite/admin/index.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/externalsite/admin/externalsite.php + * \file htdocs/externalsite/admin/index.php * \ingroup externalsite - * \brief Page de configuration du module externalsite + * \brief Page to setup module external site */ if (!defined('NOSCANPOSTFORINJECTION')) { @@ -41,18 +41,24 @@ if (!$user->admin) { // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'externalsite')); -$def = array(); - $action = GETPOST('action', 'aZ09'); + +/* + * Actions + */ + // Sauvegardes parametres if ($action == 'update') { $i = 0; $db->begin(); - $label = GETPOST('EXTERNALSITE_LABEL', 'alpha'); - $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml'); + $label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml'); + + $exturl = GETPOST('EXTERNALSITE_URL', 'none'); + $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1); + $exturl = trim(dol_string_onlythesehtmlattributes($exturl)); $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity); @@ -77,7 +83,7 @@ $linkback = ''; -print $langs->trans("Module100Desc")."
    \n"; +print ''.$langs->trans("Module100Desc")."
    \n"; print '
    '; print '
    '; @@ -102,7 +108,12 @@ print ""; print ''; print ''.$langs->trans("ExternalSiteURL").""; print ''; print "http://localhost/myurl/"; print "
    https://wikipedia.org/"; diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index e687169fe50..b7280c2f4a4 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -83,17 +83,17 @@ $extrafields = new ExtraFields($db); $arrayfields = array( - 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 'f.fk_contrat'=>array('label'=>$langs->trans("Contract"), 'checked'=>1), - 'f.duree'=>array('label'=>$langs->trans("Duration"), 'checked'=>1), - 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), - 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), - 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), - 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), - 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'f.titre'=>array('label'=>"Ref", 'checked'=>1), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 'f.fk_contrat'=>array('label'=>"Contract", 'checked'=>1), + 'f.duree'=>array('label'=>"Duration", 'checked'=>1), + 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>1), + 'f.frequency'=>array('label'=>"RecurringInvoiceTemplate", 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>"NbOfGenerationDoneShort", 'checked'=>1), + 'f.date_last_gen'=>array('label'=>"DateLastGeneration", 'checked'=>1), + 'f.date_when'=>array('label'=>"NextDateToExecution", 'checked'=>1), + 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), ); @@ -580,15 +580,13 @@ if ($action == 'create') { print '
    '; print '
    '; - print ''; - $title = $langs->trans("Recurrence"); print load_fiche_titre($title, '', 'calendar'); print '
    '; // if "frequency" is empty or = 0, the reccurence is disabled - print ''; - - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= ''; - - $i++; - } - - $result .= '
    '; + print '
    '; print ''; @@ -663,7 +661,7 @@ if ($action == 'create') { print '
    '; print $langs->trans('Frequency'); print '
    '; // Nb of generation already done - print ''; + print ''; print ''; @@ -817,7 +815,7 @@ if ($action == 'create') { print_liste_field_titre("Duration", $_SERVER['PHP_SELF'], 'f.duree', '', '', 'width="50px"', $sortfield, $sortorder, 'right '); // Recurring or not print_liste_field_titre("Frequency", $_SERVER['PHP_SELF'], "f.frequency", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); - print_liste_field_titre("NbOfGenerationDone", $_SERVER['PHP_SELF'], "f.nb_gen_done", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); + print_liste_field_titre("NbOfGenerationDoneShort", $_SERVER['PHP_SELF'], "f.nb_gen_done", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateLastGeneration", $_SERVER['PHP_SELF'], "f.date_last_gen", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print_liste_field_titre("NextDateToIntervention", $_SERVER['PHP_SELF'], "f.date_when", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print ''; @@ -908,7 +906,7 @@ if ($action == 'create') { } } } else { - print ''; + print ''; } print "
    '.$langs->trans("NbOfGenerationDone").'
    '.$langs->trans("NbOfGenerationOfRecordDone").''; print $object->nb_gen_done ? $object->nb_gen_done : '0'; print '
    '.$langs->trans("NoneF").'
    '.$langs->trans("None").'
    "; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index ebc884eb033..88c5a1cefc0 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -875,9 +875,9 @@ if ($action == 'create') { print '
    '.$langs->trans("Project").''; /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty if ($societe->fournisseur==1) - $numprojet=select_projects(-1,$_POST["projectid"],'projectid'); + $numprojet=select_projects(-1, GETPOST("projectid", 'int'), 'projectid'); else - $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); + $numprojet=select_projects($societe->id, GETPOST("projectid", 'int'), 'projectid'); */ $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid'); if ($numprojet == 0) { diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index a5ba127a54d..423bb31f348 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -110,6 +110,10 @@ class Interventions extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -136,14 +140,14 @@ class Interventions extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Add sql filters if ($sqlfilters) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f5602bc5abb..1fef1ed7c03 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1438,7 +1438,7 @@ class FichinterLigne extends CommonObjectLine $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,'; $sql .= ' ft.date as datei'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; - $sql .= ' WHERE ft.rowid = '.$rowid; + $sql .= ' WHERE ft.rowid = '.((int) $rowid); dol_syslog("FichinterLigne::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -1622,7 +1622,7 @@ class FichinterLigne extends CommonObjectLine $sql = "SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee "; $sql .= " FROM ".MAIN_DB_PREFIX."fichinterdet"; - $sql .= " WHERE fk_fichinter=".$this->fk_fichinter; + $sql .= " WHERE fk_fichinter=".((int) $this->fk_fichinter); dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1634,10 +1634,10 @@ class FichinterLigne extends CommonObjectLine } $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; - $sql .= " SET duree = ".$total_duration; + $sql .= " SET duree = ".((int) $total_duration); $sql .= " , dateo = ".(!empty($obj->dateo) ? "'".$this->db->idate($obj->dateo)."'" : "null"); $sql .= " , datee = ".(!empty($obj->datee) ? "'".$this->db->idate($obj->datee)."'" : "null"); - $sql .= " WHERE rowid = ".$this->fk_fichinter; + $sql .= " WHERE rowid = ".((int) $this->fk_fichinter); dol_syslog("FichinterLigne::update_total", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 8ed842a70c9..4fe35c32a2c 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -434,10 +434,10 @@ class FichinterRec extends Fichinter $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet_rec WHERE fk_fichinter = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet_rec WHERE fk_fichinter = ".((int) $rowid); dol_syslog($sql); if ($this->db->query($sql)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter_rec WHERE rowid = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter_rec WHERE rowid = ".((int) $rowid); dol_syslog($sql); if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); @@ -784,8 +784,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET nb_gen_max = '.((int) $nb); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) { @@ -811,8 +811,8 @@ class FichinterRec extends Fichinter } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql .= ' SET auto_validate = '.((int) $validate); + $sql .= ' WHERE rowid = '.((int) $this->id); dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index a0d22cf1e2a..297aeca7760 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -73,15 +73,15 @@ class FichinterStats extends Stats //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled } if (!$user->rights->societe->client->voir && !$this->socid) { - $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')'; if ($this->socid) { - $this->where .= " AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".((int) $this->socid); } if ($this->userid > 0) { - $this->where .= ' AND c.fk_user_author = '.$this->userid; + $this->where .= ' AND c.fk_user_author = '.((int) $this->userid); } } diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 863463e8d0e..52bde29e660 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -129,7 +129,7 @@ if ($resql) { } $db->free($resql); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
    '; print ''; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index aff0ebad349..e479b1430a1 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -298,7 +298,7 @@ if (!defined('NUSOAP_PATH')) { define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/')); } if (!defined('PHPEXCELNEW_PATH')) { - define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); + define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); } if (!defined('ODTPHP_PATH')) { define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/')); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 6db5ba5cad3..294adb50146 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -507,7 +507,7 @@ if ($object->id > 0) { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); //Query from product/liste.php - $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,'; + $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity, p.tosell as status, p.tobuy as status_buy, p.tobatch as status_batch,'; $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; @@ -539,6 +539,9 @@ if ($object->id > 0) { $productstatic->label = $objp->label; $productstatic->type = $objp->fk_product_type; $productstatic->entity = $objp->entity; + $productstatic->status = $objp->status; + $productstatic->status_buy = $objp->status_buy; + $productstatic->status_batch = $objp->status_batch; print ''; print ''; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $i++; - $total += $obj->total_ttc; - } - - if ($num > $nbofloop) { - $result .= ''; - $result .= ''; - $result .= ''; - } elseif ($total > 0) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= '
    '; @@ -654,7 +657,7 @@ if ($object->id > 0) { $sql2 .= " AND c.fk_statut IN (".$db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php } else { // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY - $sql2 .= " AND c.fk_statut IN (".$db->sanitize($db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)).")"; + $sql2 .= " AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).")"; } $sql2 .= " AND c.billed = 0"; // Find order that are not already invoiced diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 953092120e4..b9b541f0229 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -102,6 +102,10 @@ class SupplierInvoices extends DolibarrApi { global $db; + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -130,7 +134,7 @@ class SupplierInvoices extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index d75abb17e90..a92fe61db24 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -72,7 +72,7 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -101,6 +101,10 @@ class SupplierOrders extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -131,10 +135,10 @@ class SupplierOrders extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if (!empty($product_ids)) { - $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$product_ids.")"; + $sql .= " AND cd.fk_commande = t.rowid AND cd.fk_product IN (".$this->db->sanitize($product_ids).")"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale @@ -265,7 +269,7 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -299,7 +303,7 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -344,7 +348,7 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Order not found'); } - if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1c9ed333fae..5f88a1a3f1e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1157,7 +1157,7 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".$statut; + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = ".((int) $statut); $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::cancel", LOG_DEBUG); if ($this->db->query($sql)) { @@ -2306,7 +2306,7 @@ class CommandeFournisseur extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql .= " SET fk_statut = ".$statut; + $sql .= " SET fk_statut = ".((int) $statut); $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut IN (".self::STATUS_ORDERSENT.",".self::STATUS_RECEIVED_PARTIALLY.")"; // Process running or Partially received @@ -2708,7 +2708,7 @@ class CommandeFournisseur extends CommonOrder if ($qty < $this->line->packaging) { $qty = $this->line->packaging; } else { - if (($qty % $this->line->packaging) > 0) { + if (! empty($this->line->packaging) && ($qty % $this->line->packaging) > 0) { $coeff = intval($qty / $this->line->packaging) + 1; $qty = $this->line->packaging * $coeff; setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); @@ -3495,7 +3495,7 @@ class CommandeFournisseurLigne extends CommonOrderLine if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn"; } - $sql .= ' WHERE cd.rowid = '.$rowid; + $sql .= ' WHERE cd.rowid = '.((int) $rowid); $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 21c36ced633..0f8b8341a3d 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -674,8 +674,10 @@ class CommandeFournisseurDispatch extends CommonObject $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } elseif ($key == 't.datec' || $key == 't.tms' || $key == 't.eatby' || $key == 't.sellby' || $key == 't.batch') { $sqlwhere [] = $key.' = \''.$this->db->escape($value).'\''; + } elseif ($key == 'qty') { + $sqlwhere [] = $key.' = '.((float) $value); } else { - $sqlwhere [] = $key.' = '.$this->db->escape($value); + $sqlwhere [] = $key.' = '.((int) $value); } } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dccb3901069..4a19e4bdc81 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2015 Bahfir Abbes * Copyright (C) 2015-2019 Ferran Marcet - * Copyright (C) 2016 Alexandre Spangaro + * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2020 Frédéric France * @@ -34,6 +34,8 @@ * \brief File of class to manage suppliers invoices */ +include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -124,6 +126,19 @@ class FactureFournisseur extends CommonInvoice */ public $statut; + /** + * ! Closing after partial payment: discount_vat, badsupplier, abandon + * ! Closing when no payment: replaced, abandoned + * @var string Close code + */ + public $close_code; + + /** + * ! Comment if paid without full payment + * @var string Close note + */ + public $close_note; + /** * Set to 1 if the invoice is completely paid, otherwise is 0 * @var int @@ -311,7 +326,7 @@ class FactureFournisseur extends CommonInvoice * Classified paid. * If paid partially, $this->close_code can be: * - CLOSECODE_DISCOUNTVAT - * - CLOSECODE_BADDEBT + * - CLOSECODE_BADCREDIT * If paid completelly, this->close_code will be null */ const STATUS_CLOSED = 2; @@ -319,7 +334,7 @@ class FactureFournisseur extends CommonInvoice /** * Classified abandoned and no payment done. * $this->close_code can be: - * - CLOSECODE_BADDEBT + * - CLOSECODE_BADCREDIT * - CLOSECODE_ABANDONED * - CLOSECODE_REPLACED */ @@ -1181,7 +1196,7 @@ class FactureFournisseur extends CommonInvoice if (!$error) { // If invoice was converted into a discount not yet consumed, we remove discount $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql .= ' WHERE fk_invoice_supplier_source = '.$rowid; + $sql .= ' WHERE fk_invoice_supplier_source = '.((int) $rowid); $sql .= ' AND fk_invoice_supplier_line IS NULL'; $resql = $this->db->query($sql); @@ -1196,7 +1211,7 @@ class FactureFournisseur extends CommonInvoice if (count($list_rowid_det)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier = NULL, fk_invoice_supplier_line = NULL'; - $sql .= ' WHERE fk_invoice_supplier_line IN ('.join(',', $list_rowid_det).')'; + $sql .= ' WHERE fk_invoice_supplier_line IN ('.$this->db->sanitize(join(',', $list_rowid_det)).')'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -1208,13 +1223,13 @@ class FactureFournisseur extends CommonInvoice if (!$error) { $main = MAIN_DB_PREFIX.'facture_fourn_det'; $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture_fourn = $rowid)"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture_fourn = ".((int) $rowid).")"; $resqlef = $this->db->query($sqlef); - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';'; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if ($resqlef && $resql) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.((int) $rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql2 = $this->db->query($sql); if (!$resql2) { @@ -1318,36 +1333,53 @@ class FactureFournisseur extends CommonInvoice */ public function setPaid($user, $close_code = '', $close_note = '') { - global $conf, $langs; $error = 0; - $this->db->begin(); + if ($this->paye != 1) { + $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn'; - $sql .= ' SET paye = 1, fk_statut = '.self::STATUS_CLOSED; - $sql .= ' WHERE rowid = '.$this->id; + $now = dol_now(); - dol_syslog("FactureFournisseur::set_paid", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('BILL_SUPPLIER_PAYED', $user); - if ($result < 0) { - $error++; + dol_syslog("FactureFournisseur::set_paid", LOG_DEBUG); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET'; + $sql .= ' fk_statut = '.self::STATUS_CLOSED; + if (!$close_code) { + $sql .= ', paye=1'; } - // End call triggers - } else { - $error++; - $this->error = $this->db->error(); - dol_print_error($this->db); - } + if ($close_code) { + $sql .= ", close_code='".$this->db->escape($close_code)."'"; + } + if ($close_note) { + $sql .= ", close_note='".$this->db->escape($close_note)."'"; + } + $sql .= ', fk_user_closing = '.$user->id; + $sql .= ", date_closing = '".$this->db->idate($now)."'"; + $sql .= ' WHERE rowid = '.$this->id; - if (!$error) { - $this->db->commit(); - return 1; + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + $result = $this->call_trigger('BILL_SUPPLIER_PAYED', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } else { + $error++; + $this->error = $this->db->error(); + dol_print_error($this->db); + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } else { - $this->db->rollback(); - return -1; + return 0; } } @@ -1385,7 +1417,9 @@ class FactureFournisseur extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn'; - $sql .= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; + $sql .= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; + $sql .= ' date_closing=null,'; + $sql .= ' fk_user_closing=null'; $sql .= ' WHERE rowid = '.$this->id; dol_syslog("FactureFournisseur::set_unpaid", LOG_DEBUG); @@ -1399,8 +1433,8 @@ class FactureFournisseur extends CommonInvoice // End call triggers } else { $error++; - $this->error = $this->db->lasterror(); - dol_syslog("FactureFournisseur::set_unpaid ".$this->error); + $this->error = $this->db->error(); + dol_print_error($this->db); } if (!$error) { @@ -1412,6 +1446,64 @@ class FactureFournisseur extends CommonInvoice } } + /** + * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL + * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because + * of no payment even if merchandises were sent). + * + * @param User $user Object user making change + * @param string $close_code Code of closing invoice (CLOSECODE_REPLACED, CLOSECODE_...) + * @param string $close_note Comment + * @return int <0 if KO, >0 if OK + */ + public function setCanceled($user, $close_code = '', $close_note = '') + { + dol_syslog(get_class($this)."::setCanceled rowid=".((int) $this->id), LOG_DEBUG); + + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn SET'; + $sql .= ' fk_statut='.self::STATUS_ABANDONED; + if ($close_code) { + $sql .= ", close_code='".$this->db->escape($close_code)."'"; + } + if ($close_note) { + $sql .= ", close_note='".$this->db->escape($close_note)."'"; + } + $sql .= ' WHERE rowid = '.$this->id; + + $resql = $this->db->query($sql); + if ($resql) { + // Bound discounts are deducted from the invoice + // as they have not been used since the invoice is abandoned. + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql .= ' SET fk_invoice_supplier = NULL'; + $sql .= ' WHERE fk_invoice_supplier = '.$this->id; + + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + $result = $this->call_trigger('BILL_SUPPLIER_CANCEL', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; + } + } else { + $this->error = $this->db->error()." sql=".$sql; + $this->db->rollback(); + return -2; + } + } + /** * Tag invoice as validated + call trigger BILL_VALIDATE * @@ -1465,7 +1557,7 @@ class FactureFournisseur extends CommonInvoice $this->newref = dol_sanitizeFileName($num); $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " SET ref='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; + $sql .= " SET ref='".$this->db->escape($num)."', fk_statut = 1, fk_user_valid = ".((int) $user->id).", date_valid = '".$this->db->idate($now)."'"; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); @@ -2092,7 +2184,7 @@ class FactureFournisseur extends CommonInvoice // Libere remise liee a ligne de facture $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql .= ' SET fk_invoice_supplier_line = NULL'; - $sql .= ' WHERE fk_invoice_supplier_line = '.$rowid; + $sql .= ' WHERE fk_invoice_supplier_line = '.((int) $rowid); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $result = $this->db->query($sql); @@ -2703,6 +2795,10 @@ class FactureFournisseur extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; + if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { + $object->note_private = ''; + $object->note_public = ''; + } // Loop on each line of new invoice foreach ($object->lines as $i => $line) { @@ -3093,7 +3189,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; - $sql .= ' WHERE f.rowid = '.$rowid; + $sql .= ' WHERE f.rowid = '.((int) $rowid); $sql .= ' ORDER BY f.rang, f.rowid'; $query = $this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index b124817bf9f..21b4ec377a2 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -164,7 +164,7 @@ class ProductFournisseur extends Product $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; + $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".((int) $id_fourn); dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); $resql2 = $this->db->query($sql); @@ -208,7 +208,7 @@ class ProductFournisseur extends Product if (empty($error)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -372,15 +372,15 @@ class ProductFournisseur extends Product } } $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_user = ".$user->id." ,"; + $sql .= " SET fk_user = ".((int) $user->id)." ,"; $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; - $sql .= " price = ".$buyprice.","; - $sql .= " quantity = ".$qty.","; - $sql .= " remise_percent = ".$remise_percent.","; - $sql .= " remise = ".$remise.","; - $sql .= " unitprice = ".$unitBuyPrice.","; - $sql .= " fk_availability = ".$availability.","; + $sql .= " price = ".((float) $buyprice).","; + $sql .= " quantity = ".((float) $qty).","; + $sql .= " remise_percent = ".((float) $remise_percent).","; + $sql .= " remise = ".((float) $remise).","; + $sql .= " unitprice = ".((float) $unitBuyPrice).","; + $sql .= " fk_availability = ".((int) $availability).","; $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; @@ -394,16 +394,16 @@ class ProductFournisseur extends Product //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$this->db->escape($localtaxtype1)."'":"'0'").","; //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$this->db->escape($localtaxtype2)."'":"'0'").","; $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; - $sql .= " info_bits = ".$newnpr.","; - $sql .= " charges = ".$charges.","; // deprecated - $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; + $sql .= " info_bits = ".((int) $newnpr).","; + $sql .= " charges = ".((float) $charges).","; // deprecated + $sql .= " delivery_time_days = ".($delivery_time_days != '' ? ((int) $delivery_time_days) : 'null').","; $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging); } - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " WHERE rowid = ".((int) $this->product_fourn_price_id); // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); @@ -438,7 +438,7 @@ class ProductFournisseur extends Product // Delete price for this quantity $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; + $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".((float) $qty)." AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { // Add price for this quantity to supplier @@ -634,9 +634,10 @@ class ProductFournisseur extends Product * @param string $sortorder Sort order * @param int $limit Limit * @param int $offset Offset + * @param int $socid Filter on a third party id * @return array Array of Products with new properties to define supplier price */ - public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { // phpcs:enable global $conf; @@ -652,8 +653,9 @@ class ProductFournisseur extends Product $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; - $sql .= " AND s.status=1"; // only enabled company selected - $sql .= " AND pfp.fk_product = ".$prodid; + $sql .= ($socid > 0 ? ' AND pfp.fk_soc = '.((int) $socid) : ''); + $sql .= " AND s.status = 1"; // only enabled company selected + $sql .= " AND pfp.fk_product = ".((int) $prodid); if (empty($sortfield)) { $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; } else { @@ -885,8 +887,8 @@ class ProductFournisseur extends Product $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET fk_supplier_price_expression = ".$expression_id; - $sql .= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " SET fk_supplier_price_expression = ".((int) $expression_id); + $sql .= " WHERE rowid = ".((int) $this->product_fourn_price_id); dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 41c780f70c8..9f17f522bdd 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -83,7 +83,7 @@ class PaiementFourn extends Paiement * Load payment object * * @param int $id Id if payment to get - * @param string $ref Ref of payment to get (currently ref = id but this may change in future) + * @param string $ref Ref of payment to get * @param int $fk_bank Id of bank line associated to payment * @return int <0 if KO, -2 if not found, >0 if OK */ @@ -101,9 +101,9 @@ class PaiementFourn extends Paiement if ($id > 0) { $sql .= ' AND p.rowid = '.((int) $id); } elseif ($ref) { - $sql .= ' AND p.rowid = '.$ref; - } elseif ($fk_bank) { - $sql .= ' AND p.fk_bank = '.$fk_bank; + $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; + } elseif ($fk_bank > 0) { + $sql .= ' AND p.fk_bank = '.((int) $fk_bank); } //print $sql; @@ -529,9 +529,10 @@ class PaiementFourn extends Paiement * @param string $option Sur quoi pointe le lien * @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more CSS * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0, $morecss = '') { global $langs; @@ -547,13 +548,26 @@ class PaiementFourn extends Paiement $text = $langs->trans($reg[1]); } - $label = ''.$langs->trans("Payment").'
    '; + $label = img_picto('', $this->picto).' '.$langs->trans("Payment").'
    '; $label .= ''.$langs->trans("Ref").': '.$text; if ($this->datepaye ? $this->datepaye : $this->date) { - $label .= '
    '.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); + $label .= '
    '.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour', 'tzuser'); } - $linkstart = ''; + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("Payment"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + $linkstart = ''; $linkend = ''; $result .= $linkstart; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index fe854c72d48..0a03b367717 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -290,7 +290,7 @@ if (empty($reshook)) { } if ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise($user, $_POST['remise_percent']); + $result = $object->set_remise($user, price2num(GETPOST('remise_percent'))); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1436,10 +1436,10 @@ if (empty($reshook)) { } } elseif ($action == 'swapstatut' && $object->id > 0) { // bascule du statut d'un contact - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $object->id > 0) { // Efface un contact - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -1883,7 +1883,7 @@ if ($action == 'create') { // Confirmation de l'envoi de la commande if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".GETPOST("methodecommande")."&comment=".urlencode(GETPOST("comment")), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); } // Confirmation to delete line diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index ae2e8bab481..2ff1c97e3e5 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -76,14 +76,14 @@ if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) { } elseif ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer) { // Toggle the status of a contact if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } } elseif ($action == 'deletecontact' && $user->rights->fournisseur->commande->creer) { // Deleting a contact $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 0d48c7d30dd..0402fa7a99b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1046,7 +1046,7 @@ if ($id > 0 || !empty($ref)) { if (empty($conf->reception->enabled)) { print $langs->trans("Comment").' : '; print 'trans("DispatchSupplierOrder", $object->ref); + print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref); // print ' / '.$object->ref_supplier; // Not yet available print '" class="flat">
    '; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index d46456b52dc..9164a223d04 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -115,7 +115,7 @@ if ($resql) { } $db->free($resql); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
    '; print ''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index e35d9d84824..2417563c176 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -970,24 +970,24 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view other users if ($user->rights->user->user->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } $parameters = array(); @@ -1439,7 +1439,7 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['cf.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1450,7 +1450,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['cf.total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1461,7 +1461,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1490,21 +1490,21 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d22006a52d0..35b5cd214c8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2015 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García - * Copyright (C) 2016-2020 Alexandre Spangaro + * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2019 Ferran Marcet * @@ -112,18 +112,18 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', // Common permissions $usercanread = $user->rights->fournisseur->facture->lire; -$usercancreate = $user->rights->fournisseur->facture->creer; -$usercandelete = $user->rights->fournisseur->facture->supprimer; +$usercancreate = $user->rights->fournisseur->facture->creer; +$usercandelete = $user->rights->fournisseur->facture->supprimer; // Advanced permissions $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send); // Permissions for includes -$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php +$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $error = 0; @@ -283,6 +283,32 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } + } elseif ($action == 'confirm_paid_partially' && $confirm == 'yes') { + // Classif "paid partialy" + $object->fetch($id); + $close_code = GETPOST("close_code", 'restricthtml'); + $close_note = GETPOST("close_note", 'restricthtml'); + if ($close_code) { + $result = $object->setPaid($user, $close_code, $close_note); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); + } + } elseif ($action == 'confirm_canceled' && $confirm == 'yes') { + // Classify "abandoned" + $object->fetch($id); + $close_code = GETPOST("close_code", 'restricthtml'); + $close_note = GETPOST("close_note", 'restricthtml'); + if ($close_code) { + $result = $object->setCanceled($user, $close_code, $close_note); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); + } } // Set supplier ref @@ -417,13 +443,11 @@ if (empty($reshook)) { dol_print_error($db, $object->error); } } elseif ($action == "setabsolutediscount" && $usercancreate) { - // POST[remise_id] or POST[remise_id_for_payment] - // We use the credit to reduce amount of invoice - if (!empty($_POST["remise_id"])) { + if (GETPOST("remise_id", "int")) { $ret = $object->fetch($id); if ($ret > 0) { - $result = $object->insert_discount($_POST["remise_id"]); + $result = $object->insert_discount(GETPOST("remise_id", "int")); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -432,10 +456,10 @@ if (empty($reshook)) { } } // We use the credit to reduce remain to pay - if (!empty($_POST["remise_id_for_payment"])) { + if (GETPOST("remise_id_for_payment", "int")) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); - $discount->fetch($_POST["remise_id_for_payment"]); + $discount->fetch(GETPOST("remise_id_for_payment", "int")); //var_dump($object->getRemainToPay(0)); //var_dump($discount->amount_ttc);exit; @@ -499,11 +523,15 @@ if (empty($reshook)) { // Loop on each vat rate $i = 0; foreach ($object->lines as $line) { - if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 - // no need to create discount if amount is null + if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null + $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); + $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; + $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc; $i++; } } @@ -517,6 +545,9 @@ if (empty($reshook)) { $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ht[$vatrate] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_tva[$vatrate] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ttc[$vatrate] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); } } } @@ -576,6 +607,7 @@ if (empty($reshook)) { $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; + $discount->vat_src_code = ''; $result = $discount->create($user); if ($result < 0) { @@ -587,7 +619,20 @@ if (empty($reshook)) { $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); + $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); + $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); + $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); + + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $tva_tx, $reg)) { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx); // Remove code into vatrate. + } + $discount->tva_tx = abs($tva_tx); + $discount->vat_src_code = $vat_src_code; $result = $discount->create($user); if ($result < 0) { @@ -630,7 +675,7 @@ if (empty($reshook)) { } } } elseif ($action == 'add' && $usercancreate) { - // Create + // Insert new invoice in database if ($socid > 0) { $object->socid = GETPOST('socid', 'int'); } @@ -815,7 +860,7 @@ if (empty($reshook)) { } } - // Standard or deposit + // Standard invoice or Deposit invoice, created from a Predefined template invoice if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) { if (GETPOST('socid', 'int') < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); @@ -845,24 +890,26 @@ if (empty($reshook)) { $tmpproject = GETPOST('projectid', 'int'); // Creation invoice - $object->ref = GETPOST('ref', 'nohtml'); - $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); - $object->socid = GETPOST('socid', 'int'); - $object->libelle = GETPOST('label', 'nohtml'); // deprecated - $object->label = GETPOST('label', 'nohtml'); - $object->date = $dateinvoice; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - $object->transport_mode_id = GETPOST('transport_mode_id'); + $object->socid = GETPOST('socid', 'int'); + $object->type = GETPOST('type'); + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); + $object->socid = GETPOST('socid', 'int'); + $object->libelle = GETPOST('label', 'nohtml'); // deprecated + $object->label = GETPOST('label', 'nohtml'); + $object->date = $dateinvoice; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->note_private = GETPOST('note_private', 'restricthtml'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->transport_mode_id = GETPOST('transport_mode_id'); // Auto calculation of date due if not filled by user if (empty($object->date_echeance)) { @@ -937,6 +984,123 @@ if (empty($reshook)) { $srcobject = new $classname($db); $result = $srcobject->fetch(GETPOST('originid', 'int')); + + // If deposit invoice - down payment with 1 line (fixed amount or percent) + if (GETPOST('type') == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable'))) { + // Define the array $amountdeposit + $amountdeposit = array(); + if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) { + if ($typeamount == 'amount') { + $amount = $valuedeposit; + } else { + $amount = $srcobject->total_ttc * ($valuedeposit / 100); + } + + $TTotalByTva = array(); + foreach ($srcobject->lines as &$line) { + if (!empty($line->special_code)) { + continue; + } + $TTotalByTva[$line->tva_tx] += $line->total_ttc; + } + + foreach ($TTotalByTva as $tva => &$total) { + $coef = $total / $srcobject->total_ttc; // Calc coef + $am = $amount * $coef; + $amount_ttc_diff += $am; + $amountdeposit[$tva] += $am / (1 + $tva / 100); // Convert into HT for the addline + } + } else { + if ($typeamount == 'amount') { + $amountdeposit[0] = $valuedeposit; + } elseif ($typeamount == 'variable') { + if ($result > 0) { + $totalamount = 0; + $lines = $srcobject->lines; + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { + $qualified = 1; + if (empty($lines[$i]->qty)) { + $qualified = 0; // We discard qty=0, it is an option + } + if (!empty($lines[$i]->special_code)) { + $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...) + } + if ($qualified) { + $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + $tva_tx = $lines[$i]->tva_tx; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; + } + } + + if ($totalamount == 0) { + $amountdeposit[0] = 0; + } + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error++; + } + } + + $amount_ttc_diff = $amountdeposit[0]; + } + + foreach ($amountdeposit as $tva => $amount) { + if (empty($amount)) { + continue; + } + + $arraylist = array( + 'amount' => 'FixAmount', + 'variable' => 'VarAmount' + ); + $descline = '(DEPOSIT)'; + //$descline.= ' - '.$langs->trans($arraylist[$typeamount]); + if ($typeamount == 'amount') { + $descline .= ' ('.price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; + } elseif ($typeamount == 'variable') { + $descline .= ' ('.$valuedeposit.'%)'; + } + + $descline .= ' - '.$srcobject->ref; + $result = $object->addline( + $descline, + $amount, // subprice + $tva, // vat rate + 0, // localtax1_tx + 0, // localtax2_tx + 1, // quantity + (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT) ? 0 : $conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product + 0, // remise_percent + 0, // date_start + 0, // date_end + 0, + $lines[$i]->info_bits, // info_bits + 'HT', + 0, // product_type + 1, + 0, + 0, + 0, + null, + $object->origin, + 0, + '', + $lines[$i]->special_code, + 0 + //,$langs->trans('Deposit') //Deprecated + ); + } + + $diff = $object->total_ttc - $amount_ttc_diff; + + if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { + $object->fetch_lines(); + $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); + $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); + } + } + if ($result > 0) { $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { @@ -1082,14 +1246,14 @@ if (empty($reshook)) { $prod = new Product($db); $prod->fetch(GETPOST('productid')); $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) { - $label = $_POST['product_desc']; + if (trim(GETPOST('product_desc', 'restricthtml')) != trim($label)) { + $label = GETPOST('product_desc', 'restricthtml'); } $type = $prod->type; } else { - $label = $_POST['product_desc']; - $type = $_POST["type"] ? $_POST["type"] : 0; + $label = GETPOST('product_desc', 'restricthtml'); + $type = GETPOST("type") ? GETPOST("type") : 0; } $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); @@ -1590,14 +1754,14 @@ if (empty($reshook)) { } elseif ($action == 'swapstatut') { // bascule du statut d'un contact if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } } elseif ($action == 'deletecontact') { // Efface un contact $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -1800,40 +1964,64 @@ if ($action == 'create') { print $desc; print ''; - /* Not yet supported - if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) - { - // Deposit - if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) - { + if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { + // Deposit - Down payment + if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
    '; $tmp=' '; print ''; + jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() { + setRadioForTypeOfInvoice(); + }); + function setRadioForTypeOfInvoice() { + console.log("Change radio"); + if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) { + jQuery(".checkforselect").prop("disabled", true); + jQuery(".checkforselect").prop("checked", false); + } else { + jQuery(".checkforselect").prop("disabled", false); + jQuery(".checkforselect").prop("checked", true); + } + }; + }); + '; - $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); - print '
    '.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."
    '; + $tmp = $tmp.''; + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); + print ''; + print ''; - if (($origin == 'propal') || ($origin == 'commande')) - { - print ''; + print ''; - print '
    '; print $desc; print ''; - $arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit'))); - print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); + if (($origin == 'propal') || ($origin == 'commande')) { + print ''; + $arraylist = array( + 'amount' => $langs->transnoentitiesnoconv('FixAmount', $langs->transnoentitiesnoconv('Deposit')), + 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')), + 'variablealllines' => $langs->transnoentitiesnoconv('VarAmountAllLines') + ); + print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1); + print ''; + print ''.$langs->trans("AmountOrPercent").''; print '' . $langs->trans('Value') . ':'; } - print '
    '; + print '
    '; print '
    '; } } - */ /* Not yet supported for supplier if ($societe->id > 0) @@ -2342,10 +2530,68 @@ if ($action == 'create') { } // Confirmation set paid - if ($action == 'paid') { + if ($action == 'paid' && $resteapayer <= 0) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); } + if ($action == 'paid' && $resteapayer > 0) { + $close = array(); + // Code + $i = 0; + $close[$i]['code'] = 'discount_vat'; // escompte + $i++; + $close[$i]['code'] = 'badsupplier'; + $i++; + $close[$i]['code'] = 'other'; + $i++; + // Help + $i = 0; + $close[$i]['label'] = $langs->trans("HelpEscompte").'

    '.$langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc"); + $i++; + $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadSupplierDesc"); + $i++; + $close[$i]['label'] = $langs->trans("Other"); + $i++; + // Text + $i = 0; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); + $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); + $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1); + $i++; + // arrayreasons[code]=reason + foreach ($close as $key => $val) { + $arrayreasons[$close[$key]['code']] = $close[$key]['reason']; + } + + // Create a form table + $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + // Incomplete payment. We ask if the reason is discount or other + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 310); + } + + // Confirmation of the abandoned classification + if ($action == 'canceled') { + // Code + $close[1]['code'] = 'badsupplier'; + $close[2]['code'] = 'abandon'; + // Help + $close[1]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadSupplierDesc"); + $close[2]['label'] = $langs->trans("ConfirmClassifyAbandonReasonOtherDesc"); + // Text + $close[1]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadSupplier", $object->ref), $close[1]['label'], 1); + $close[2]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyAbandonReasonOther"), $close[2]['label'], 1); + // arrayreasons + $arrayreasons[$close[1]['code']] = $close[1]['reason']; + $arrayreasons[$close[2]['code']] = $close[2]['reason']; + + // Create a form table + $formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); + + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 250); + } + // Confirmation de la suppression de la facture fournisseur if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); @@ -3111,9 +3357,9 @@ if ($action == 'create') { $ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection. if ($ventilExportCompta == 0) { - print ''; + print ''.$langs->trans('Modify').''; } else { - print '
    '.$langs->trans('Modify').'
    '; + print ''.$langs->trans('Modify').''; } } @@ -3122,15 +3368,29 @@ if ($action == 'create') { // Reopen a standard paid invoice if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT - || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) + || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)) + || ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discount->id))) && ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) { // A paid invoice (partially or completely) if (!$facidnext && $object->close_code != 'replaced' && $usercancreate) { // Not replaced by another invoice - print ''; + print ''.$langs->trans('ReOpen').''; } else { if ($usercancreate) { - print '
    '.$langs->trans('ReOpen').'
    '; + print ''.$langs->trans('ReOpen').''; } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { - print '
    '.$langs->trans('ReOpen').'
    '; + print ''.$langs->trans('ReOpen').''; + } + } + } + + // Validate + if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { + if (count($object->lines)) { + if ($usercanvalidate) { + print ''.$langs->trans('Validate').''; + } else { + print ''.$langs->trans('Validate').''; } } } @@ -3139,24 +3399,16 @@ if ($action == 'create') { if (empty($user->socid)) { if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) { if ($usercansend) { - print ''; + print ''.$langs->trans('SendMail').''; } else { - print '
    '.$langs->trans('SendMail').'
    '; + print ''.$langs->trans('SendMail').''; } } } - // Make payments - if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; // must use facid because id is for payment id not invoice - } - - // Classify paid - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print ''; - - //print ''.$langs->trans('ClassifyPaid').''; + // Create payment + if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0) { + print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice } // Reverse back money or convert to reduction @@ -3164,37 +3416,43 @@ if ($action == 'create') { // For credit note only if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0) { if ($resteapayer == 0) { - print '
    '.$langs->trans('DoPaymentBack').'
    '; + print ''.$langs->trans('DoPaymentBack').''; } else { - print ''; + print ''.$langs->trans('DoPaymentBack').''; } } // For standard invoice with excess paid if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { - print ''; + print ''.$langs->trans('ConvertExcessPaidToReduc').''; } // For credit note if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { - print ''; + print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $usercancreate && empty($discount->id)) { - print ''; + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { + print ''.$langs->trans('ConvertToReduc').''; } } - // Validate - if ($action != 'confirm_edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { - if (count($object->lines)) { - if ($usercanvalidate) { - print ''; - } else { - print ''; + // Classify paid + if (($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && (($object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $resteapayer >= 0))) + || ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && empty($discount->id)) + ) { + print ''.$langs->trans('ClassifyPaid').''; + } + + // Classify 'closed not completely paid' (possible if validated and not yet filed paid) + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0) { + if ($totalpaye > 0 || $totalcreditnotes > 0) { + // If one payment or one credit note was linked to this invoice + print ''.$langs->trans('ClassifyPaidPartially').''; + } else { + if (empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) { + print ''.$langs->trans('ClassifyCanceled').''; } } } @@ -3205,34 +3463,34 @@ if ($action == 'create') { print ''; }*/ - // Clone - if ($action != 'edit' && $usercancreate) { - print ''; - } - // Create a credit note if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $usercancreate) { if (!$objectidnext) { - print ''; + print ''.$langs->trans("CreateCreditNote").''; } } + // Clone + if ($action != 'edit' && $usercancreate) { + print 'socid.'">'.$langs->trans('ToClone').''; + } + // Delete $isErasable = $object->is_erasable(); if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); if ($isErasable == -4) { - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { // Should never happen with supplier invoice - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { // Should never happen with supplier invoice - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { - print ''; + print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases - print ''; + print ''.$langs->trans('Delete').''; } else { - print ''; + print ''.$langs->trans('Delete').''; } } print ''; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 4f450bca3c4..1284ee293be 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -76,14 +76,14 @@ if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) { } elseif ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) { // bascule du statut d'un contact if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } } elseif ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) { // Efface un contact $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php deleted file mode 100644 index 7019b90b868..00000000000 --- a/htdocs/fourn/facture/impayees.php +++ /dev/null @@ -1,327 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Vinicius Nogueira - * Copyright (C) 2012 Juanjo Menent - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (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/fourn/facture/impayees.php - * \ingroup facture - * \brief Page to list all unpaid invoices - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - -if (!$user->rights->fournisseur->facture->lire) { - accessforbidden(); -} - -$langs->loadLangs(array("companies", "bills")); - -$socid = GETPOST('socid', 'int'); -$option = GETPOST('option'); - -// Security check -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; -} - -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); - -$search_ref = GETPOST('search_ref', 'alpha'); -$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); -$search_company = GETPOST('search_company', 'alpha'); -$search_amount_no_tax = GETPOST('search_amount_no_tax', 'alpha'); -$search_amount_all_tax = GETPOST('search_amount_all_tax', 'alpha'); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortfield) { - $sortfield = "f.date_lim_reglement"; -} -if (!$sortorder) { - $sortorder = "ASC"; -} - -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_ref = ""; - $search_ref_supplier = ""; - $search_company = ""; - $search_amount_no_tax = ""; - $search_amount_all_tax = ""; -} - -/* - * View - */ - -$now = dol_now(); - -llxHeader('', $langs->trans("BillsSuppliersUnpaid")); - -$title = $langs->trans("BillsSuppliersUnpaid"); - -$facturestatic = new FactureFournisseur($db); -$companystatic = new Societe($db); - -if ($user->rights->fournisseur->facture->lire) { - $sql = "SELECT s.rowid as socid, s.nom as name,"; - $sql .= " f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc,"; - $sql .= " f.datef as df, f.date_lim_reglement as datelimite, "; - $sql .= " f.paye as paye, f.rowid as facid, f.fk_statut"; - $sql .= " ,sum(pf.amount) as am"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; - } - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn "; - $sql .= " WHERE f.entity = ".$conf->entity; - $sql .= " AND f.fk_soc = s.rowid"; - $sql .= " AND f.paye = 0 AND f.fk_statut = 1"; - if ($option == 'late') { - $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; - } - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - if ($socid) { - $sql .= " AND s.rowid = ".$socid; - } - - if (GETPOST('filtre')) { - $filtrearr = explode(",", GETPOST('filtre')); - foreach ($filtrearr as $fil) { - $filt = explode(":", $fil); - $sql .= " AND ".$filt[0]." = ".$filt[1]; - } - } - - if ($search_ref) { - $sql .= " AND f.ref LIKE '%".$db->escape($search_ref)."%'"; - } - if ($search_ref_supplier) { - $sql .= " AND f.ref_supplier LIKE '%".$db->escape($search_ref_supplier)."%'"; - } - - if ($search_company) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; - } - - if ($search_amount_no_tax) { - $sql .= " AND f.total_ht = '".$db->escape($search_amount_no_tax)."'"; - } - - if ($search_amount_all_tax) { - $sql .= " AND f.total_ttc = '".$db->escape($search_amount_all_tax)."'"; - } - - if (dol_strlen(GETPOST('sf_re')) > 0) { - $sql .= " AND f.ref_supplier LIKE '%".$db->escape(GETPOST('sf_re'))."%'"; - } - - $sql .= " GROUP BY s.rowid, s.nom, f.rowid, f.ref, f.ref_supplier, f.total_ht, f.total_ttc, f.datef, f.date_lim_reglement, f.paye, f.fk_statut"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", sc.fk_soc, sc.fk_user "; - } - $sql .= $db->order($sortfield, $sortorder); - if (!in_array("f.ref_supplier", explode(',', $sortfield))) { - $sql .= ", f.ref_supplier DESC"; - } - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - if ($socid) { - $soc = new Societe($db); - $soc->fetch($socid); - } - - $param = ''; - if ($socid) { - $param .= "&socid=".$socid; - } - - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_ref_supplier) { - $param .= '&search_ref_supplier='.urlencode($search_ref_supplier); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_amount_no_tax) { - $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); - } - if ($search_amount_all_tax) { - $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); - } - - $param .= ($option ? "&option=".$option : ""); - if (!empty($late)) { - $param .= '&late='.urlencode($late); - } - $urlsource = str_replace('&', '&', $param); - - $titre = ($socid ? $langs->trans("BillsSuppliersUnpaidForCompany", $soc->name) : $langs->trans("BillsSuppliersUnpaid")); - - if ($option == 'late') { - $titre .= ' ('.$langs->trans("Late").')'; - } else { - $titre .= ' ('.$langs->trans("All").')'; - } - - $link = ''; - if (empty($option)) { - $link = ''.$langs->trans("ShowUnpaidLateOnly").''; - } elseif ($option == 'late') { - $link = ''.$langs->trans("ShowUnpaidAll").''; - } - print load_fiche_titre($titre, $link); - - print_barre_liste('', '', $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0); // We don't want pagination on this page - $i = 0; - print ''; - - print ''; - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "f.rowid", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("RefSupplier", $_SERVER["PHP_SELF"], "f.ref_supplier", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("DateDue", $_SERVER["PHP_SELF"], "f.date_lim_reglement", "", $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("AlreadyPaid", $_SERVER["PHP_SELF"], "am", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "fk_statut,paye,am", "", $param, '', $sortfield, $sortorder, 'right '); - print "\n"; - - // Lines with filter fields - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - if ($num > 0) { - $total_ht = 0; - $total_ttc = 0; - $total_paid = 0; - - while ($i < $num) { - $objp = $db->fetch_object($resql); - - $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_echeance = $db->jdate($objp->datelimite); - - - - print ''; - $classname = "impayee"; - - print '\n"; - - print ''; - - print '\n"; - print '\n"; - - print ''; - - print ""; - print ""; - print ""; - - // Show invoice status - print ''; - - print "\n"; - $total_ht += $objp->total_ht; - $total_ttc += $objp->total_ttc; - $total_paid += $objp->am; - - $i++; - } - - print ''; - print ""; - print ""; - print ""; - print ""; - print ''; - print "\n"; - } - - print "
    '; - print ''; - print '  '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
    '; - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - print $facturestatic->getNomUrl(1); - print "'.dol_trunc($objp->ref_supplier, 12).''.dol_print_date($db->jdate($objp->df), 'day')."'.dol_print_date($db->jdate($objp->datelimite), 'day'); - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans("Late")); - } - print "'; - $companystatic->id = $objp->socid; - $companystatic->name = $objp->name; - print $companystatic->getNomUrl(1, 'supplier', 32); - print '".price($objp->total_ht)."".price($objp->total_ttc)."".price($objp->am)."'; - print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $objp->am); - print '
    ".$langs->trans("Total").": ".price($total_ht)."".price($total_ttc)."".price($total_paid)." 
    "; - - print ''; - - $db->free($resql); - } else { - dol_print_error($db); - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 1e3c4f5e686..e76426f54c2 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; // Security check restrictedArea($user, 'fournisseur', 0, '', 'facture'); @@ -39,6 +40,8 @@ if (isset($user->socid) && $user->socid > 0) { $socid = $user->socid; } +$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + // Maximum elements of the tables $maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; $maxLatestEditCount = 5; @@ -56,24 +59,18 @@ print '
    '; print '
    '; -// This is useless due to the global search combo -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { - print getAreaSearchFrom(); - print '
    '; -} - -print getPieChart($socid); +print getPurchaseInvoicePieChart($socid); print '
    '; -print getDraftTable($maxDraftCount, $socid); +print getDraftSupplierTable($maxDraftCount, $socid); print '
    '; print '
    '; print '
    '; -print getLatestEditTable($maxLatestEditCount, $socid); +print getPurchaseInvoiceLatestEditTable($maxLatestEditCount, $socid); print '
    '; -print getOpenTable($maxOpenCount, $socid); +print getPurchaseInvoiceUnpaidOpenTable($max, $socid); print '
    '; print '
    '; @@ -83,453 +80,3 @@ print '
    '; // End of page llxFooter(); $db->close(); - -/** - * Return a HTML string that contains a additional search form - * - * @return string A HTML string that contains a additional search form - */ -function getAreaSearchFrom() -{ - global $langs; - - $result = '
    '; - $result .= '
    '; - $result .= ''; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= "
    '.$langs->trans("Search").'
    '.$langs->trans("Invoice").':
    "; - $result .= "
    "; - $result .= "
    "; - - return $result; -} - -/** - * Return a HTML table that contains a pie chart of supplier invoices - * - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that contains a pie chart of supplier invoices - */ -function getPieChart($socid = 0) -{ - global $conf, $db, $langs, $user; - - $sql = "SELECT count(f.rowid), f.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($user->socid) { - $sql .= ' AND f.fk_soc = '.$user->socid; - } - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - $sql .= " GROUP BY f.fk_statut"; - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $vals = []; - - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - $vals[$row[1]] = $row[0]; - $total += $row[0]; - } - - $i++; - } - - $db->free($resql); - - $result = '
    '; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $objectstatic = new FactureFournisseur($db); - $array = [FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED]; - $dataseries = []; - - foreach ($array as $status) { - $objectstatic->statut = $status; - $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0; - - $dataseries[] = [$objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)]; - if (!$conf->use_javascript_ajax) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - } - - if ($conf->use_javascript_ajax) { - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphthirdparties'); - - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= '
    '.$langs->trans("Statistics").' - '.$langs->trans("SupplierInvoice").'
    '.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
    '.$dolgraph->show($total ? 0 : 1).'
    '.$langs->trans("Total").''.$total.'
    '; - $result .= '
    '; - - return $result; -} - -/** - * Return a HTML table that contains a list with supplier invoice drafts - * - * @param int $maxCount (Optional) The maximum count of elements inside the table - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that contains a list with supplier invoice drafts - */ -function getDraftTable($maxCount = 500, $socid = 0) -{ - global $db, $langs, $user; - - $sql = "SELECT f.rowid, f.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client, f.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; - if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; - } - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - $sql .= $db->plimit($maxCount, 0); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - - $result = '
    '; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - if ($num < 1) { - $result .= '
    '; - $result .= $langs->trans("SuppliersDraftInvoices"); - $result .= ' '; - $result .= ''.$num.''; - $result .= ''; - $result .= '
    '; - $result .= '
    '; - return $result; - } - - $objectstatic = new FactureFournisseur($db); - $companystatic = new Societe($db); - $nbofloop = min($num, $maxCount); - $total = 0; - $i = 0; - - while ($i < $nbofloop) { - $obj = $db->fetch_object($resql); - - $objectstatic->id = $obj->rowid; - $objectstatic->ref = $obj->ref; - - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - - $result .= '
    '.$objectstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'supplier', 24).''.price($obj->total_ttc).'
    '.$langs->trans("XMoreLines", ($num - $nbofloop)).'
    '.$langs->trans("Total").''.price($total).'
    '; - $result .= '
    '; - return $result; -} - -/** - * Return a HTML table that contains a list with latest edited supplier invoices - * - * @param int $maxCount (Optional) The maximum count of elements inside the table - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that contains a list with latest edited supplier invoices - */ -function getLatestEditTable($maxCount = 5, $socid = 0) -{ - global $conf, $db, $langs, $user; - - $sql = "SELECT f.rowid, f.entity, f.ref, f.fk_statut as status, f.paye, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; - $sql .= " f.datec"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; - } - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - $sql .= " ORDER BY f.tms DESC"; - $sql .= $db->plimit($maxCount, 0); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - - $result = '
    '; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - if ($num < 1) { - $result .= '
    '.$langs->trans("BoxTitleLastSupplierBills", $maxCount).'
    '; - $result .= '
    '; - return $result; - } - - $objectstatic = new FactureFournisseur($db); - $companystatic = new Societe($db); - $formfile = new FormFile($db); - $i = 0; - - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $objectstatic->id = $obj->rowid; - $objectstatic->ref = $obj->ref; - $objectstatic->paye = $obj->paye; - $objectstatic->statut = $obj->status; - - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; - - $result .= '
    '; - $result .= ''; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= ''; - $result .= '
    '.$objectstatic->getNomUrl(1).' '.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).'
    '; - $result .= '
    '.$companystatic->getNomUrl(1, 'supplier').''.dol_print_date($db->jdate($obj->datec), 'day').''.$objectstatic->getLibStatut(5).'
    '; - $result .= '
    '; - return $result; -} - -/** - * Return a HTML table that contains a list with open (unpaid) supplier invoices - * - * @param int $maxCount (Optional) The maximum count of elements inside the table - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that conatins a list with open (unpaid) supplier invoices - */ -function getOpenTable($maxCount = 500, $socid = 0) -{ - global $conf, $db, $langs, $user; - - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql .= ", f.rowid as id, f.entity, f.total_ttc, f.total_ht, f.ref, f.fk_statut"; - $sql .= ", f.datef as df, f.date_lim_reglement as datelimite"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - $sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - if ($socid) { - $sql .= " AND s.rowid = ".$socid; - } - $sql .= " ORDER BY f.rowid DESC"; - $sql .= $db->plimit($maxCount, 0); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - - $result = '
    '; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - if ($num < 1) { - $result .= '
    '; - $result .= $langs->trans("BillsCustomersUnpaid"); - $result .= ' '; - $result .= ''.$num.''; - $result .= ''; - $result .= '
    '; - $result .= '
    '; - return $result; - } - - $objectstatic = new FactureFournisseur($db); - $companystatic = new Societe($db); - $formfile = new FormFile($db); - $nbofloop = min($num, $maxCount); - $now = dol_now(); - $total = 0; - $i = 0; - - while ($i < $nbofloop) { - $obj = $db->fetch_object($resql); - - $objectstatic->id = $obj->id; - $objectstatic->ref = $obj->ref; - - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; - - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= ''; - $result .= ''; - - $result .= ''; - - $result .= ''; - $result .= '
    '.$objectstatic->getNomUrl(1).''; - - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { - $result .= img_warning($langs->trans("Late")); - } - - $result .= ''.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).'
    '; - $result .= ''; - - $result .= ''.$companystatic->getNomUrl(1, 'customer', 44).''; - $result .= ''.dol_print_date($db->jdate($obj->df), 'day').''; - $result .= ''.price($obj->total_ttc).''; - - $result .= ''; - - $i++; - $total += $obj->total_ttc; - } - - if ($num > $nbofloop) { - $result .= ''; - $result .= ''.$langs->trans("XMoreLines", ($num - $nbofloop)).''; - $result .= ''; - } elseif ($total > 0) { - $result .= ''; - $result .= ''.$langs->trans("Total").''; - $result .= ''.price($total).''; - $result .= ' '; - $result .= ''; - } - - $result .= ''; - $result .= '
    '; - return $result; -} diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 7c6ed0c5e16..0b6e7aca99c 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -171,7 +171,7 @@ $arrayfields = array( 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), - 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>-1), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), @@ -475,14 +475,14 @@ $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " country.code as country_code,"; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; $sql .= " u.login"; +if ($search_categ_sup && $search_categ_sup != '-1') { + $sql .= ", cs.fk_categorie, cs.fk_soc"; +} // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (!$search_all) { $sql .= ', SUM(pf.amount) as dynamount_payed'; } -if ($search_categ_sup) { - $sql .= ", cs.fk_categorie, cs.fk_soc"; -} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -524,6 +524,10 @@ if ($search_user > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; if (!$user->rights->societe->client->voir && !$socid) { @@ -580,10 +584,10 @@ if ($search_state) { $sql .= natural_search("state.nom", $search_state); } if ($search_country) { - $sql .= " AND s.fk_pays IN (".$search_country.')'; + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) { - $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; } if ($search_montant_ht != '') { $sql .= natural_search('f.total_ht', $search_montant_ht, 1); @@ -677,16 +681,28 @@ if (!$search_all) { $sql .= ' country.code,'; $sql .= " p.rowid, p.ref, p.title,"; $sql .= " u.login"; + if ($search_categ_sup && $search_categ_sup != '-1') { + $sql .= ", cs.fk_categorie, cs.fk_soc"; + } if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { //prevent error with sql_mode=only_full_group_by $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } + // Add GroupBy from hooks + $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } else { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -829,6 +845,10 @@ if ($resql) { // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( @@ -931,32 +951,32 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'company', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1); + $tmptitle = $langs->trans('SuppliersCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $tmptitle); $moreforfilter .= '
    '; } $parameters = array(); @@ -1039,7 +1059,7 @@ if ($resql) { } print ''; $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); - print '
    '.$langs->trans("Late"); + print '
    '; print ''; } // Project @@ -1252,7 +1272,7 @@ if ($resql) { print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['f.total_vat']['checked'])) { - print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['f.total_localtax1']['checked'])) { print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); @@ -1395,7 +1415,7 @@ if ($resql) { // Supplier ref if (!empty($arrayfields['f.ref_supplier']['checked'])) { - print ''; + print ''; print $obj->ref_supplier; print ''; if (!$i) { @@ -1519,7 +1539,7 @@ if ($resql) { // Payment condition if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''; + print ''; $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1); print ''; if (!$i) { @@ -1528,7 +1548,7 @@ if ($resql) { } // Payment mode if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''; + print ''; $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); print ''; if (!$i) { @@ -1538,7 +1558,7 @@ if ($resql) { // Amount HT if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; + print ''.price($obj->total_ht)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1549,7 +1569,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['f.total_vat']['checked'])) { - print ''.price($obj->total_vat)."\n"; + print ''.price($obj->total_vat)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1560,7 +1580,7 @@ if ($resql) { } // Amount LocalTax1 if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print ''.price($obj->total_localtax1)."\n"; + print ''.price($obj->total_localtax1)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1571,7 +1591,7 @@ if ($resql) { } // Amount LocalTax2 if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print ''.price($obj->total_localtax2)."\n"; + print ''.price($obj->total_localtax2)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1582,7 +1602,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; + print ''.price($obj->total_ttc)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1609,7 +1629,7 @@ if ($resql) { } if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1649,27 +1669,27 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; + print ''.price($obj->multicurrency_total_ht)."\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { - print ''.price($obj->multicurrency_total_vat)."\n"; + print ''.price($obj->multicurrency_total_vat)."\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; + print ''.price($obj->multicurrency_total_ttc)."\n"; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1677,9 +1697,9 @@ if ($resql) { // Pending amount if (!empty($arrayfields['multicurrency_rtp']['checked'])) { - print ''; - print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); - print ''; // TODO Use a denormalized field + print ''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); + print ''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -1692,6 +1712,7 @@ if ($resql) { $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation if (!empty($arrayfields['f.datec']['checked'])) { print ''; diff --git a/htdocs/fourn/js/index.html b/htdocs/fourn/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/fourn/js/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 305c7bedba5..000b5def498 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -11,6 +11,7 @@ * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,28 +34,9 @@ */ require '../../main.inc.php'; - -// Security check -if ($user->socid) { - $socid = $user->socid; -} - -// doesn't work :-( -// restrictedArea($user, 'fournisseur'); - -// doesn't work :-( -// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -// $object = new PaiementFourn($db); -// restrictedArea($user, $object->element); - -if (!$user->rights->fournisseur->facture->lire) { - accessforbidden(); -} - require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); @@ -119,9 +101,28 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $hookmanager->initHooks(array('paymentsupplierlist')); $object = new PaiementFourn($db); +// Security check +if ($user->socid) { + $socid = $user->socid; +} + +// doesn't work :-( +// restrictedArea($user, 'fournisseur'); +// doesn't work :-( +// require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +// $object = new PaiementFourn($db); +// restrictedArea($user, $object->element); +if (empty($conf->fournisseur->enabled)) { + accessforbidden(); +} +if (!$user->rights->fournisseur->facture->lire) { + accessforbidden(); +} + + /* -* Actions -*/ + * Actions + */ $parameters = array('socid'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -200,9 +201,8 @@ if ($search_amount) { $sql .= natural_search('p.amount', $search_amount, 1); } if ($search_bank_account > 0) { - $sql .= ' AND b.fk_account='.$search_bank_account."'"; + $sql .= ' AND b.fk_account = '.((int) $search_bank_account); } - if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -520,7 +520,7 @@ while ($i < min($num, $limit)) { // Amount if (!empty($arrayfields['p.amount']['checked'])) { - print ''.price($objp->pamount).''; + print ''.price($objp->pamount).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 06ad90ec858..97a6b53f2e2 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -73,7 +73,7 @@ if ($socid > 0) { $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql .= " u.login, u.rowid as userid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; + $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $societe->id); $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany $sql .= " AND f.fk_user_valid = u.rowid"; $sql .= " ORDER BY f.datef DESC"; diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index ab673e45447..5094f178cea 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -58,8 +58,8 @@ if ($result) { } if ($action == 'add' || GETPOST('modify', 'alpha')) { - $ftp_name = "FTP_NAME_".$entry; // $_POST["numero_entry"]; - $ftp_server = "FTP_SERVER_".$entry; //$_POST["numero_entry"]; + $ftp_name = "FTP_NAME_".$entry; + $ftp_server = "FTP_SERVER_".$entry; $error = 0; @@ -203,7 +203,7 @@ if (!function_exists('ftp_connect')) { print ''; print ''.$langs->trans("FTPPassiveMode").''; $defaultpassive = GETPOST("FTP_PASSIVE_".($lastftpentry + 1)); - if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) { + if (!GETPOSTISSET("FTP_PASSIVE_".($lastftpentry + 1))) { $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1; } print ''.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry + 1), $defaultpassive, 2).''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 7943df254c1..ffd394a35b3 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -479,7 +479,7 @@ class Holiday extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau - $sql .= " AND cp.fk_user IN (".$user_id.")"; + $sql .= " AND cp.fk_user IN (".$this->db->sanitize($user_id).")"; // Selection filter if (!empty($filter)) { @@ -1122,7 +1122,7 @@ class Holiday extends CommonObject $sql .= " AND cp.fk_user = ".(int) $fk_user; $sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; if ($status != '-1') { - $sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")"; + $sql .= " AND cp.statut IN (".$this->db->sanitize($status).")"; } $resql = $this->db->query($sql); @@ -2069,7 +2069,7 @@ class Holiday extends CommonObject $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; - $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + $sql .= " WHERE (fk_country IS NULL OR fk_country = ".((int) $mysoc->country_id).')'; if ($active >= 0) { $sql .= " AND active = ".((int) $active); } @@ -2209,8 +2209,8 @@ class Holiday extends CommonObject $sql .= " AND h.entity IN (".getEntity('holiday').")"; if (empty($user->rights->expensereport->readall)) { $userchildids = $user->getAllChildIds(1); - $sql .= " AND (h.fk_user IN (".join(',', $userchildids).")"; - $sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))"; + $sql .= " AND (h.fk_user IN (".$this->db->sanitize(join(',', $userchildids)).")"; + $sql .= " OR h.fk_validator IN (".$this->db->sanitize(join(',', $userchildids))."))"; } $resql = $this->db->query($sql); @@ -2251,8 +2251,8 @@ class Holiday extends CommonObject $sql .= " AND h.entity IN (".getEntity('holiday').")"; if (empty($user->rights->expensereport->read_all)) { $userchildids = $user->getAllChildIds(1); - $sql .= " AND (h.fk_user IN (".join(',', $userchildids).")"; - $sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))"; + $sql .= " AND (h.fk_user IN (".$this->db->sanitize(join(',', $userchildids)).")"; + $sql .= " OR h.fk_validator IN (".$this->db->sanitize(join(',', $userchildids))."))"; } $resql = $this->db->query($sql); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index e57e12dcaee..b3d2c25adda 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -230,7 +230,7 @@ $filters = ''; $userchilds = array(); if (empty($user->rights->holiday->readall)) { $userchilds = $user->getAllChildIds(1); - $filters .= ' AND u.rowid IN ('.join(', ', $userchilds).')'; + $filters .= ' AND u.rowid IN ('.$db->sanitize(join(', ', $userchilds)).')'; } if (!empty($search_name)) { $filters .= natural_search(array('u.firstname', 'u.lastname'), $search_name); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 4474aecf748..f49a3145af9 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -341,10 +341,10 @@ if (!empty($search_status) && $search_status != -1) { } if (empty($user->rights->holiday->readall)) { - $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')'; + $sql .= ' AND cp.fk_user IN ('.$db->sanitize(join(',', $childids)).')'; } if ($id > 0) { - $sql .= " AND cp.fk_user IN (".$id.")"; + $sql .= " AND cp.fk_user IN (".$db->sanitize($id).")"; } // Add where from extra fields diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 37497fd1810..62991a6e0ee 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -154,7 +154,7 @@ if (!empty($search_employee)) { $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'"; } if (!empty($search_type)) { - $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; + $sql .= ' AND cp.fk_type IN ('.$db->sanitize($search_type).')'; } if (!empty($search_description)) { $sql .= natural_search('cp.description', $search_description); diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index eb61b7e7807..2772137284b 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -27,12 +27,19 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) { - accessforbidden(); -} - $error = 0; +$permissiontoread = $user->admin; +$permissiontoadd = $user->admin; + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); + /* * Actions @@ -73,11 +80,13 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $linkback = '
    '.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("HRMSetup"), $linkback); +$newcardbutton = dolGetButtonTitle($langs->trans('NewEstablishment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/hrm/establishment/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + // Configuration header $head = hrm_admin_prepare_head(); -print dol_get_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user"); +print dol_get_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user", 0, $newcardbutton); -$sql = "SELECT e.rowid, e.label, e.address, e.zip, e.town, e.status"; +$sql = "SELECT e.rowid, e.rowid as ref, e.label, e.address, e.zip, e.town, e.status"; $sql .= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql .= " WHERE e.entity IN (".getEntity('establishment').')'; $sql .= $db->order($sortfield, $sortorder); @@ -135,11 +144,6 @@ if ($result) { print dol_get_fiche_end(); -// Buttons -print ''; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index 0131539071a..d19b15e3499 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -27,10 +27,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -if (!$user->admin) { - accessforbidden(); -} - $action = GETPOST('action', 'aZ09'); // Other parameters HRM_* @@ -38,9 +34,22 @@ $list = array( // 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example ); +$permissiontoread = $user->admin; +$permissiontoadd = $user->admin; + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); + + /* * Actions */ + if ($action == 'update') { $error = 0; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index bca81f2e45d..c63ab29a14a 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -58,7 +58,7 @@ class Establishment extends CommonObject /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto = 'building'; + public $picto = 'establishment'; /** * @var int ID @@ -428,34 +428,92 @@ class Establishment extends CommonObject } /** - * Return clicable name (with picto eventually) + * Return a link to the object card (with optionaly the picto) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @return string String with URL + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL */ - public function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $langs; + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; - $link = ''; - $linkend = ''; + $label = img_picto('', $this->picto).' '.$langs->trans("Establishment").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; - $picto = 'building'; + $url = DOL_URL_ROOT.'/hrm/establishment/card.php?id='.$this->id; - $label = ''.$langs->trans("Establishment").''; - $label .= '
    '.$langs->trans("Label").': '.$this->label; + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("Establishment"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink') { + $linkstart = ''; + if ($option == 'nolink') { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; if ($withpicto) { - $result .= ($link.img_object($label, $picto).$linkend); - } - if ($withpicto && $withpicto != 2) { - $result .= ' '; + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); } + if ($withpicto != 2) { - $result .= $link.$this->label.$linkend; + $result .= $this->ref; } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('establishmentdao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + return $result; } diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index a46ebfa28f3..caec6191d0d 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -19,6 +19,7 @@ * \file htdocs/hrm/establishment/card.php * \brief Page to show an establishment */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; @@ -28,11 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'hrm')); -// Security check -if (!$user->admin) { - accessforbidden(); -} - $error = 0; $action = GETPOST('action', 'aZ09'); @@ -55,6 +51,18 @@ $object = new Establishment($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +$permissiontoread = $user->admin; +$permissiontoadd = $user->admin; // Used by the include of actions_addupdatedelete.inc.php +$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; + +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); + /* * Actions @@ -80,9 +88,9 @@ if ($action == 'confirm_delete' && $confirm == "yes") { if (empty($error)) { $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = $_POST["country_id"]; + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST("country_id", 'int'); $object->status = GETPOST('status', 'int'); $object->fk_user_author = $user->id; $object->datec = dol_now(); @@ -165,7 +173,7 @@ if ($action == 'create') { // Name print ''; print ''.$form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print ''; // Entity @@ -252,7 +260,7 @@ if (($id || $ref) && $action == 'edit') { $head = establishment_prepare_head($object); if ($action == 'edit') { - print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building'); + print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, $object->picto); print '
    '."\n"; print ''; @@ -335,7 +343,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = establishment_prepare_head($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); + print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, $object->picto); // Confirmation to delete if ($action == 'delete') { diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index f72b381a2d8..517b76de93a 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -76,12 +76,17 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id; } +$permissiontoread = $user->admin; +$permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php +$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'mymodule', $object->id); - -$permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); +if (empty($conf->hrm->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); /* @@ -128,7 +133,7 @@ if ($object->id > 0) { $head = establishment_prepare_head($object); - print dol_get_fiche_head($head, 'info', $langs->trans("Establishment"), -1, 'building'); + print dol_get_fiche_head($head, 'info', $langs->trans("Establishment"), -1, $object->picto); // Object card // ------------------------------------------------------------ diff --git a/htdocs/hrm/index.html b/htdocs/hrm/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index e40ceb3f9ba..f169ce60b37 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -182,7 +182,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $sql .= " WHERE u.rowid = x.fk_user"; $sql .= " AND x.entity = ".$conf->entity; if (empty($user->rights->holiday->readall)) { - $sql .= ' AND x.fk_user IN ('.join(',', $childids).')'; + $sql .= ' AND x.fk_user IN ('.$db->sanitize(join(',', $childids)).')'; } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; @@ -263,7 +263,7 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) $sql .= " WHERE u.rowid = x.fk_user_author"; $sql .= " AND x.entity = ".$conf->entity; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { - $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')'; + $sql .= ' AND x.fk_user_author IN ('.$db->sanitize(join(',', $childids)).')'; } //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 50ab14dfce5..0783e6352a4 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -307,8 +307,8 @@ if ($step == 4 && $action == 'select_model') { if ($action == 'saveorder') { // Enregistrement de la position des champs - dol_syslog("boxorder=".$_GET['boxorder']." datatoimport=".$_GET["datatoimport"], LOG_DEBUG); - $part = explode(':', $_GET['boxorder']); + dol_syslog("boxorder=".GETPOST('boxorder')." datatoimport=".GETPOST("datatoimport"), LOG_DEBUG); + $part = explode(':', GETPOST('boxorder')); $colonne = $part[0]; $list = $part[1]; dol_syslog('column='.$colonne.' list='.$list); @@ -492,12 +492,16 @@ if ($step == 2 && $datatoimport) { print ''; print ''; + print '
    '; + print ''; $s = $langs->trans("ChooseFormatOfFileToImport", '{s1}'); $s = str_replace('{s1}', img_picto('', 'next'), $s); print $s; print '

    '; + print '
    '; + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; @@ -513,7 +517,9 @@ if ($step == 2 && $datatoimport) { print ''; $text = $objmodelimport->getDriverDescForKey($key); print ''; - print ''; + print ''; // Action button print '
    '.img_picto_common($key, $objmodelimport->getPictoForKey($key)).''.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).''.$langs->trans("DownloadEmptyExample").''; + print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample").''; + print ''; print ''.img_picto($langs->trans("SelectFormat"), 'next', 'class="fa-15x"').''; @@ -587,7 +593,7 @@ if ($step == 3 && $datatoimport) { print '
    '; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -598,8 +604,8 @@ if ($step == 3 && $datatoimport) { print ''; $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); - print ''.$langs->trans("DownloadEmptyExample").''; - + print ''; + print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample").''; print ''; print ''; @@ -890,7 +896,7 @@ if ($step == 4 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1374,7 +1380,7 @@ if ($step == 5 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1468,7 +1474,7 @@ if ($step == 5 && $datatoimport) { print '
    '; - print load_fiche_titre($langs->trans("InformationOnTargetTables"), '', ''); + print load_fiche_titre($langs->trans("InformationOnTargetTables"), '', 'file-import'); print '
    '; print '
    '; @@ -1812,7 +1818,7 @@ if ($step == 6 && $datatoimport) { print ''; print '
    '; - print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', ''); + print load_fiche_titre($langs->trans("InformationOnSourceFile"), '', 'file-export'); print '
    '; print '
    '; @@ -1875,8 +1881,7 @@ if ($step == 6 && $datatoimport) { print ''.$langs->trans("InformationOnTargetTables").''; print '
    '; print '
    '; - print ''; - //print ''; + print '
    '.$langs->trans("InformationOnTargetTables").'
    '; // Tables imported print ''; - // Actions - print ''; - print ''; + if ($object->status == $object::STATUS_VALIDATED) { + // Actions + print ''; + print ''; + } // Line to add a new line in inventory if ($object->status == $object::STATUS_VALIDATED) { @@ -431,7 +544,7 @@ if ($object->id > 0) { print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? GETPOST('fk_warehouse', 'int') : $object->fk_warehouse), 'fk_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth300'); print ''; print ''; if ($conf->productbatch->enabled) { print ''; print ''; // Actions @@ -453,7 +566,7 @@ if ($object->id > 0) { $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; - $sql .= ' WHERE id.fk_inventory = '.$object->id; + $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); $cacheOfProducts = array(); $cacheOfWarehouses = array(); @@ -504,16 +617,21 @@ if ($object->id > 0) { print ''; } - print ''; print ''; - print ''; - + if ($object->status == $object::STATUS_VALIDATED) { + $qty_view = GETPOST("id_".$obj->rowid) ? GETPOST("id_".$obj->rowid) : $obj->qty_view; + print ''; + print ''; + print ''; + } else { + print $obj->qty_view; + print ''; + } print ''; $i++; @@ -524,15 +642,10 @@ if ($object->id > 0) { print '
    '; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReader.php b/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReader.php deleted file mode 100644 index e35c4ee6255..00000000000 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReader.php +++ /dev/null @@ -1,31 +0,0 @@ - [MathTrig::class, 'SUMXMY2'], 'argumentCount' => '2', ], + 'SWITCH' => [ + 'category' => Category::CATEGORY_LOGICAL, + 'functionCall' => [Logical::class, 'statementSwitch'], + 'argumentCount' => '3+', + ], 'SYD' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Financial::class, 'SYD'], @@ -2207,8 +2212,8 @@ class Calculation private static function loadLocales() { $localeFileDirectory = __DIR__ . '/locale/'; - foreach (glob($localeFileDirectory . '/*', GLOB_ONLYDIR) as $filename) { - $filename = substr($filename, strlen($localeFileDirectory) + 1); + foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) { + $filename = substr($filename, strlen($localeFileDirectory)); if ($filename != 'en') { self::$validLocaleLanguages[] = $filename; } @@ -2413,7 +2418,6 @@ class Calculation if (strpos($locale, '_') !== false) { list($language) = explode('_', $locale); } - if (count(self::$validLocaleLanguages) == 1) { self::loadLocales(); } @@ -2704,7 +2708,7 @@ class Calculation * @param Cell $pCell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not * - * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return mixed */ @@ -2808,7 +2812,7 @@ class Calculation * @param string $cellID Address of the cell to calculate * @param Cell $pCell Cell to calculate * - * @throws Exception + * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return mixed */ @@ -2892,6 +2896,15 @@ class Calculation { $cellValue = null; + // Quote-Prefixed cell values cannot be formulae, but are treated as strings + if ($pCell !== null && $pCell->getStyle()->getQuotePrefix() === true) { + return self::wrapResult((string) $formula); + } + + if (preg_match('/^=\s*cmd\s*\|/miu', $formula) !== 0) { + return self::wrapResult($formula); + } + // Basic validation that this is indeed a formula // We simply return the cell value if not $formula = trim($formula); diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Category.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Category.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Database.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Database.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Database.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/DateTime.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/DateTime.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/Logger.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engine/Logger.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/Logger.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engineering.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Engineering.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/ExceptionHandler.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ExceptionHandler.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/ExceptionHandler.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/ExceptionHandler.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Financial.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Financial.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Financial.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaParser.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaParser.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaParser.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaParser.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaToken.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaToken.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/FormulaToken.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/FormulaToken.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Functions.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Functions.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Functions.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Functions.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Logical.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php similarity index 83% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Logical.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php index c36e3fca74f..3e6c5e74177 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Logical.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Logical.php @@ -273,6 +273,60 @@ class Logical return ($condition) ? $returnIfTrue : $returnIfFalse; } + /** + * STATEMENT_SWITCH. + * + * Returns corresponding with first match (any data type such as a string, numeric, date, etc). + * + * Excel Function: + * =SWITCH (expression, value1, result1, value2, result2, ... value_n, result_n [, default]) + * + * Expression + * The expression to compare to a list of values. + * value1, value2, ... value_n + * A list of values that are compared to expression. The SWITCH function is looking for the first value that matches the expression. + * result1, result2, ... result_n + * A list of results. The SWITCH function returns the corresponding result when a value matches expression. + * default + * Optional. It is the default to return if expression does not match any of the values (value1, value2, ... value_n). + * + * @category Logical Functions + * + * @param mixed $arguments Statement arguments + * + * @return mixed The value of matched expression + */ + public static function statementSwitch(...$arguments) + { + $result = Functions::VALUE(); + + if (count($arguments) > 0) { + $targetValue = Functions::flattenSingleValue($arguments[0]); + $argc = count($arguments) - 1; + $switchCount = floor($argc / 2); + $switchSatisfied = false; + $hasDefaultClause = $argc % 2 !== 0; + $defaultClause = $argc % 2 === 0 ? null : $arguments[count($arguments) - 1]; + + if ($switchCount) { + for ($index = 0; $index < $switchCount; ++$index) { + if ($targetValue == $arguments[$index * 2 + 1]) { + $result = $arguments[$index * 2 + 2]; + $switchSatisfied = true; + + break; + } + } + } + + if (!$switchSatisfied) { + $result = $hasDefaultClause ? $defaultClause : Functions::NA(); + } + } + + return $result; + } + /** * IFERROR. * diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/LookupRef.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/LookupRef.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php index 2a3c5582108..e6b0f3203f8 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/LookupRef.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class LookupRef @@ -473,8 +474,9 @@ class LookupRef $lookupValue = Functions::flattenSingleValue($lookupValue); $matchType = ($matchType === null) ? 1 : (int) Functions::flattenSingleValue($matchType); + $initialLookupValue = $lookupValue; // MATCH is not case sensitive - $lookupValue = strtolower($lookupValue); + $lookupValue = StringHelper::strToLower($lookupValue); // Lookup_value type has to be number, text, or logical values if ((!is_numeric($lookupValue)) && (!is_string($lookupValue)) && (!is_bool($lookupValue))) { @@ -502,7 +504,7 @@ class LookupRef } // Convert strings to lowercase for case-insensitive testing if (is_string($lookupArrayValue)) { - $lookupArray[$i] = strtolower($lookupArrayValue); + $lookupArray[$i] = StringHelper::strToLower($lookupArrayValue); } if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) { $lookupArray = array_slice($lookupArray, 0, $i - 1); @@ -522,9 +524,13 @@ class LookupRef if ($matchType == 0 || $matchType == 1) { foreach ($lookupArray as $i => $lookupArrayValue) { - if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) { + $onlyNumeric = is_numeric($lookupArrayValue) && is_numeric($lookupValue); + $onlyNumericExactMatch = $onlyNumeric && $lookupArrayValue == $lookupValue; + $nonOnlyNumericExactMatch = !$onlyNumeric && $lookupArrayValue === $lookupValue; + $exactMatch = $onlyNumericExactMatch || $nonOnlyNumericExactMatch; + if (($matchType == 0) && $exactMatch) { // exact match - return ++$i; + return $i + 1; } elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) { $i = array_search($i, $keySet); @@ -661,7 +667,9 @@ class LookupRef { reset($a); $firstColumn = key($a); - if (($aLower = strtolower($a[$firstColumn])) == ($bLower = strtolower($b[$firstColumn]))) { + $aLower = StringHelper::strToLower($a[$firstColumn]); + $bLower = StringHelper::strToLower($b[$firstColumn]); + if ($aLower == $bLower) { return 0; } @@ -707,11 +715,14 @@ class LookupRef uasort($lookup_array, ['self', 'vlookupSort']); } + $lookupLower = StringHelper::strToLower($lookup_value); $rowNumber = $rowValue = false; foreach ($lookup_array as $rowKey => $rowData) { + $firstLower = StringHelper::strToLower($rowData[$firstColumn]); + // break if we have passed possible keys if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || - (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)))) { + (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))) { break; } // remember the last key, but only if datatypes match @@ -719,17 +730,15 @@ class LookupRef (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))) { if ($not_exact_match) { $rowNumber = $rowKey; - $rowValue = $rowData[$firstColumn]; continue; - } elseif ((strtolower($rowData[$firstColumn]) == strtolower($lookup_value)) + } elseif (($firstLower == $lookupLower) // Spreadsheets software returns first exact match, // we have sorted and we might have broken key orders // we want the first one (by its initial index) && (($rowNumber == false) || ($rowKey < $rowNumber)) ) { $rowNumber = $rowKey; - $rowValue = $rowData[$firstColumn]; } } } @@ -782,8 +791,11 @@ class LookupRef // break if we have passed possible keys $bothNumeric = is_numeric($lookup_value) && is_numeric($rowData); $bothNotNumeric = !is_numeric($lookup_value) && !is_numeric($rowData); + $lookupLower = StringHelper::strToLower($lookup_value); + $rowDataLower = StringHelper::strToLower($rowData); + if (($bothNumeric && $rowData > $lookup_value) || - ($bothNotNumeric && strtolower($rowData) > strtolower($lookup_value))) { + ($bothNotNumeric && $rowDataLower > $lookupLower)) { break; } @@ -793,7 +805,7 @@ class LookupRef $rowNumber = $rowKey; continue; - } elseif (strtolower($rowData) === strtolower($lookup_value) + } elseif ($rowDataLower === $lookupLower && ($rowNumber === null || $rowKey < $rowNumber) ) { $rowNumber = $rowKey; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/MathTrig.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/MathTrig.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php index 9170196bae5..a06f3a384c9 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/MathTrig.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -1224,11 +1224,12 @@ class MathTrig } $testCondition = '=' . $arg . $condition; + $sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0; - if (is_numeric($sumArgs[$key]) && + if (is_numeric($sumValue) && Calculation::getInstance()->_calculateFormulaValue($testCondition)) { // Is it a value within our criteria and only numeric can be added to the result - $returnValue += $sumArgs[$key]; + $returnValue += $sumValue; } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Statistical.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Statistical.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/TextData.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/TextData.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Token/Stack.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/Token/Stack.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Token/Stack.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/functionlist.txt b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/functionlist.txt rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt index ee87c17f63c..4a5cd265ba8 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/functionlist.txt +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/functionlist.txt @@ -337,6 +337,7 @@ SUMSQ SUMX2MY2 SUMX2PY2 SUMXMY2 +SWITCH SYD T TAN diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/bg/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/bg/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/cs/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/cs/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/da/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/da/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/de/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/de/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/en/uk/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/en/uk/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/en/uk/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/en/uk/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/es/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/es/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fi/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fi/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/fr/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/fr/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/hu/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/hu/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/it/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/it/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/nl/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/nl/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/no/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/no/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pl/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pl/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/br/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/br/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/pt/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/pt/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/ru/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/ru/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/sv/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/sv/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/config b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/config similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/config rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/config diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/functions b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/functions similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Calculation/locale/tr/functions rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/locale/tr/functions diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/AdvancedValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index efb8e5ef368..4052c23cb97 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -16,6 +16,8 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * + * @throws \PhpOffice\PhpSpreadsheet\Exception + * * @return bool */ public function bindValue(Cell $cell, $value = null) diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Cell.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Cell.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php index 416b4a9909b..813eee4a091 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Cell.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php @@ -523,7 +523,7 @@ class Cell /** * If this cell is in a merge range, then return the range. * - * @return string + * @return false|string */ public function getMergeRange() { diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Coordinate.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Coordinate.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php index 12e3b689727..5e20ec6d9dc 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Coordinate.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php @@ -157,14 +157,12 @@ abstract class Coordinate } // Build range - $imploded = []; $counter = count($pRange); for ($i = 0; $i < $counter; ++$i) { $pRange[$i] = implode(':', $pRange[$i]); } - $imploded = implode(',', $pRange); - return $imploded; + return implode(',', $pRange); } /** diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataType.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataType.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidation.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidation.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DataValidator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DefaultValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php similarity index 97% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DefaultValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 7cbb6cca27f..0e6433a4ec8 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -14,6 +14,8 @@ class DefaultValueBinder implements IValueBinder * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * + * @throws \PhpOffice\PhpSpreadsheet\Exception + * * @return bool */ public function bindValue(Cell $cell, $value) diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Hyperlink.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/Hyperlink.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Cell/IValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Cell/IValueBinder.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php new file mode 100644 index 00000000000..0552677f295 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -0,0 +1,31 @@ +setValueExplicit((string) $value, DataType::TYPE_STRING); + + // Done! + return true; + } +} diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Axis.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Axis.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php index 52f70431453..3d1dd22262d 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Axis.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Axis.php @@ -365,10 +365,10 @@ class Axis extends Properties } /** - * Set Shadow Properties from Maped Values. + * Set Shadow Properties from Mapped Values. * * @param array $properties_map - * @param * $reference + * @param mixed &$reference * * @return Axis */ diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Chart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Chart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Chart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeries.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeries.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeries.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeriesValues.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/DataSeriesValues.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/DataSeriesValues.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/GridLines.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/GridLines.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php index 6e9e39dcf50..8cc83e5540c 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/GridLines.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/GridLines.php @@ -319,7 +319,7 @@ class GridLines extends Properties * Set Shadow Properties Values. * * @param array $properties_map - * @param * $reference + * @param mixed &$reference * * @return GridLines */ @@ -439,7 +439,7 @@ class GridLines extends Properties { if ($size !== null) { $this->activateObject(); - $softEdges['size'] = (string) $this->getExcelPointsWidth($size); + $this->softEdges['size'] = (string) $this->getExcelPointsWidth($size); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Layout.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Layout.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php index fb5a53a063e..a8a96d2f1cb 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Layout.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Layout.php @@ -175,13 +175,13 @@ class Layout /** * Set X-Mode. * - * @param X-Mode $value + * @param string $value * * @return Layout */ public function setXMode($value) { - $this->xMode = $value; + $this->xMode = (string) $value; return $this; } @@ -199,13 +199,13 @@ class Layout /** * Set Y-Mode. * - * @param Y-Mode $value + * @param string $value * * @return Layout */ public function setYMode($value) { - $this->yMode = $value; + $this->yMode = (string) $value; return $this; } @@ -223,13 +223,13 @@ class Layout /** * Set X-Position. * - * @param X-Position $value + * @param float $value * * @return Layout */ public function setXPosition($value) { - $this->xPos = $value; + $this->xPos = (float) $value; return $this; } @@ -247,13 +247,13 @@ class Layout /** * Set Y-Position. * - * @param Y-Position $value + * @param float $value * * @return Layout */ public function setYPosition($value) { - $this->yPos = $value; + $this->yPos = (float) $value; return $this; } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Legend.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Legend.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Legend.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/PlotArea.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/PlotArea.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/PlotArea.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Properties.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Properties.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/IRenderer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/IRenderer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/JpGraph.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/PHP Charting Libraries.txt diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/Polyfill.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Renderer/Polyfill.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/Polyfill.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Title.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Chart/Title.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Title.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Cells.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Cells.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php index 80a43220988..84c3d3009ca 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Cells.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php @@ -241,7 +241,7 @@ class Cells */ public function getHighestColumn($row = null) { - if ($row == null) { + if ($row === null) { $colRow = $this->getHighestRowAndColumn(); return $colRow['column']; @@ -259,7 +259,7 @@ class Cells $columnList[] = Coordinate::columnIndexFromString($c); } - return Coordinate::stringFromColumnIndex(max($columnList) + 1); + return Coordinate::stringFromColumnIndex(max($columnList)); } /** @@ -272,7 +272,7 @@ class Cells */ public function getHighestRow($column = null) { - if ($column == null) { + if ($column === null) { $colRow = $this->getHighestRowAndColumn(); return $colRow['row']; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/CellsFactory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/CellsFactory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Memory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Collection/Memory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Comment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Comment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Comment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Document/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Document/Properties.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php index bbac96d92a8..1a432db0497 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Document/Properties.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Properties.php @@ -418,7 +418,7 @@ class Properties * * @param string $propertyName * - * @return string + * @return mixed */ public function getCustomPropertyValue($propertyName) { diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Document/Security.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Security.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Document/Security.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Document/Security.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/HashTable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/HashTable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/HashTable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Html.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Migrator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Migrator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Migrator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Migrator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Sample.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Sample.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Helper/Sample.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Sample.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/IComparable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IComparable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/IComparable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IComparable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/IOFactory.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/IOFactory.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/NamedRange.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedRange.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/NamedRange.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/NamedRange.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/BaseReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php similarity index 52% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/BaseReader.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php index c191c3f8d8e..f7af1557fff 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/BaseReader.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/BaseReader.php @@ -55,27 +55,16 @@ abstract class BaseReader implements IReader */ protected $securityScanner; - /** - * Read data only? - * If this is true, then the Reader will only read data values for cells, it will not read any formatting information. - * If false (the default) it will read data and formatting. - * - * @return bool - */ + public function __construct() + { + $this->readFilter = new DefaultReadFilter(); + } + public function getReadDataOnly() { return $this->readDataOnly; } - /** - * Set read data only - * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. - * Set to false (the default) to advise the Reader to read both data and formatting for cells. - * - * @param bool $pValue - * - * @return IReader - */ public function setReadDataOnly($pValue) { $this->readDataOnly = (bool) $pValue; @@ -83,27 +72,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read empty cells? - * If this is true (the default), then the Reader will read data values for all cells, irrespective of value. - * If false it will not read data for cells containing a null value or an empty string. - * - * @return bool - */ public function getReadEmptyCells() { return $this->readEmptyCells; } - /** - * Set read empty cells - * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. - * Set to false to advise the Reader to ignore cells containing a null value or an empty string. - * - * @param bool $pValue - * - * @return IReader - */ public function setReadEmptyCells($pValue) { $this->readEmptyCells = (bool) $pValue; @@ -111,29 +84,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read charts in workbook? - * If this is true, then the Reader will include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * If false (the default) it will ignore any charts defined in the workbook file. - * - * @return bool - */ public function getIncludeCharts() { return $this->includeCharts; } - /** - * Set read charts in workbook - * Set to true, to advise the Reader to include any charts that exist in the workbook. - * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. - * Set to false (the default) to discard charts. - * - * @param bool $pValue - * - * @return IReader - */ public function setIncludeCharts($pValue) { $this->includeCharts = (bool) $pValue; @@ -141,27 +96,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Get which sheets to load - * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null - * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed - */ public function getLoadSheetsOnly() { return $this->loadSheetsOnly; } - /** - * Set which sheets to load. - * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook - * - * @return IReader - */ public function setLoadSheetsOnly($value) { if ($value === null) { @@ -173,12 +112,6 @@ abstract class BaseReader implements IReader return $this; } - /** - * Set all sheets to load - * Tells the Reader to load all worksheets from the workbook. - * - * @return IReader - */ public function setLoadAllSheets() { $this->loadSheetsOnly = null; @@ -186,23 +119,11 @@ abstract class BaseReader implements IReader return $this; } - /** - * Read filter. - * - * @return IReadFilter - */ public function getReadFilter() { return $this->readFilter; } - /** - * Set read filter. - * - * @param IReadFilter $pValue - * - * @return IReader - */ public function setReadFilter(IReadFilter $pValue) { $this->readFilter = $pValue; @@ -210,7 +131,7 @@ abstract class BaseReader implements IReader return $this; } - public function getSecuritySCanner() + public function getSecurityScanner() { if (property_exists($this, 'securityScanner')) { return $this->securityScanner; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Csv.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Csv.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php index 25f244c1181..81ca1a8cf3e 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Csv.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Csv.php @@ -62,7 +62,7 @@ class Csv extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** @@ -143,7 +143,7 @@ class Csv extends BaseReader return; } - return $this->skipBOM(); + $this->skipBOM(); } /** @@ -155,7 +155,7 @@ class Csv extends BaseReader return; } - $potentialDelimiters = [',', ';', "\t", '|', ':', ' ']; + $potentialDelimiters = [',', ';', "\t", '|', ':', ' ', '~']; $counts = []; foreach ($potentialDelimiters as $delimiter) { $counts[$delimiter] = []; @@ -184,8 +184,9 @@ class Csv extends BaseReader // If number of lines is 0, nothing to infer : fall back to the default if ($numberLines === 0) { $this->delimiter = reset($potentialDelimiters); + $this->skipBOM(); - return $this->skipBOM(); + return; } // Calculate the mean square deviations for each delimiter (ignoring delimiters that haven't been found consistently) @@ -230,7 +231,7 @@ class Csv extends BaseReader $this->delimiter = reset($potentialDelimiters); } - return $this->skipBOM(); + $this->skipBOM(); } /** @@ -254,15 +255,13 @@ class Csv extends BaseReader $line = $line . $newLine; // Drop everything that is enclosed to avoid counting false positives in enclosures - $enclosure = preg_quote($this->enclosure, '/'); - $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/U', '', $line); + $enclosure = '(?escapeCharacter, '/') . ')' + . preg_quote($this->enclosure, '/'); + $line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line); // See if we have any enclosures left in the line - $matches = []; - preg_match('/(' . $enclosure . ')/', $line, $matches); - - // if we still have an enclosure then we need to read the next line aswell - if (count($matches) > 0) { + // if we still have an enclosure then we need to read the next line as well + if (preg_match('/(' . $enclosure . ')/', $line) > 0) { $line = $this->getNextLine($line); } @@ -547,7 +546,8 @@ class Csv extends BaseReader fclose($this->fileHandle); // Trust file extension if any - if (strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)) === 'csv') { + $extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)); + if (in_array($extension, ['csv', 'tsv'])) { return true; } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/DefaultReadFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/DefaultReadFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/DefaultReadFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/DefaultReadFilter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Gnumeric.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Gnumeric.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php index 16f1925a738..7445ef1bf25 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Gnumeric.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -36,7 +36,7 @@ class Gnumeric extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->referenceHelper = ReferenceHelper::getInstance(); $this->securityScanner = XmlScanner::getInstance($this); } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php similarity index 67% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php index d9f25a3166d..2e823f03bb5 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Html.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Html.php @@ -12,6 +12,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\Fill; +use PhpOffice\PhpSpreadsheet\Style\Font; +use PhpOffice\PhpSpreadsheet\Style\Style; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; /** PhpSpreadsheet root directory */ @@ -96,6 +99,26 @@ class Html extends BaseReader ], ], ], // Bottom border + 'strong' => [ + 'font' => [ + 'bold' => true, + ], + ], // Bold + 'b' => [ + 'font' => [ + 'bold' => true, + ], + ], // Bold + 'i' => [ + 'font' => [ + 'italic' => true, + ], + ], // Italic + 'em' => [ + 'font' => [ + 'italic' => true, + ], + ], // Italic ]; protected $rowspan = []; @@ -105,7 +128,7 @@ class Html extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -295,11 +318,9 @@ class Html extends BaseReader switch ($child->nodeName) { case 'meta': foreach ($attributeArray as $attributeName => $attributeValue) { - switch ($attributeName) { - case 'content': - // TODO - // Extract character set, so we can convert to UTF-8 if required - break; + // Extract character set, so we can convert to UTF-8 if required + if ($attributeName === 'charset') { + $this->setInputEncoding($attributeValue); } } $this->processDomElement($child, $sheet, $row, $column, $cellContent); @@ -334,6 +355,10 @@ class Html extends BaseReader $cellContent .= ' '; } + if (isset($this->formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); + } + break; case 'hr': $this->flushCell($sheet, $column, $row, $cellContent); @@ -423,6 +448,10 @@ class Html extends BaseReader $column = 'A'; } + break; + case 'img': + $this->insertImage($sheet, $column, $row, $attributeArray); + break; case 'table': $this->flushCell($sheet, $column, $row, $cellContent); @@ -448,6 +477,11 @@ class Html extends BaseReader $column = $this->getTableStartColumn(); $cellContent = ''; $this->processDomElement($child, $sheet, $row, $column, $cellContent); + + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } + ++$row; break; @@ -501,6 +535,27 @@ class Html extends BaseReader ] ); } + + if (isset($attributeArray['width'])) { + $sheet->getColumnDimension($column)->setWidth($attributeArray['width']); + } + + if (isset($attributeArray['height'])) { + $sheet->getRowDimension($row)->setRowHeight($attributeArray['height']); + } + + if (isset($attributeArray['align'])) { + $sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']); + } + + if (isset($attributeArray['valign'])) { + $sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']); + } + + if (isset($attributeArray['data-format'])) { + $sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']); + } + ++$column; break; @@ -608,36 +663,271 @@ class Html extends BaseReader return; } - $supported_styles = ['background-color', 'color']; + $cellStyle = $sheet->getStyle($column . $row); // add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color $styles = explode(';', $attributeArray['style']); foreach ($styles as $st) { $value = explode(':', $st); + $styleName = isset($value[0]) ? trim($value[0]) : null; + $styleValue = isset($value[1]) ? trim($value[1]) : null; - if (empty(trim($value[0])) || !in_array(trim($value[0]), $supported_styles)) { + if (!$styleName) { continue; } - //check if has #, so we can get clean hex - if (substr(trim($value[1]), 0, 1) == '#') { - $style_color = substr(trim($value[1]), 1); - } - - if (empty($style_color)) { - continue; - } - - switch (trim($value[0])) { + switch ($styleName) { + case 'background': case 'background-color': - $sheet->getStyle($column . $row)->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => "{$style_color}"]]]); + $styleColor = $this->getStyleColor($styleValue); + + if (!$styleColor) { + continue 2; + } + + $cellStyle->applyFromArray(['fill' => ['fillType' => Fill::FILL_SOLID, 'color' => ['rgb' => $styleColor]]]); break; case 'color': - $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "{$style_color}"]]]); + $styleColor = $this->getStyleColor($styleValue); + + if (!$styleColor) { + continue 2; + } + + $cellStyle->applyFromArray(['font' => ['color' => ['rgb' => $styleColor]]]); + + break; + + case 'border': + $this->setBorderStyle($cellStyle, $styleValue, 'allBorders'); + + break; + + case 'border-top': + $this->setBorderStyle($cellStyle, $styleValue, 'top'); + + break; + + case 'border-bottom': + $this->setBorderStyle($cellStyle, $styleValue, 'bottom'); + + break; + + case 'border-left': + $this->setBorderStyle($cellStyle, $styleValue, 'left'); + + break; + + case 'border-right': + $this->setBorderStyle($cellStyle, $styleValue, 'right'); + + break; + + case 'font-size': + $cellStyle->getFont()->setSize( + (float) $styleValue + ); + + break; + + case 'font-weight': + if ($styleValue === 'bold' || $styleValue >= 500) { + $cellStyle->getFont()->setBold(true); + } + + break; + + case 'font-style': + if ($styleValue === 'italic') { + $cellStyle->getFont()->setItalic(true); + } + + break; + + case 'font-family': + $cellStyle->getFont()->setName(str_replace('\'', '', $styleValue)); + + break; + + case 'text-decoration': + switch ($styleValue) { + case 'underline': + $cellStyle->getFont()->setUnderline(Font::UNDERLINE_SINGLE); + + break; + case 'line-through': + $cellStyle->getFont()->setStrikethrough(true); + + break; + } + + break; + + case 'text-align': + $cellStyle->getAlignment()->setHorizontal($styleValue); + + break; + + case 'vertical-align': + $cellStyle->getAlignment()->setVertical($styleValue); + + break; + + case 'width': + $sheet->getColumnDimension($column)->setWidth( + str_replace('px', '', $styleValue) + ); + + break; + + case 'height': + $sheet->getRowDimension($row)->setRowHeight( + str_replace('px', '', $styleValue) + ); + + break; + + case 'word-wrap': + $cellStyle->getAlignment()->setWrapText( + $styleValue === 'break-word' + ); + + break; + + case 'text-indent': + $cellStyle->getAlignment()->setIndent( + (int) str_replace(['px'], '', $styleValue) + ); break; } } } + + /** + * Check if has #, so we can get clean hex. + * + * @param $value + * + * @return null|string + */ + public function getStyleColor($value) + { + if (strpos($value, '#') === 0) { + return substr($value, 1); + } + + return null; + } + + /** + * @param Worksheet $sheet + * @param string $column + * @param int $row + * @param array $attributes + * + * @throws \PhpOffice\PhpSpreadsheet\Exception + */ + private function insertImage(Worksheet $sheet, $column, $row, array $attributes) + { + if (!isset($attributes['src'])) { + return; + } + + $src = urldecode($attributes['src']); + $width = isset($attributes['width']) ? (float) $attributes['width'] : null; + $height = isset($attributes['height']) ? (float) $attributes['height'] : null; + $name = isset($attributes['alt']) ? (float) $attributes['alt'] : null; + + $drawing = new Drawing(); + $drawing->setPath($src); + $drawing->setWorksheet($sheet); + $drawing->setCoordinates($column . $row); + $drawing->setOffsetX(0); + $drawing->setOffsetY(10); + $drawing->setResizeProportional(true); + + if ($name) { + $drawing->setName($name); + } + + if ($width) { + $drawing->setWidth((int) $width); + } + + if ($height) { + $drawing->setHeight((int) $height); + } + + $sheet->getColumnDimension($column)->setWidth( + $drawing->getWidth() / 6 + ); + + $sheet->getRowDimension($row)->setRowHeight( + $drawing->getHeight() * 0.9 + ); + } + + /** + * Map html border style to PhpSpreadsheet border style. + * + * @param string $style + * + * @return null|string + */ + public function getBorderStyle($style) + { + switch ($style) { + case 'solid': + return Border::BORDER_THIN; + case 'dashed': + return Border::BORDER_DASHED; + case 'dotted': + return Border::BORDER_DOTTED; + case 'medium': + return Border::BORDER_MEDIUM; + case 'thick': + return Border::BORDER_THICK; + case 'none': + return Border::BORDER_NONE; + case 'dash-dot': + return Border::BORDER_DASHDOT; + case 'dash-dot-dot': + return Border::BORDER_DASHDOTDOT; + case 'double': + return Border::BORDER_DOUBLE; + case 'hair': + return Border::BORDER_HAIR; + case 'medium-dash-dot': + return Border::BORDER_MEDIUMDASHDOT; + case 'medium-dash-dot-dot': + return Border::BORDER_MEDIUMDASHDOTDOT; + case 'medium-dashed': + return Border::BORDER_MEDIUMDASHED; + case 'slant-dash-dot': + return Border::BORDER_SLANTDASHDOT; + } + + return null; + } + + /** + * @param Style $cellStyle + * @param string $styleValue + * @param string $type + */ + private function setBorderStyle(Style $cellStyle, $styleValue, $type) + { + list(, $borderStyle, $color) = explode(' ', $styleValue); + + $cellStyle->applyFromArray([ + 'borders' => [ + $type => [ + 'borderStyle' => $this->getBorderStyle($borderStyle), + 'color' => ['rgb' => $this->getStyleColor($color)], + ], + ], + ]); + } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReadFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReadFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/IReadFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReadFilter.php diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php new file mode 100644 index 00000000000..70a7a200d78 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/IReader.php @@ -0,0 +1,137 @@ +readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -52,7 +52,7 @@ class Ods extends BaseReader $stat = $zip->statName('mimetype'); if ($stat && ($stat['size'] <= 255)) { $mimeType = $zip->getFromName($stat['name']); - } elseif ($stat = $zip->statName('META-INF/manifest.xml')) { + } elseif ($zip->statName('META-INF/manifest.xml')) { $xml = simplexml_load_string( $this->securityScanner->scan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', @@ -265,7 +265,7 @@ class Ods extends BaseReader $zip = new ZipArchive(); if (!$zip->open($pFilename)) { - throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.'); + throw new Exception("Could not open {$pFilename} for reading! Error opening file."); } // Meta @@ -275,97 +275,13 @@ class Ods extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + if ($xml === false) { + throw new Exception('Unable to read data from {$pFilename}'); + } + $namespacesMeta = $xml->getNamespaces(true); - $docProps = $spreadsheet->getProperties(); - $officeProperty = $xml->children($namespacesMeta['office']); - foreach ($officeProperty as $officePropertyData) { - $officePropertyDC = []; - if (isset($namespacesMeta['dc'])) { - $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); - } - foreach ($officePropertyDC as $propertyName => $propertyValue) { - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'title': - $docProps->setTitle($propertyValue); - - break; - case 'subject': - $docProps->setSubject($propertyValue); - - break; - case 'creator': - $docProps->setCreator($propertyValue); - $docProps->setLastModifiedBy($propertyValue); - - break; - case 'date': - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - $docProps->setModified($creationDate); - - break; - case 'description': - $docProps->setDescription($propertyValue); - - break; - } - } - $officePropertyMeta = []; - if (isset($namespacesMeta['dc'])) { - $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); - } - foreach ($officePropertyMeta as $propertyName => $propertyValue) { - $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); - $propertyValue = (string) $propertyValue; - switch ($propertyName) { - case 'initial-creator': - $docProps->setCreator($propertyValue); - - break; - case 'keyword': - $docProps->setKeywords($propertyValue); - - break; - case 'creation-date': - $creationDate = strtotime($propertyValue); - $docProps->setCreated($creationDate); - - break; - case 'user-defined': - $propertyValueType = Properties::PROPERTY_TYPE_STRING; - foreach ($propertyValueAttributes as $key => $value) { - if ($key == 'name') { - $propertyValueName = (string) $value; - } elseif ($key == 'value-type') { - switch ($value) { - case 'date': - $propertyValue = Properties::convertProperty($propertyValue, 'date'); - $propertyValueType = Properties::PROPERTY_TYPE_DATE; - - break; - case 'boolean': - $propertyValue = Properties::convertProperty($propertyValue, 'bool'); - $propertyValueType = Properties::PROPERTY_TYPE_BOOLEAN; - - break; - case 'float': - $propertyValue = Properties::convertProperty($propertyValue, 'r4'); - $propertyValueType = Properties::PROPERTY_TYPE_FLOAT; - - break; - default: - $propertyValueType = Properties::PROPERTY_TYPE_STRING; - } - } - } - $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); - - break; - } - } - } + (new DocumentProperties($spreadsheet))->load($xml, $namespacesMeta); // Content @@ -513,7 +429,7 @@ class Ods extends BaseReader foreach ($paragraphs as $pData) { $dataArray[] = $this->scanElementForText($pData); } - $allCellDataText = implode($dataArray, "\n"); + $allCellDataText = implode("\n", $dataArray); $type = $cellData->getAttributeNS($officeNs, 'value-type'); @@ -580,12 +496,12 @@ class Ods extends BaseReader ); $dataValue = Date::formattedPHPToExcel( - $year, - $month, - $day, - $hour, - $minute, - $second + (int) $year, + (int) $month, + (int) $day, + (int) $hour, + (int) $minute, + (int) $second ); if ($dataValue != floor($dataValue)) { diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php new file mode 100644 index 00000000000..8b6122c56e7 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Ods/Properties.php @@ -0,0 +1,136 @@ +spreadsheet = $spreadsheet; + } + + public function load(\SimpleXMLElement $xml, $namespacesMeta) + { + $docProps = $this->spreadsheet->getProperties(); + $officeProperty = $xml->children($namespacesMeta['office']); + foreach ($officeProperty as $officePropertyData) { + /** @var \SimpleXMLElement $officePropertyData */ + $officePropertiesDC = (object) []; + if (isset($namespacesMeta['dc'])) { + $officePropertiesDC = $officePropertyData->children($namespacesMeta['dc']); + } + $this->setCoreProperties($docProps, $officePropertiesDC); + + $officePropertyMeta = (object) []; + if (isset($namespacesMeta['dc'])) { + $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); + } + foreach ($officePropertyMeta as $propertyName => $propertyValue) { + $this->setMetaProperties($namespacesMeta, $propertyValue, $propertyName, $docProps); + } + } + } + + private function setCoreProperties(DocumentProperties $docProps, \SimpleXMLElement $officePropertyDC) + { + foreach ($officePropertyDC as $propertyName => $propertyValue) { + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'title': + $docProps->setTitle($propertyValue); + + break; + case 'subject': + $docProps->setSubject($propertyValue); + + break; + case 'creator': + $docProps->setCreator($propertyValue); + $docProps->setLastModifiedBy($propertyValue); + + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + $docProps->setModified($creationDate); + + break; + case 'keyword': + $docProps->setKeywords($propertyValue); + + break; + case 'description': + $docProps->setDescription($propertyValue); + + break; + } + } + } + + private function setMetaProperties( + $namespacesMeta, + \SimpleXMLElement $propertyValue, + $propertyName, + DocumentProperties $docProps + ) { + $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); + $propertyValue = (string) $propertyValue; + switch ($propertyName) { + case 'initial-creator': + $docProps->setCreator($propertyValue); + + break; + case 'keyword': + $docProps->setKeywords($propertyValue); + + break; + case 'creation-date': + $creationDate = strtotime($propertyValue); + $docProps->setCreated($creationDate); + + break; + case 'user-defined': + $this->setUserDefinedProperty($propertyValueAttributes, $propertyValue, $docProps); + + break; + } + } + + private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps) + { + $propertyValueName = ''; + $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; + foreach ($propertyValueAttributes as $key => $value) { + if ($key == 'name') { + $propertyValueName = (string) $value; + } elseif ($key == 'value-type') { + switch ($value) { + case 'date': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'date'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_DATE; + + break; + case 'boolean': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'bool'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_BOOLEAN; + + break; + case 'float': + $propertyValue = DocumentProperties::convertProperty($propertyValue, 'r4'); + $propertyValueType = DocumentProperties::PROPERTY_TYPE_FLOAT; + + break; + default: + $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; + } + } + } + + $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); + } +} diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Security/XmlScanner.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php similarity index 54% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Security/XmlScanner.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index b5f7ac60fdc..732f0bf612c 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Security; use PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Settings; class XmlScanner { - /** - * Identifies whether the thread-safe libxmlDisableEntityLoader() function is available. - * - * @var bool - */ - private $libxmlDisableEntityLoader = false; - /** * String used to identify risky xml elements. * @@ -22,10 +16,16 @@ class XmlScanner private $callback; - private function __construct($pattern = 'pattern = $pattern; - $this->libxmlDisableEntityLoader = $this->identifyLibxmlDisableEntityLoaderAvailability(); + + $this->disableEntityLoaderCheck(); + + // A fatal error will bypass the destructor, so we register a shutdown here + register_shutdown_function([__CLASS__, 'shutdown']); } public static function getInstance(Reader\IReader $reader) @@ -43,7 +43,7 @@ class XmlScanner } } - private function identifyLibxmlDisableEntityLoaderAvailability() + public static function threadSafeLibxmlDisableEntityLoaderAvailability() { if (PHP_MAJOR_VERSION == 7) { switch (PHP_MINOR_VERSION) { @@ -61,11 +61,54 @@ class XmlScanner return false; } + private function disableEntityLoaderCheck() + { + if (Settings::getLibXmlDisableEntityLoader()) { + $libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); + + if (self::$libxmlDisableEntityLoaderValue === null) { + self::$libxmlDisableEntityLoaderValue = $libxmlDisableEntityLoaderValue; + } + } + } + + public static function shutdown() + { + if (self::$libxmlDisableEntityLoaderValue !== null) { + libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue); + self::$libxmlDisableEntityLoaderValue = null; + } + } + + public function __destruct() + { + self::shutdown(); + } + public function setAdditionalCallback(callable $callback) { $this->callback = $callback; } + private function toUtf8($xml) + { + $pattern = '/encoding="(.*?)"/'; + $result = preg_match($pattern, $xml, $matches); + $charset = strtoupper($result ? $matches[1] : 'UTF-8'); + + if ($charset !== 'UTF-8') { + $xml = mb_convert_encoding($xml, 'UTF-8', $charset); + + $result = preg_match($pattern, $xml, $matches); + $charset = strtoupper($result ? $matches[1] : 'UTF-8'); + if ($charset !== 'UTF-8') { + throw new Reader\Exception('Suspicious Double-encoded XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); + } + } + + return $xml; + } + /** * Scan the XML for use of libxmlDisableEntityLoader) { - $previousLibxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true); - } + $this->disableEntityLoaderCheck(); - $pattern = '/encoding="(.*?)"/'; - $result = preg_match($pattern, $xml, $matches); - $charset = $result ? $matches[1] : 'UTF-8'; - - if ($charset !== 'UTF-8') { - $xml = mb_convert_encoding($xml, 'UTF-8', $charset); - } + $xml = $this->toUtf8($xml); // Don't rely purely on libxml_disable_entity_loader() $pattern = '/\\0?' . implode('\\0?', str_split($this->pattern)) . '\\0?/'; - try { - if (preg_match($pattern, $xml)) { - throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); - } + if (preg_match($pattern, $xml)) { + throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks'); + } - if ($this->callback !== null && is_callable($this->callback)) { - $xml = call_user_func($this->callback, $xml); - } - } finally { - if (isset($previousLibxmlDisableEntityLoaderValue)) { - libxml_disable_entity_loader($previousLibxmlDisableEntityLoaderValue); - } + if ($this->callback !== null && is_callable($this->callback)) { + $xml = call_user_func($this->callback, $xml); } return $xml; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Slk.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Slk.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php index 61e52334b5c..c1013c2eb22 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Slk.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Slk.php @@ -43,7 +43,7 @@ class Slk extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php index 514adae2743..bd2c9c1db5b 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php @@ -412,7 +412,7 @@ class Xls extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); } /** diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/ErrorCode.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/ErrorCode.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/MD5.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/MD5.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/MD5.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/MD5.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/RC4.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/RC4.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/Border.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/Border.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/Border.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/Border.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php similarity index 69% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php index 335f5d7e99c..5372fef9c13 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php @@ -4,10 +4,19 @@ namespace PhpOffice\PhpSpreadsheet\Reader; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; -use PhpOffice\PhpSpreadsheet\Document\Properties; use PhpOffice\PhpSpreadsheet\NamedRange; use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter; use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\ColumnAndRowAttributes; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\ConditionalStyles; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\DataValidations; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Hyperlinks; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\PageSetup; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Properties as PropertyReader; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\SheetViewOptions; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\SheetViews; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles; use PhpOffice\PhpSpreadsheet\ReferenceHelper; use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheet\Settings; @@ -20,11 +29,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Borders; use PhpOffice\PhpSpreadsheet\Style\Color; -use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Style\Style; -use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column; use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use SimpleXMLElement; @@ -52,7 +59,7 @@ class Xlsx extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->referenceHelper = ReferenceHelper::getInstance(); $this->securityScanner = XmlScanner::getInstance($this); } @@ -323,60 +330,6 @@ class Xlsx extends BaseReader return $contents; } - /** - * Set Worksheet column attributes by attributes array passed. - * - * @param Worksheet $docSheet - * @param string $column A, B, ... DX, ... - * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) - * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? - */ - private function setColumnAttributes(Worksheet $docSheet, $column, array $columnAttributes) - { - if (isset($columnAttributes['xfIndex'])) { - $docSheet->getColumnDimension($column)->setXfIndex($columnAttributes['xfIndex']); - } - if (isset($columnAttributes['visible'])) { - $docSheet->getColumnDimension($column)->setVisible($columnAttributes['visible']); - } - if (isset($columnAttributes['collapsed'])) { - $docSheet->getColumnDimension($column)->setCollapsed($columnAttributes['collapsed']); - } - if (isset($columnAttributes['outlineLevel'])) { - $docSheet->getColumnDimension($column)->setOutlineLevel($columnAttributes['outlineLevel']); - } - if (isset($columnAttributes['width'])) { - $docSheet->getColumnDimension($column)->setWidth($columnAttributes['width']); - } - } - - /** - * Set Worksheet row attributes by attributes array passed. - * - * @param Worksheet $docSheet - * @param int $row 1, 2, 3, ... 99, ... - * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) - * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? - */ - private function setRowAttributes(Worksheet $docSheet, $row, array $rowAttributes) - { - if (isset($rowAttributes['xfIndex'])) { - $docSheet->getRowDimension($row)->setXfIndex($rowAttributes['xfIndex']); - } - if (isset($rowAttributes['visible'])) { - $docSheet->getRowDimension($row)->setVisible($rowAttributes['visible']); - } - if (isset($rowAttributes['collapsed'])) { - $docSheet->getRowDimension($row)->setCollapsed($rowAttributes['collapsed']); - } - if (isset($rowAttributes['outlineLevel'])) { - $docSheet->getRowDimension($row)->setOutlineLevel($rowAttributes['outlineLevel']); - } - if (isset($rowAttributes['rowHeight'])) { - $docSheet->getRowDimension($row)->setRowHeight($rowAttributes['rowHeight']); - } - } - /** * Loads Spreadsheet from file. * @@ -456,70 +409,20 @@ class Xlsx extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + + $propertyReader = new PropertyReader($this->securityScanner, $excel->getProperties()); foreach ($rels->Relationship as $rel) { switch ($rel['Type']) { case 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $xmlCore->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); - $xmlCore->registerXPathNamespace('dcterms', 'http://purl.org/dc/terms/'); - $xmlCore->registerXPathNamespace('cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); - $docProps = $excel->getProperties(); - $docProps->setCreator((string) self::getArrayItem($xmlCore->xpath('dc:creator'))); - $docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath('cp:lastModifiedBy'))); - $docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:created')))); //! respect xsi:type - $docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:modified')))); //! respect xsi:type - $docProps->setTitle((string) self::getArrayItem($xmlCore->xpath('dc:title'))); - $docProps->setDescription((string) self::getArrayItem($xmlCore->xpath('dc:description'))); - $docProps->setSubject((string) self::getArrayItem($xmlCore->xpath('dc:subject'))); - $docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords'))); - $docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category'))); - } + $propertyReader->readCoreProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $docProps = $excel->getProperties(); - if (isset($xmlCore->Company)) { - $docProps->setCompany((string) $xmlCore->Company); - } - if (isset($xmlCore->Manager)) { - $docProps->setManager((string) $xmlCore->Manager); - } - } + $propertyReader->readExtendedProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties': - $xmlCore = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, "{$rel['Target']}")), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - if (is_object($xmlCore)) { - $docProps = $excel->getProperties(); - /** @var SimpleXMLElement $xmlProperty */ - foreach ($xmlCore as $xmlProperty) { - $cellDataOfficeAttributes = $xmlProperty->attributes(); - if (isset($cellDataOfficeAttributes['name'])) { - $propertyName = (string) $cellDataOfficeAttributes['name']; - $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - $attributeType = $cellDataOfficeChildren->getName(); - $attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; - $attributeValue = Properties::convertProperty($attributeValue, $attributeType); - $attributeType = Properties::convertPropertyType($attributeType); - $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); - } - } - } + $propertyReader->readCustomProperties($this->getFromZipArchive($zip, "{$rel['Target']}")); break; //Ribbon @@ -586,8 +489,7 @@ class Xlsx extends BaseReader } } } - $styles = []; - $cellStyles = []; + $xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" $xmlStyles = simplexml_load_string( @@ -595,6 +497,9 @@ class Xlsx extends BaseReader 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); + + $styles = []; + $cellStyles = []; $numFmts = null; if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; @@ -674,31 +579,10 @@ class Xlsx extends BaseReader } } - $dxfs = []; - if (!$this->readDataOnly && $xmlStyles) { - // Conditional Styles - if ($xmlStyles->dxfs) { - foreach ($xmlStyles->dxfs->dxf as $dxf) { - $style = new Style(false, true); - self::readStyle($style, $dxf); - $dxfs[] = $style; - } - } - // Cell Styles - if ($xmlStyles->cellStyles) { - foreach ($xmlStyles->cellStyles->cellStyle as $cellStyle) { - if ((int) ($cellStyle['builtinId']) == 0) { - if (isset($cellStyles[(int) ($cellStyle['xfId'])])) { - // Set default style - $style = new Style(); - self::readStyle($style, $cellStyles[(int) ($cellStyle['xfId'])]); - - // normal style, currently not using it for anything - } - } - } - } - } + $styleReader = new Styles($xmlStyles); + $styleReader->setStyleBaseData(self::$theme, $styles, $cellStyles); + $dxfs = $styleReader->dxfs($this->readDataOnly); + $styles = $styleReader->styles(); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" $xmlWorkbook = simplexml_load_string( @@ -765,134 +649,19 @@ class Xlsx extends BaseReader $docSheet->setSheetState((string) $eleSheet['state']); } - if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) { - if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { - $zoomScale = (int) ($xmlSheet->sheetViews->sheetView['zoomScale']); - if ($zoomScale <= 0) { - // setZoomScale will throw an Exception if the scale is less than or equals 0 - // that is OK when manually creating documents, but we should be able to read all documents - $zoomScale = 100; - } - - $docSheet->getSheetView()->setZoomScale($zoomScale); - } - if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { - $zoomScaleNormal = (int) ($xmlSheet->sheetViews->sheetView['zoomScaleNormal']); - if ($zoomScaleNormal <= 0) { - // setZoomScaleNormal will throw an Exception if the scale is less than or equals 0 - // that is OK when manually creating documents, but we should be able to read all documents - $zoomScaleNormal = 100; - } - - $docSheet->getSheetView()->setZoomScaleNormal($zoomScaleNormal); - } - if (isset($xmlSheet->sheetViews->sheetView['view'])) { - $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); - } - if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { - $docSheet->setShowGridLines(self::boolean((string) $xmlSheet->sheetViews->sheetView['showGridLines'])); - } - if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { - $docSheet->setShowRowColHeaders(self::boolean((string) $xmlSheet->sheetViews->sheetView['showRowColHeaders'])); - } - if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { - $docSheet->setRightToLeft(self::boolean((string) $xmlSheet->sheetViews->sheetView['rightToLeft'])); - } - if (isset($xmlSheet->sheetViews->sheetView->pane)) { - $xSplit = 0; - $ySplit = 0; - $topLeftCell = null; - - if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) { - $xSplit = (int) ($xmlSheet->sheetViews->sheetView->pane['xSplit']); - } - - if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) { - $ySplit = (int) ($xmlSheet->sheetViews->sheetView->pane['ySplit']); - } - - if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { - $topLeftCell = (string) $xmlSheet->sheetViews->sheetView->pane['topLeftCell']; - } - - $docSheet->freezePane(Coordinate::stringFromColumnIndex($xSplit + 1) . ($ySplit + 1), $topLeftCell); + if ($xmlSheet) { + if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) { + $sheetViews = new SheetViews($xmlSheet->sheetViews->sheetView, $docSheet); + $sheetViews->load(); } - if (isset($xmlSheet->sheetViews->sheetView->selection)) { - if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) { - $sqref = (string) $xmlSheet->sheetViews->sheetView->selection['sqref']; - $sqref = explode(' ', $sqref); - $sqref = $sqref[0]; - $docSheet->setSelectedCells($sqref); - } - } + $sheetViewOptions = new SheetViewOptions($docSheet, $xmlSheet); + $sheetViewOptions->load($this->getReadDataOnly()); + + (new ColumnAndRowAttributes($docSheet, $xmlSheet)) + ->load($this->getReadFilter(), $this->getReadDataOnly()); } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->tabColor)) { - if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { - $docSheet->getTabColor()->setARGB((string) $xmlSheet->sheetPr->tabColor['rgb']); - } - } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr['codeName'])) { - $docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName'], false); - } - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->outlinePr)) { - if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && - !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { - $docSheet->setShowSummaryRight(false); - } else { - $docSheet->setShowSummaryRight(true); - } - - if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && - !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { - $docSheet->setShowSummaryBelow(false); - } else { - $docSheet->setShowSummaryBelow(true); - } - } - - if (isset($xmlSheet->sheetPr, $xmlSheet->sheetPr->pageSetUpPr)) { - if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && - !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { - $docSheet->getPageSetup()->setFitToPage(false); - } else { - $docSheet->getPageSetup()->setFitToPage(true); - } - } - - if (isset($xmlSheet->sheetFormatPr)) { - if (isset($xmlSheet->sheetFormatPr['customHeight']) && - self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && - isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { - $docSheet->getDefaultRowDimension()->setRowHeight((float) $xmlSheet->sheetFormatPr['defaultRowHeight']); - } - if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { - $docSheet->getDefaultColumnDimension()->setWidth((float) $xmlSheet->sheetFormatPr['defaultColWidth']); - } - if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && - ((string) $xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { - $docSheet->getDefaultRowDimension()->setZeroHeight(true); - } - } - - if (isset($xmlSheet->printOptions) && !$this->readDataOnly) { - if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { - $docSheet->setShowGridlines(true); - } - if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { - $docSheet->setPrintGridlines(true); - } - if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { - $docSheet->getPageSetup()->setHorizontalCentered(true); - } - if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { - $docSheet->getPageSetup()->setVerticalCentered(true); - } - } - - $this->readColumnsAndRowsAttributes($xmlSheet, $docSheet); - if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { $cIndex = 1; // Cell Start from 1 foreach ($xmlSheet->sheetData->row as $row) { @@ -972,38 +741,39 @@ class Xlsx extends BaseReader break; } - // Check for numeric values - if (is_numeric($value) && $cellDataType != 's') { - if ($value == (int) $value) { - $value = (int) $value; - } elseif ($value == (float) $value) { - $value = (float) $value; - } elseif ($value == (float) $value) { - $value = (float) $value; + // read empty cells or the cells are not empty + if ($this->readEmptyCells || ($value !== null && $value !== '')) { + // Check for numeric values + if (is_numeric($value) && $cellDataType != 's') { + if ($value == (int) $value) { + $value = (int) $value; + } elseif ($value == (float) $value) { + $value = (float) $value; + } } - } - // Rich text? - if ($value instanceof RichText && $this->readDataOnly) { - $value = $value->getPlainText(); - } + // Rich text? + if ($value instanceof RichText && $this->readDataOnly) { + $value = $value->getPlainText(); + } - $cell = $docSheet->getCell($r); - // Assign value - if ($cellDataType != '') { - $cell->setValueExplicit($value, $cellDataType); - } else { - $cell->setValue($value); - } - if ($calculatedValue !== null) { - $cell->setCalculatedValue($calculatedValue); - } + $cell = $docSheet->getCell($r); + // Assign value + if ($cellDataType != '') { + $cell->setValueExplicit($value, $cellDataType); + } else { + $cell->setValue($value); + } + if ($calculatedValue !== null) { + $cell->setCalculatedValue($calculatedValue); + } - // Style information? - if ($c['s'] && !$this->readDataOnly) { - // no style index means 0, it seems - $cell->setXfIndex(isset($styles[(int) ($c['s'])]) ? - (int) ($c['s']) : 0); + // Style information? + if ($c['s'] && !$this->readDataOnly) { + // no style index means 0, it seems + $cell->setXfIndex(isset($styles[(int) ($c['s'])]) ? + (int) ($c['s']) : 0); + } } $rowIndex += 1; } @@ -1011,49 +781,8 @@ class Xlsx extends BaseReader } } - $conditionals = []; if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { - foreach ($xmlSheet->conditionalFormatting as $conditional) { - foreach ($conditional->cfRule as $cfRule) { - if (((string) $cfRule['type'] == Conditional::CONDITION_NONE || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) && isset($dxfs[(int) ($cfRule['dxfId'])])) { - $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; - } - } - } - - foreach ($conditionals as $ref => $cfRules) { - ksort($cfRules); - $conditionalStyles = []; - foreach ($cfRules as $cfRule) { - $objConditional = new Conditional(); - $objConditional->setConditionType((string) $cfRule['type']); - $objConditional->setOperatorType((string) $cfRule['operator']); - - if ((string) $cfRule['text'] != '') { - $objConditional->setText((string) $cfRule['text']); - } - - if (isset($cfRule['stopIfTrue']) && (int) $cfRule['stopIfTrue'] === 1) { - $objConditional->setStopIfTrue(true); - } - - if (count($cfRule->formula) > 1) { - foreach ($cfRule->formula as $formula) { - $objConditional->addCondition((string) $formula); - } - } else { - $objConditional->addCondition((string) $cfRule->formula); - } - $objConditional->setStyle(clone $dxfs[(int) ($cfRule['dxfId'])]); - $conditionalStyles[] = $objConditional; - } - - // Extract all cell references in $ref - $cellBlocks = explode(' ', str_replace('$', '', strtoupper($ref))); - foreach ($cellBlocks as $cellBlock) { - $docSheet->getStyle($cellBlock)->setConditionalStyles($conditionalStyles); - } - } + (new ConditionalStyles($docSheet, $xmlSheet, $dxfs))->load(); } $aKeys = ['sheet', 'objects', 'scenarios', 'formatCells', 'formatColumns', 'formatRows', 'insertColumns', 'insertRows', 'insertHyperlinks', 'deleteColumns', 'deleteRows', 'selectLockedCells', 'sort', 'autoFilter', 'pivotTables', 'selectUnlockedCells']; @@ -1074,103 +803,7 @@ class Xlsx extends BaseReader } if ($xmlSheet && $xmlSheet->autoFilter && !$this->readDataOnly) { - $autoFilterRange = (string) $xmlSheet->autoFilter['ref']; - if (strpos($autoFilterRange, ':') !== false) { - $autoFilter = $docSheet->getAutoFilter(); - $autoFilter->setRange($autoFilterRange); - - foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { - $column = $autoFilter->getColumnByOffset((int) $filterColumn['colId']); - // Check for standard filters - if ($filterColumn->filters) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); - $filters = $filterColumn->filters; - if ((isset($filters['blank'])) && ($filters['blank'] == 1)) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule(null, '')->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Standard filters are always an OR join, so no join rule needs to be set - // Entries can be either filter elements - foreach ($filters->filter as $filterRule) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule(null, (string) $filterRule['val'])->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Or Date Group elements - foreach ($filters->dateGroupItem as $dateGroupItem) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule( - null, - [ - 'year' => (string) $dateGroupItem['year'], - 'month' => (string) $dateGroupItem['month'], - 'day' => (string) $dateGroupItem['day'], - 'hour' => (string) $dateGroupItem['hour'], - 'minute' => (string) $dateGroupItem['minute'], - 'second' => (string) $dateGroupItem['second'], - ], - (string) $dateGroupItem['dateTimeGrouping'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP); - } - } - // Check for custom filters - if ($filterColumn->customFilters) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); - $customFilters = $filterColumn->customFilters; - // Custom filters can an AND or an OR join; - // and there should only ever be one or two entries - if ((isset($customFilters['and'])) && ($customFilters['and'] == 1)) { - $column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND); - } - foreach ($customFilters->customFilter as $filterRule) { - $column->createRule()->setRule( - (string) $filterRule['operator'], - (string) $filterRule['val'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); - } - } - // Check for dynamic filters - if ($filterColumn->dynamicFilter) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); - // We should only ever have one dynamic filter - foreach ($filterColumn->dynamicFilter as $filterRule) { - // Operator is undefined, but always treated as EQUAL - $column->createRule()->setRule( - null, - (string) $filterRule['val'], - (string) $filterRule['type'] - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); - if (isset($filterRule['val'])) { - $column->setAttribute('val', (string) $filterRule['val']); - } - if (isset($filterRule['maxVal'])) { - $column->setAttribute('maxVal', (string) $filterRule['maxVal']); - } - } - } - // Check for dynamic filters - if ($filterColumn->top10) { - $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); - // We should only ever have one top10 filter - foreach ($filterColumn->top10 as $filterRule) { - $column->createRule()->setRule( - (((isset($filterRule['percent'])) && ($filterRule['percent'] == 1)) - ? Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT - : Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE - ), - (string) $filterRule['val'], - (((isset($filterRule['top'])) && ($filterRule['top'] == 1)) - ? Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP - : Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM - ) - ) - ->setRuleType(Column\Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); - } - } - } - } + (new AutoFilter($docSheet, $xmlSheet))->load(); } if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->readDataOnly) { @@ -1182,124 +815,12 @@ class Xlsx extends BaseReader } } - if ($xmlSheet && $xmlSheet->pageMargins && !$this->readDataOnly) { - $docPageMargins = $docSheet->getPageMargins(); - $docPageMargins->setLeft((float) ($xmlSheet->pageMargins['left'])); - $docPageMargins->setRight((float) ($xmlSheet->pageMargins['right'])); - $docPageMargins->setTop((float) ($xmlSheet->pageMargins['top'])); - $docPageMargins->setBottom((float) ($xmlSheet->pageMargins['bottom'])); - $docPageMargins->setHeader((float) ($xmlSheet->pageMargins['header'])); - $docPageMargins->setFooter((float) ($xmlSheet->pageMargins['footer'])); - } - - if ($xmlSheet && $xmlSheet->pageSetup && !$this->readDataOnly) { - $docPageSetup = $docSheet->getPageSetup(); - - if (isset($xmlSheet->pageSetup['orientation'])) { - $docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']); - } - if (isset($xmlSheet->pageSetup['paperSize'])) { - $docPageSetup->setPaperSize((int) ($xmlSheet->pageSetup['paperSize'])); - } - if (isset($xmlSheet->pageSetup['scale'])) { - $docPageSetup->setScale((int) ($xmlSheet->pageSetup['scale']), false); - } - if (isset($xmlSheet->pageSetup['fitToHeight']) && (int) ($xmlSheet->pageSetup['fitToHeight']) >= 0) { - $docPageSetup->setFitToHeight((int) ($xmlSheet->pageSetup['fitToHeight']), false); - } - if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { - $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); - } - if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && - self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { - $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); - } - - $relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - if (isset($relAttributes['id'])) { - $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['pageSetupRelId'] = (string) $relAttributes['id']; - } - } - - if ($xmlSheet && $xmlSheet->headerFooter && !$this->readDataOnly) { - $docHeaderFooter = $docSheet->getHeaderFooter(); - - if (isset($xmlSheet->headerFooter['differentOddEven']) && - self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { - $docHeaderFooter->setDifferentOddEven(true); - } else { - $docHeaderFooter->setDifferentOddEven(false); - } - if (isset($xmlSheet->headerFooter['differentFirst']) && - self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { - $docHeaderFooter->setDifferentFirst(true); - } else { - $docHeaderFooter->setDifferentFirst(false); - } - if (isset($xmlSheet->headerFooter['scaleWithDoc']) && - !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { - $docHeaderFooter->setScaleWithDocument(false); - } else { - $docHeaderFooter->setScaleWithDocument(true); - } - if (isset($xmlSheet->headerFooter['alignWithMargins']) && - !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { - $docHeaderFooter->setAlignWithMargins(false); - } else { - $docHeaderFooter->setAlignWithMargins(true); - } - - $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); - $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); - $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); - $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); - $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); - $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); - } - - if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->readDataOnly) { - foreach ($xmlSheet->rowBreaks->brk as $brk) { - if ($brk['man']) { - $docSheet->setBreak("A$brk[id]", Worksheet::BREAK_ROW); - } - } - } - if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->readDataOnly) { - foreach ($xmlSheet->colBreaks->brk as $brk) { - if ($brk['man']) { - $docSheet->setBreak(Coordinate::stringFromColumnIndex((string) $brk['id'] + 1) . '1', Worksheet::BREAK_COLUMN); - } - } + if ($xmlSheet && !$this->readDataOnly) { + $unparsedLoadedData = (new PageSetup($docSheet, $xmlSheet))->load($unparsedLoadedData); } if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) { - foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { - // Uppercase coordinate - $range = strtoupper($dataValidation['sqref']); - $rangeSet = explode(' ', $range); - foreach ($rangeSet as $range) { - $stRange = $docSheet->shrinkRangeToFit($range); - - // Extract all cell references in $range - foreach (Coordinate::extractAllCellReferencesInRange($stRange) as $reference) { - // Create validation - $docValidation = $docSheet->getCell($reference)->getDataValidation(); - $docValidation->setType((string) $dataValidation['type']); - $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); - $docValidation->setOperator((string) $dataValidation['operator']); - $docValidation->setAllowBlank($dataValidation['allowBlank'] != 0); - $docValidation->setShowDropDown($dataValidation['showDropDown'] == 0); - $docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0); - $docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0); - $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); - $docValidation->setError((string) $dataValidation['error']); - $docValidation->setPromptTitle((string) $dataValidation['promptTitle']); - $docValidation->setPrompt((string) $dataValidation['prompt']); - $docValidation->setFormula1((string) $dataValidation->formula1); - $docValidation->setFormula2((string) $dataValidation->formula2); - } - } - } + (new DataValidations($docSheet, $xmlSheet))->load(); } // unparsed sheet AlternateContent @@ -1313,50 +834,25 @@ class Xlsx extends BaseReader } // Add hyperlinks - $hyperlinks = []; if (!$this->readDataOnly) { + $hyperlinkReader = new Hyperlinks($docSheet); // Locate hyperlink relations - if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) { + $relationsFileName = dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels'; + if ($zip->locateName($relationsFileName)) { //~ http://schemas.openxmlformats.org/package/2006/relationships" $relsWorksheet = simplexml_load_string( $this->securityScanner->scan( - $this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels') + $this->getFromZipArchive($zip, $relationsFileName) ), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() ); - foreach ($relsWorksheet->Relationship as $ele) { - if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { - $hyperlinks[(string) $ele['Id']] = (string) $ele['Target']; - } - } + $hyperlinkReader->readHyperlinks($relsWorksheet); } // Loop through hyperlinks if ($xmlSheet && $xmlSheet->hyperlinks) { - /** @var SimpleXMLElement $hyperlink */ - foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) { - // Link url - $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - - foreach (Coordinate::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { - $cell = $docSheet->getCell($cellReference); - if (isset($linkRel['id'])) { - $hyperlinkUrl = $hyperlinks[(string) $linkRel['id']]; - if (isset($hyperlink['location'])) { - $hyperlinkUrl .= '#' . (string) $hyperlink['location']; - } - $cell->getHyperlink()->setUrl($hyperlinkUrl); - } elseif (isset($hyperlink['location'])) { - $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']); - } - - // Tooltip - if (isset($hyperlink['tooltip'])) { - $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']); - } - } - } + $hyperlinkReader->setHyperlinks($xmlSheet->hyperlinks); } } @@ -1418,12 +914,18 @@ class Xlsx extends BaseReader foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = File::realpath(dirname("$dir/$fileWorksheet") . '/' . $relPath); - $vmlCommentsFile = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + + try { + $vmlCommentsFile = simplexml_load_string( + $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), + 'SimpleXMLElement', + Settings::getLibXmlLoaderOptions() + ); + $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + } catch (\Throwable $ex) { + //Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData + continue; + } $shapes = $vmlCommentsFile->xpath('//v:shape'); foreach ($shapes as $shape) { @@ -1597,8 +1099,10 @@ class Xlsx extends BaseReader } } if ($xmlSheet->drawing && !$this->readDataOnly) { + $unparsedDrawings = []; foreach ($xmlSheet->drawing as $drawing) { - $fileDrawing = $drawings[(string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')]; + $drawingRelId = (string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id'); + $fileDrawing = $drawings[$drawingRelId]; //~ http://schemas.openxmlformats.org/package/2006/relationships" $relsDrawing = simplexml_load_string( $this->securityScanner->scan( @@ -1630,10 +1134,11 @@ class Xlsx extends BaseReader $this->securityScanner->scan($this->getFromZipArchive($zip, $fileDrawing)), 'SimpleXMLElement', Settings::getLibXmlLoaderOptions() - )->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); + ); + $xmlDrawingChildren = $xmlDrawing->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); - if ($xmlDrawing->oneCellAnchor) { - foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { + if ($xmlDrawingChildren->oneCellAnchor) { + foreach ($xmlDrawingChildren->oneCellAnchor as $oneCellAnchor) { if ($oneCellAnchor->pic->blipFill) { /** @var SimpleXMLElement $blip */ $blip = $oneCellAnchor->pic->blipFill->children('http://schemas.openxmlformats.org/drawingml/2006/main')->blip; @@ -1667,12 +1172,13 @@ class Xlsx extends BaseReader if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); - $shadow->setDistance(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), 'dir'))); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), 'algn')); - $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), 'val')); - $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), 'val') / 1000); + $clr = isset($outerShdw->srgbClr) ? $outerShdw->srgbClr : $outerShdw->prstClr; + $shadow->getColor()->setRGB(self::getArrayItem($clr->attributes(), 'val')); + $shadow->setAlpha(self::getArrayItem($clr->alpha->attributes(), 'val') / 1000); } $this->readHyperLinkDrawing($objDrawing, $oneCellAnchor, $hyperlinks); @@ -1688,8 +1194,8 @@ class Xlsx extends BaseReader } } } - if ($xmlDrawing->twoCellAnchor) { - foreach ($xmlDrawing->twoCellAnchor as $twoCellAnchor) { + if ($xmlDrawingChildren->twoCellAnchor) { + foreach ($xmlDrawingChildren->twoCellAnchor as $twoCellAnchor) { if ($twoCellAnchor->pic->blipFill) { $blip = $twoCellAnchor->pic->blipFill->children('http://schemas.openxmlformats.org/drawingml/2006/main')->blip; $xfrm = $twoCellAnchor->pic->spPr->children('http://schemas.openxmlformats.org/drawingml/2006/main')->xfrm; @@ -1719,12 +1225,13 @@ class Xlsx extends BaseReader if ($outerShdw) { $shadow = $objDrawing->getShadow(); $shadow->setVisible(true); - $shadow->setBlurRadius(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); - $shadow->setDistance(Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); + $shadow->setBlurRadius(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'blurRad'))); + $shadow->setDistance(Drawing::EMUToPixels(self::getArrayItem($outerShdw->attributes(), 'dist'))); $shadow->setDirection(Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), 'dir'))); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), 'algn')); - $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), 'val')); - $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), 'val') / 1000); + $clr = isset($outerShdw->srgbClr) ? $outerShdw->srgbClr : $outerShdw->prstClr; + $shadow->getColor()->setRGB(self::getArrayItem($clr->attributes(), 'val')); + $shadow->setAlpha(self::getArrayItem($clr->alpha->attributes(), 'val') / 1000); } $this->readHyperLinkDrawing($objDrawing, $twoCellAnchor, $hyperlinks); @@ -1754,13 +1261,21 @@ class Xlsx extends BaseReader } } } + if ($relsDrawing === false && $xmlDrawing->count() == 0) { + // Save Drawing without rels and children as unparsed + $unparsedDrawings[$drawingRelId] = $xmlDrawing->asXML(); + } } // store original rId of drawing files $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'] = []; foreach ($relsWorksheet->Relationship as $ele) { if ($ele['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing') { - $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'][(string) $ele['Target']] = (string) $ele['Id']; + $drawingRelId = (string) $ele['Id']; + $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingOriginalIds'][(string) $ele['Target']] = $drawingRelId; + if (isset($unparsedDrawings[$drawingRelId])) { + $unparsedLoadedData['sheets'][$docSheet->getCodeName()]['Drawings'][$drawingRelId] = $unparsedDrawings[$drawingRelId]; + } } } @@ -1905,7 +1420,7 @@ class Xlsx extends BaseReader if (strpos((string) $definedName, '!') !== false) { // Extract sheet name $extractedSheetName = Worksheet::extractSheetTitle((string) $definedName, true); - $extractedSheetName = $extractedSheetName[0]; + $extractedSheetName = trim($extractedSheetName[0], "'"); // Locate sheet $locatedSheet = $excel->getSheetByName($extractedSheetName); @@ -2511,94 +2026,4 @@ class Xlsx extends BaseReader return (bool) $xsdBoolean; } - - /** - * Read columns and rows attributes from XML and set them on the worksheet. - * - * @param SimpleXMLElement $xmlSheet - * @param Worksheet $docSheet - */ - private function readColumnsAndRowsAttributes(SimpleXMLElement $xmlSheet, Worksheet $docSheet) - { - $columnsAttributes = []; - $rowsAttributes = []; - if (isset($xmlSheet->cols) && !$this->readDataOnly) { - foreach ($xmlSheet->cols->col as $col) { - for ($i = (int) ($col['min']); $i <= (int) ($col['max']); ++$i) { - if ($col['style'] && !$this->readDataOnly) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['xfIndex'] = (int) $col['style']; - } - if (self::boolean($col['hidden'])) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['visible'] = false; - } - if (self::boolean($col['collapsed'])) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['collapsed'] = true; - } - if ($col['outlineLevel'] > 0) { - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['outlineLevel'] = (int) $col['outlineLevel']; - } - $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['width'] = (float) $col['width']; - - if ((int) ($col['max']) == 16384) { - break; - } - } - } - } - - if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { - foreach ($xmlSheet->sheetData->row as $row) { - if ($row['ht'] && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['rowHeight'] = (float) $row['ht']; - } - if (self::boolean($row['hidden']) && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['visible'] = false; - } - if (self::boolean($row['collapsed'])) { - $rowsAttributes[(int) $row['r']]['collapsed'] = true; - } - if ($row['outlineLevel'] > 0) { - $rowsAttributes[(int) $row['r']]['outlineLevel'] = (int) $row['outlineLevel']; - } - if ($row['s'] && !$this->readDataOnly) { - $rowsAttributes[(int) $row['r']]['xfIndex'] = (int) $row['s']; - } - } - } - - $readFilter = (\get_class($this->getReadFilter()) !== DefaultReadFilter::class ? $this->getReadFilter() : null); - - // set columns/rows attributes - $columnsAttributesSet = []; - $rowsAttributesSet = []; - foreach ($columnsAttributes as $coordColumn => $columnAttributes) { - if ($readFilter !== null) { - foreach ($rowsAttributes as $coordRow => $rowAttributes) { - if (!$readFilter->readCell($coordColumn, $coordRow, $docSheet->getTitle())) { - continue 2; - } - } - } - - if (!isset($columnsAttributesSet[$coordColumn])) { - $this->setColumnAttributes($docSheet, $coordColumn, $columnAttributes); - $columnsAttributesSet[$coordColumn] = true; - } - } - - foreach ($rowsAttributes as $coordRow => $rowAttributes) { - if ($readFilter !== null) { - foreach ($columnsAttributes as $coordColumn => $columnAttributes) { - if (!$readFilter->readCell($coordColumn, $coordRow, $docSheet->getTitle())) { - continue 2; - } - } - } - - if (!isset($rowsAttributesSet[$coordRow])) { - $this->setRowAttributes($docSheet, $coordRow, $rowAttributes); - $rowsAttributesSet[$coordRow] = true; - } - } - } } diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php new file mode 100644 index 00000000000..6929758dfe9 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -0,0 +1,144 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load() + { + $autoFilterRange = (string) $this->worksheetXml->autoFilter['ref']; + if (strpos($autoFilterRange, ':') !== false) { + $this->readAutoFilter($autoFilterRange, $this->worksheetXml); + } + } + + private function readAutoFilter($autoFilterRange, $xmlSheet) + { + $autoFilter = $this->worksheet->getAutoFilter(); + $autoFilter->setRange($autoFilterRange); + + foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { + $column = $autoFilter->getColumnByOffset((int) $filterColumn['colId']); + // Check for standard filters + if ($filterColumn->filters) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); + $filters = $filterColumn->filters; + if ((isset($filters['blank'])) && ($filters['blank'] == 1)) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, '')->setRuleType(Rule::AUTOFILTER_RULETYPE_FILTER); + } + // Standard filters are always an OR join, so no join rule needs to be set + // Entries can be either filter elements + foreach ($filters->filter as $filterRule) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule(null, (string) $filterRule['val'])->setRuleType(Rule::AUTOFILTER_RULETYPE_FILTER); + } + + // Or Date Group elements + $this->readDateRangeAutoFilter($filters, $column); + } + + // Check for custom filters + $this->readCustomAutoFilter($filterColumn, $column); + // Check for dynamic filters + $this->readDynamicAutoFilter($filterColumn, $column); + // Check for dynamic filters + $this->readTopTenAutoFilter($filterColumn, $column); + } + } + + private function readDateRangeAutoFilter(\SimpleXMLElement $filters, Column $column) + { + foreach ($filters->dateGroupItem as $dateGroupItem) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule( + null, + [ + 'year' => (string) $dateGroupItem['year'], + 'month' => (string) $dateGroupItem['month'], + 'day' => (string) $dateGroupItem['day'], + 'hour' => (string) $dateGroupItem['hour'], + 'minute' => (string) $dateGroupItem['minute'], + 'second' => (string) $dateGroupItem['second'], + ], + (string) $dateGroupItem['dateTimeGrouping'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP); + } + } + + private function readCustomAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->customFilters) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); + $customFilters = $filterColumn->customFilters; + // Custom filters can an AND or an OR join; + // and there should only ever be one or two entries + if ((isset($customFilters['and'])) && ($customFilters['and'] == 1)) { + $column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND); + } + foreach ($customFilters->customFilter as $filterRule) { + $column->createRule()->setRule( + (string) $filterRule['operator'], + (string) $filterRule['val'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + } + } + } + + private function readDynamicAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->dynamicFilter) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); + // We should only ever have one dynamic filter + foreach ($filterColumn->dynamicFilter as $filterRule) { + // Operator is undefined, but always treated as EQUAL + $column->createRule()->setRule( + null, + (string) $filterRule['val'], + (string) $filterRule['type'] + )->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); + if (isset($filterRule['val'])) { + $column->setAttribute('val', (string) $filterRule['val']); + } + if (isset($filterRule['maxVal'])) { + $column->setAttribute('maxVal', (string) $filterRule['maxVal']); + } + } + } + } + + private function readTopTenAutoFilter(\SimpleXMLElement $filterColumn, Column $column) + { + if ($filterColumn->top10) { + $column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); + // We should only ever have one top10 filter + foreach ($filterColumn->top10 as $filterRule) { + $column->createRule()->setRule( + (((isset($filterRule['percent'])) && ($filterRule['percent'] == 1)) + ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT + : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE + ), + (string) $filterRule['val'], + (((isset($filterRule['top'])) && ($filterRule['top'] == 1)) + ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP + : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM + ) + )->setRuleType(Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php new file mode 100644 index 00000000000..1679f01f9f1 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php @@ -0,0 +1,19 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + /** + * Set Worksheet column attributes by attributes array passed. + * + * @param string $columnAddress A, B, ... DX, ... + * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) + * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? + */ + private function setColumnAttributes($columnAddress, array $columnAttributes) + { + if (isset($columnAttributes['xfIndex'])) { + $this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']); + } + if (isset($columnAttributes['visible'])) { + $this->worksheet->getColumnDimension($columnAddress)->setVisible($columnAttributes['visible']); + } + if (isset($columnAttributes['collapsed'])) { + $this->worksheet->getColumnDimension($columnAddress)->setCollapsed($columnAttributes['collapsed']); + } + if (isset($columnAttributes['outlineLevel'])) { + $this->worksheet->getColumnDimension($columnAddress)->setOutlineLevel($columnAttributes['outlineLevel']); + } + if (isset($columnAttributes['width'])) { + $this->worksheet->getColumnDimension($columnAddress)->setWidth($columnAttributes['width']); + } + } + + /** + * Set Worksheet row attributes by attributes array passed. + * + * @param int $rowNumber 1, 2, 3, ... 99, ... + * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) + * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? + */ + private function setRowAttributes($rowNumber, array $rowAttributes) + { + if (isset($rowAttributes['xfIndex'])) { + $this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']); + } + if (isset($rowAttributes['visible'])) { + $this->worksheet->getRowDimension($rowNumber)->setVisible($rowAttributes['visible']); + } + if (isset($rowAttributes['collapsed'])) { + $this->worksheet->getRowDimension($rowNumber)->setCollapsed($rowAttributes['collapsed']); + } + if (isset($rowAttributes['outlineLevel'])) { + $this->worksheet->getRowDimension($rowNumber)->setOutlineLevel($rowAttributes['outlineLevel']); + } + if (isset($rowAttributes['rowHeight'])) { + $this->worksheet->getRowDimension($rowNumber)->setRowHeight($rowAttributes['rowHeight']); + } + } + + /** + * @param IReadFilter $readFilter + * @param bool $readDataOnly + */ + public function load(IReadFilter $readFilter = null, $readDataOnly = false) + { + if ($this->worksheetXml === null) { + return; + } + + $columnsAttributes = []; + $rowsAttributes = []; + if (isset($this->worksheetXml->cols)) { + $columnsAttributes = $this->readColumnAttributes($this->worksheetXml->cols, $readDataOnly); + } + + if ($this->worksheetXml->sheetData && $this->worksheetXml->sheetData->row) { + $rowsAttributes = $this->readRowAttributes($this->worksheetXml->sheetData->row, $readDataOnly); + } + + // set columns/rows attributes + $columnsAttributesAreSet = []; + foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { + if ($readFilter === null || + !$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)) { + if (!isset($columnsAttributesAreSet[$columnCoordinate])) { + $this->setColumnAttributes($columnCoordinate, $columnAttributes); + $columnsAttributesAreSet[$columnCoordinate] = true; + } + } + } + + $rowsAttributesAreSet = []; + foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { + if ($readFilter === null || + !$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)) { + if (!isset($rowsAttributesAreSet[$rowCoordinate])) { + $this->setRowAttributes($rowCoordinate, $rowAttributes); + $rowsAttributesAreSet[$rowCoordinate] = true; + } + } + } + } + + private function isFilteredColumn(IReadFilter $readFilter, $columnCoordinate, array $rowsAttributes) + { + foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { + if (!$readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) { + return true; + } + } + + return false; + } + + private function readColumnAttributes(\SimpleXMLElement $worksheetCols, $readDataOnly) + { + $columnAttributes = []; + + foreach ($worksheetCols->col as $column) { + $startColumn = Coordinate::stringFromColumnIndex((int) $column['min']); + $endColumn = Coordinate::stringFromColumnIndex((int) $column['max']); + ++$endColumn; + for ($columnAddress = $startColumn; $columnAddress !== $endColumn; ++$columnAddress) { + $columnAttributes[$columnAddress] = $this->readColumnRangeAttributes($column, $readDataOnly); + + if ((int) ($column['max']) == 16384) { + break; + } + } + } + + return $columnAttributes; + } + + private function readColumnRangeAttributes(\SimpleXMLElement $column, $readDataOnly) + { + $columnAttributes = []; + + if ($column['style'] && !$readDataOnly) { + $columnAttributes['xfIndex'] = (int) $column['style']; + } + if (self::boolean($column['hidden'])) { + $columnAttributes['visible'] = false; + } + if (self::boolean($column['collapsed'])) { + $columnAttributes['collapsed'] = true; + } + if (((int) $column['outlineLevel']) > 0) { + $columnAttributes['outlineLevel'] = (int) $column['outlineLevel']; + } + $columnAttributes['width'] = (float) $column['width']; + + return $columnAttributes; + } + + private function isFilteredRow(IReadFilter $readFilter, $rowCoordinate, array $columnsAttributes) + { + foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { + if (!$readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) { + return true; + } + } + + return false; + } + + private function readRowAttributes(\SimpleXMLElement $worksheetRow, $readDataOnly) + { + $rowAttributes = []; + + foreach ($worksheetRow as $row) { + if ($row['ht'] && !$readDataOnly) { + $rowAttributes[(int) $row['r']]['rowHeight'] = (float) $row['ht']; + } + if (self::boolean($row['hidden'])) { + $rowAttributes[(int) $row['r']]['visible'] = false; + } + if (self::boolean($row['collapsed'])) { + $rowAttributes[(int) $row['r']]['collapsed'] = true; + } + if ((int) $row['outlineLevel'] > 0) { + $rowAttributes[(int) $row['r']]['outlineLevel'] = (int) $row['outlineLevel']; + } + if ($row['s'] && !$readDataOnly) { + $rowAttributes[(int) $row['r']]['xfIndex'] = (int) $row['s']; + } + } + + return $rowAttributes; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php new file mode 100644 index 00000000000..b3de5d1cde6 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -0,0 +1,92 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + $this->dxfs = $dxfs; + } + + public function load() + { + $this->setConditionalStyles( + $this->worksheet, + $this->readConditionalStyles($this->worksheetXml) + ); + } + + private function readConditionalStyles($xmlSheet) + { + $conditionals = []; + foreach ($xmlSheet->conditionalFormatting as $conditional) { + foreach ($conditional->cfRule as $cfRule) { + if (((string) $cfRule['type'] == Conditional::CONDITION_NONE + || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS + || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT + || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) + && isset($this->dxfs[(int) ($cfRule['dxfId'])])) { + $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; + } + } + } + + return $conditionals; + } + + private function setConditionalStyles(Worksheet $worksheet, array $conditionals) + { + foreach ($conditionals as $ref => $cfRules) { + ksort($cfRules); + $conditionalStyles = $this->readStyleRules($cfRules); + + // Extract all cell references in $ref + $cellBlocks = explode(' ', str_replace('$', '', strtoupper($ref))); + foreach ($cellBlocks as $cellBlock) { + $worksheet->getStyle($cellBlock)->setConditionalStyles($conditionalStyles); + } + } + } + + private function readStyleRules($cfRules) + { + $conditionalStyles = []; + foreach ($cfRules as $cfRule) { + $objConditional = new Conditional(); + $objConditional->setConditionType((string) $cfRule['type']); + $objConditional->setOperatorType((string) $cfRule['operator']); + + if ((string) $cfRule['text'] != '') { + $objConditional->setText((string) $cfRule['text']); + } + + if (isset($cfRule['stopIfTrue']) && (int) $cfRule['stopIfTrue'] === 1) { + $objConditional->setStopIfTrue(true); + } + + if (count($cfRule->formula) > 1) { + foreach ($cfRule->formula as $formula) { + $objConditional->addCondition((string) $formula); + } + } else { + $objConditional->addCondition((string) $cfRule->formula); + } + $objConditional->setStyle(clone $this->dxfs[(int) ($cfRule['dxfId'])]); + $conditionalStyles[] = $objConditional; + } + + return $conditionalStyles; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php new file mode 100644 index 00000000000..4bb44129208 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -0,0 +1,50 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load() + { + foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { + // Uppercase coordinate + $range = strtoupper($dataValidation['sqref']); + $rangeSet = explode(' ', $range); + foreach ($rangeSet as $range) { + $stRange = $this->worksheet->shrinkRangeToFit($range); + + // Extract all cell references in $range + foreach (Coordinate::extractAllCellReferencesInRange($stRange) as $reference) { + // Create validation + $docValidation = $this->worksheet->getCell($reference)->getDataValidation(); + $docValidation->setType((string) $dataValidation['type']); + $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); + $docValidation->setOperator((string) $dataValidation['operator']); + $docValidation->setAllowBlank($dataValidation['allowBlank'] != 0); + $docValidation->setShowDropDown($dataValidation['showDropDown'] == 0); + $docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0); + $docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0); + $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); + $docValidation->setError((string) $dataValidation['error']); + $docValidation->setPromptTitle((string) $dataValidation['promptTitle']); + $docValidation->setPrompt((string) $dataValidation['prompt']); + $docValidation->setFormula1((string) $dataValidation->formula1); + $docValidation->setFormula2((string) $dataValidation->formula2); + } + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php new file mode 100644 index 00000000000..400b272528c --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -0,0 +1,58 @@ +worksheet = $workSheet; + } + + public function readHyperlinks(\SimpleXMLElement $relsWorksheet) + { + foreach ($relsWorksheet->Relationship as $element) { + if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') { + $this->hyperlinks[(string) $element['Id']] = (string) $element['Target']; + } + } + } + + public function setHyperlinks(\SimpleXMLElement $worksheetXml) + { + foreach ($worksheetXml->hyperlink as $hyperlink) { + $this->setHyperlink($hyperlink, $this->worksheet); + } + } + + private function setHyperlink(\SimpleXMLElement $hyperlink, Worksheet $worksheet) + { + // Link url + $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + + foreach (Coordinate::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { + $cell = $worksheet->getCell($cellReference); + if (isset($linkRel['id'])) { + $hyperlinkUrl = $this->hyperlinks[(string) $linkRel['id']]; + if (isset($hyperlink['location'])) { + $hyperlinkUrl .= '#' . (string) $hyperlink['location']; + } + $cell->getHyperlink()->setUrl($hyperlinkUrl); + } elseif (isset($hyperlink['location'])) { + $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']); + } + + // Tooltip + if (isset($hyperlink['tooltip'])) { + $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php new file mode 100644 index 00000000000..6f286769c0e --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -0,0 +1,150 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + public function load(array $unparsedLoadedData) + { + if (!$this->worksheetXml) { + return $unparsedLoadedData; + } + + $this->margins($this->worksheetXml, $this->worksheet); + $unparsedLoadedData = $this->pageSetup($this->worksheetXml, $this->worksheet, $unparsedLoadedData); + $this->headerFooter($this->worksheetXml, $this->worksheet); + $this->pageBreaks($this->worksheetXml, $this->worksheet); + + return $unparsedLoadedData; + } + + private function margins(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->pageMargins) { + $docPageMargins = $worksheet->getPageMargins(); + $docPageMargins->setLeft((float) ($xmlSheet->pageMargins['left'])); + $docPageMargins->setRight((float) ($xmlSheet->pageMargins['right'])); + $docPageMargins->setTop((float) ($xmlSheet->pageMargins['top'])); + $docPageMargins->setBottom((float) ($xmlSheet->pageMargins['bottom'])); + $docPageMargins->setHeader((float) ($xmlSheet->pageMargins['header'])); + $docPageMargins->setFooter((float) ($xmlSheet->pageMargins['footer'])); + } + } + + private function pageSetup(\SimpleXMLElement $xmlSheet, Worksheet $worksheet, array $unparsedLoadedData) + { + if ($xmlSheet->pageSetup) { + $docPageSetup = $worksheet->getPageSetup(); + + if (isset($xmlSheet->pageSetup['orientation'])) { + $docPageSetup->setOrientation((string) $xmlSheet->pageSetup['orientation']); + } + if (isset($xmlSheet->pageSetup['paperSize'])) { + $docPageSetup->setPaperSize((int) ($xmlSheet->pageSetup['paperSize'])); + } + if (isset($xmlSheet->pageSetup['scale'])) { + $docPageSetup->setScale((int) ($xmlSheet->pageSetup['scale']), false); + } + if (isset($xmlSheet->pageSetup['fitToHeight']) && (int) ($xmlSheet->pageSetup['fitToHeight']) >= 0) { + $docPageSetup->setFitToHeight((int) ($xmlSheet->pageSetup['fitToHeight']), false); + } + if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { + $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); + } + if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && + self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { + $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); + } + + $relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + if (isset($relAttributes['id'])) { + $unparsedLoadedData['sheets'][$worksheet->getCodeName()]['pageSetupRelId'] = (string) $relAttributes['id']; + } + } + + return $unparsedLoadedData; + } + + private function headerFooter(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->headerFooter) { + $docHeaderFooter = $worksheet->getHeaderFooter(); + + if (isset($xmlSheet->headerFooter['differentOddEven']) && + self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { + $docHeaderFooter->setDifferentOddEven(true); + } else { + $docHeaderFooter->setDifferentOddEven(false); + } + if (isset($xmlSheet->headerFooter['differentFirst']) && + self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { + $docHeaderFooter->setDifferentFirst(true); + } else { + $docHeaderFooter->setDifferentFirst(false); + } + if (isset($xmlSheet->headerFooter['scaleWithDoc']) && + !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { + $docHeaderFooter->setScaleWithDocument(false); + } else { + $docHeaderFooter->setScaleWithDocument(true); + } + if (isset($xmlSheet->headerFooter['alignWithMargins']) && + !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { + $docHeaderFooter->setAlignWithMargins(false); + } else { + $docHeaderFooter->setAlignWithMargins(true); + } + + $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); + $docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter); + $docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader); + $docHeaderFooter->setEvenFooter((string) $xmlSheet->headerFooter->evenFooter); + $docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader); + $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); + } + } + + private function pageBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + if ($xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk) { + $this->rowBreaks($xmlSheet, $worksheet); + } + if ($xmlSheet->colBreaks && $xmlSheet->colBreaks->brk) { + $this->columnBreaks($xmlSheet, $worksheet); + } + } + + private function rowBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + foreach ($xmlSheet->rowBreaks->brk as $brk) { + if ($brk['man']) { + $worksheet->setBreak("A{$brk['id']}", Worksheet::BREAK_ROW); + } + } + } + + private function columnBreaks(\SimpleXMLElement $xmlSheet, Worksheet $worksheet) + { + foreach ($xmlSheet->colBreaks->brk as $brk) { + if ($brk['man']) { + $worksheet->setBreak( + Coordinate::stringFromColumnIndex(((int) $brk['id']) + 1) . '1', + Worksheet::BREAK_COLUMN + ); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php new file mode 100644 index 00000000000..bc6bba2cdb2 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -0,0 +1,91 @@ +securityScanner = $securityScanner; + $this->docProps = $docProps; + } + + private function extractPropertyData($propertyData) + { + return simplexml_load_string( + $this->securityScanner->scan($propertyData), + 'SimpleXMLElement', + Settings::getLibXmlLoaderOptions() + ); + } + + public function readCoreProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + $xmlCore->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); + $xmlCore->registerXPathNamespace('dcterms', 'http://purl.org/dc/terms/'); + $xmlCore->registerXPathNamespace('cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + + $this->docProps->setCreator((string) self::getArrayItem($xmlCore->xpath('dc:creator'))); + $this->docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath('cp:lastModifiedBy'))); + $this->docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:created')))); //! respect xsi:type + $this->docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath('dcterms:modified')))); //! respect xsi:type + $this->docProps->setTitle((string) self::getArrayItem($xmlCore->xpath('dc:title'))); + $this->docProps->setDescription((string) self::getArrayItem($xmlCore->xpath('dc:description'))); + $this->docProps->setSubject((string) self::getArrayItem($xmlCore->xpath('dc:subject'))); + $this->docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath('cp:keywords'))); + $this->docProps->setCategory((string) self::getArrayItem($xmlCore->xpath('cp:category'))); + } + } + + public function readExtendedProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + if (isset($xmlCore->Company)) { + $this->docProps->setCompany((string) $xmlCore->Company); + } + if (isset($xmlCore->Manager)) { + $this->docProps->setManager((string) $xmlCore->Manager); + } + } + } + + public function readCustomProperties($propertyData) + { + $xmlCore = $this->extractPropertyData($propertyData); + + if (is_object($xmlCore)) { + foreach ($xmlCore as $xmlProperty) { + /** @var \SimpleXMLElement $xmlProperty */ + $cellDataOfficeAttributes = $xmlProperty->attributes(); + if (isset($cellDataOfficeAttributes['name'])) { + $propertyName = (string) $cellDataOfficeAttributes['name']; + $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + + $attributeType = $cellDataOfficeChildren->getName(); + $attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; + $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); + $attributeType = DocumentProperties::convertPropertyType($attributeType); + $this->docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); + } + } + } + } + + private static function getArrayItem(array $array, $key = 0) + { + return isset($array[$key]) ? $array[$key] : null; + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php new file mode 100644 index 00000000000..eb61a5d306c --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php @@ -0,0 +1,124 @@ +worksheet = $workSheet; + $this->worksheetXml = $worksheetXml; + } + + /** + * @param bool $readDataOnly + */ + public function load($readDataOnly = false) + { + if ($this->worksheetXml === null) { + return; + } + + if (isset($this->worksheetXml->sheetPr)) { + $this->tabColor($this->worksheetXml->sheetPr); + $this->codeName($this->worksheetXml->sheetPr); + $this->outlines($this->worksheetXml->sheetPr); + $this->pageSetup($this->worksheetXml->sheetPr); + } + + if (isset($this->worksheetXml->sheetFormatPr)) { + $this->sheetFormat($this->worksheetXml->sheetFormatPr); + } + + if (!$readDataOnly && isset($this->worksheetXml->printOptions)) { + $this->printOptions($this->worksheetXml->printOptions); + } + } + + private function tabColor(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->tabColor, $sheetPr->tabColor['rgb'])) { + $this->worksheet->getTabColor()->setARGB((string) $sheetPr->tabColor['rgb']); + } + } + + private function codeName(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr['codeName'])) { + $this->worksheet->setCodeName((string) $sheetPr['codeName'], false); + } + } + + private function outlines(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->outlinePr)) { + if (isset($sheetPr->outlinePr['summaryRight']) && + !self::boolean((string) $sheetPr->outlinePr['summaryRight'])) { + $this->worksheet->setShowSummaryRight(false); + } else { + $this->worksheet->setShowSummaryRight(true); + } + + if (isset($sheetPr->outlinePr['summaryBelow']) && + !self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) { + $this->worksheet->setShowSummaryBelow(false); + } else { + $this->worksheet->setShowSummaryBelow(true); + } + } + } + + private function pageSetup(\SimpleXMLElement $sheetPr) + { + if (isset($sheetPr->pageSetUpPr)) { + if (isset($sheetPr->pageSetUpPr['fitToPage']) && + !self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) { + $this->worksheet->getPageSetup()->setFitToPage(false); + } else { + $this->worksheet->getPageSetup()->setFitToPage(true); + } + } + } + + private function sheetFormat(\SimpleXMLElement $sheetFormatPr) + { + if (isset($sheetFormatPr['customHeight']) && + self::boolean((string) $sheetFormatPr['customHeight']) && + isset($sheetFormatPr['defaultRowHeight'])) { + $this->worksheet->getDefaultRowDimension() + ->setRowHeight((float) $sheetFormatPr['defaultRowHeight']); + } + + if (isset($sheetFormatPr['defaultColWidth'])) { + $this->worksheet->getDefaultColumnDimension() + ->setWidth((float) $sheetFormatPr['defaultColWidth']); + } + + if (isset($sheetFormatPr['zeroHeight']) && + ((string) $sheetFormatPr['zeroHeight'] === '1')) { + $this->worksheet->getDefaultRowDimension()->setZeroHeight(true); + } + } + + private function printOptions(\SimpleXMLElement $printOptions) + { + if (self::boolean((string) $printOptions['gridLinesSet'])) { + $this->worksheet->setShowGridlines(true); + } + if (self::boolean((string) $printOptions['gridLines'])) { + $this->worksheet->setPrintGridlines(true); + } + if (self::boolean((string) $printOptions['horizontalCentered'])) { + $this->worksheet->getPageSetup()->setHorizontalCentered(true); + } + if (self::boolean((string) $printOptions['verticalCentered'])) { + $this->worksheet->getPageSetup()->setVerticalCentered(true); + } + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php new file mode 100644 index 00000000000..2caaec3108e --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php @@ -0,0 +1,127 @@ +sheetViewXml = $sheetViewXml; + $this->worksheet = $workSheet; + } + + public function load() + { + $this->zoomScale(); + $this->view(); + $this->gridLines(); + $this->headers(); + $this->direction(); + + if (isset($this->sheetViewXml->pane)) { + $this->pane(); + } + if (isset($this->sheetViewXml->selection, $this->sheetViewXml->selection['sqref'])) { + $this->selection(); + } + } + + private function zoomScale() + { + if (isset($this->sheetViewXml['zoomScale'])) { + $zoomScale = (int) ($this->sheetViewXml['zoomScale']); + if ($zoomScale <= 0) { + // setZoomScale will throw an Exception if the scale is less than or equals 0 + // that is OK when manually creating documents, but we should be able to read all documents + $zoomScale = 100; + } + + $this->worksheet->getSheetView()->setZoomScale($zoomScale); + } + + if (isset($this->sheetViewXml['zoomScaleNormal'])) { + $zoomScaleNormal = (int) ($this->sheetViewXml['zoomScaleNormal']); + if ($zoomScaleNormal <= 0) { + // setZoomScaleNormal will throw an Exception if the scale is less than or equals 0 + // that is OK when manually creating documents, but we should be able to read all documents + $zoomScaleNormal = 100; + } + + $this->worksheet->getSheetView()->setZoomScaleNormal($zoomScaleNormal); + } + } + + private function view() + { + if (isset($this->sheetViewXml['view'])) { + $this->worksheet->getSheetView()->setView((string) $this->sheetViewXml['view']); + } + } + + private function gridLines() + { + if (isset($this->sheetViewXml['showGridLines'])) { + $this->worksheet->setShowGridLines( + self::boolean((string) $this->sheetViewXml['showGridLines']) + ); + } + } + + private function headers() + { + if (isset($this->sheetViewXml['showRowColHeaders'])) { + $this->worksheet->setShowRowColHeaders( + self::boolean((string) $this->sheetViewXml['showRowColHeaders']) + ); + } + } + + private function direction() + { + if (isset($this->sheetViewXml['rightToLeft'])) { + $this->worksheet->setRightToLeft( + self::boolean((string) $this->sheetViewXml['rightToLeft']) + ); + } + } + + private function pane() + { + $xSplit = 0; + $ySplit = 0; + $topLeftCell = null; + + if (isset($this->sheetViewXml->pane['xSplit'])) { + $xSplit = (int) ($this->sheetViewXml->pane['xSplit']); + } + + if (isset($this->sheetViewXml->pane['ySplit'])) { + $ySplit = (int) ($this->sheetViewXml->pane['ySplit']); + } + + if (isset($this->sheetViewXml->pane['topLeftCell'])) { + $topLeftCell = (string) $this->sheetViewXml->pane['topLeftCell']; + } + + $this->worksheet->freezePane( + Coordinate::stringFromColumnIndex($xSplit + 1) . ($ySplit + 1), + $topLeftCell + ); + } + + private function selection() + { + $sqref = (string) $this->sheetViewXml->selection['sqref']; + $sqref = explode(' ', $sqref); + $sqref = $sqref[0]; + + $this->worksheet->setSelectedCells($sqref); + } +} diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php new file mode 100644 index 00000000000..c06564a3d11 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -0,0 +1,265 @@ +styleXml = $styleXml; + } + + public function setStyleBaseData(Theme $theme = null, $styles = [], $cellStyles = []) + { + self::$theme = $theme; + $this->styles = $styles; + $this->cellStyles = $cellStyles; + } + + private static function readFontStyle(Font $fontStyle, \SimpleXMLElement $fontStyleXml) + { + $fontStyle->setName((string) $fontStyleXml->name['val']); + $fontStyle->setSize((float) $fontStyleXml->sz['val']); + + if (isset($fontStyleXml->b)) { + $fontStyle->setBold(!isset($fontStyleXml->b['val']) || self::boolean((string) $fontStyleXml->b['val'])); + } + if (isset($fontStyleXml->i)) { + $fontStyle->setItalic(!isset($fontStyleXml->i['val']) || self::boolean((string) $fontStyleXml->i['val'])); + } + if (isset($fontStyleXml->strike)) { + $fontStyle->setStrikethrough(!isset($fontStyleXml->strike['val']) || self::boolean((string) $fontStyleXml->strike['val'])); + } + $fontStyle->getColor()->setARGB(self::readColor($fontStyleXml->color)); + + if (isset($fontStyleXml->u) && !isset($fontStyleXml->u['val'])) { + $fontStyle->setUnderline(Font::UNDERLINE_SINGLE); + } elseif (isset($fontStyleXml->u, $fontStyleXml->u['val'])) { + $fontStyle->setUnderline((string) $fontStyleXml->u['val']); + } + + if (isset($fontStyleXml->vertAlign, $fontStyleXml->vertAlign['val'])) { + $verticalAlign = strtolower((string) $fontStyleXml->vertAlign['val']); + if ($verticalAlign === 'superscript') { + $fontStyle->setSuperscript(true); + } + if ($verticalAlign === 'subscript') { + $fontStyle->setSubscript(true); + } + } + } + + private static function readFillStyle(Fill $fillStyle, \SimpleXMLElement $fillStyleXml) + { + if ($fillStyleXml->gradientFill) { + /** @var \SimpleXMLElement $gradientFill */ + $gradientFill = $fillStyleXml->gradientFill[0]; + if (!empty($gradientFill['type'])) { + $fillStyle->setFillType((string) $gradientFill['type']); + } + $fillStyle->setRotation((float) ($gradientFill['degree'])); + $gradientFill->registerXPathNamespace('sml', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + $fillStyle->getStartColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=0]'))->color)); + $fillStyle->getEndColor()->setARGB(self::readColor(self::getArrayItem($gradientFill->xpath('sml:stop[@position=1]'))->color)); + } elseif ($fillStyleXml->patternFill) { + $patternType = (string) $fillStyleXml->patternFill['patternType'] != '' ? (string) $fillStyleXml->patternFill['patternType'] : 'solid'; + $fillStyle->setFillType($patternType); + if ($fillStyleXml->patternFill->fgColor) { + $fillStyle->getStartColor()->setARGB(self::readColor($fillStyleXml->patternFill->fgColor, true)); + } else { + $fillStyle->getStartColor()->setARGB('FF000000'); + } + if ($fillStyleXml->patternFill->bgColor) { + $fillStyle->getEndColor()->setARGB(self::readColor($fillStyleXml->patternFill->bgColor, true)); + } + } + } + + private static function readBorderStyle(Borders $borderStyle, \SimpleXMLElement $borderStyleXml) + { + $diagonalUp = self::boolean((string) $borderStyleXml['diagonalUp']); + $diagonalDown = self::boolean((string) $borderStyleXml['diagonalDown']); + if (!$diagonalUp && !$diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_NONE); + } elseif ($diagonalUp && !$diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_UP); + } elseif (!$diagonalUp && $diagonalDown) { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_DOWN); + } else { + $borderStyle->setDiagonalDirection(Borders::DIAGONAL_BOTH); + } + + self::readBorder($borderStyle->getLeft(), $borderStyleXml->left); + self::readBorder($borderStyle->getRight(), $borderStyleXml->right); + self::readBorder($borderStyle->getTop(), $borderStyleXml->top); + self::readBorder($borderStyle->getBottom(), $borderStyleXml->bottom); + self::readBorder($borderStyle->getDiagonal(), $borderStyleXml->diagonal); + } + + private static function readBorder(Border $border, \SimpleXMLElement $borderXml) + { + if (isset($borderXml['style'])) { + $border->setBorderStyle((string) $borderXml['style']); + } + if (isset($borderXml->color)) { + $border->getColor()->setARGB(self::readColor($borderXml->color)); + } + } + + private static function readAlignmentStyle(Alignment $alignment, \SimpleXMLElement $alignmentXml) + { + $alignment->setHorizontal((string) $alignmentXml->alignment['horizontal']); + $alignment->setVertical((string) $alignmentXml->alignment['vertical']); + + $textRotation = 0; + if ((int) $alignmentXml->alignment['textRotation'] <= 90) { + $textRotation = (int) $alignmentXml->alignment['textRotation']; + } elseif ((int) $alignmentXml->alignment['textRotation'] > 90) { + $textRotation = 90 - (int) $alignmentXml->alignment['textRotation']; + } + + $alignment->setTextRotation((int) $textRotation); + $alignment->setWrapText(self::boolean((string) $alignmentXml->alignment['wrapText'])); + $alignment->setShrinkToFit(self::boolean((string) $alignmentXml->alignment['shrinkToFit'])); + $alignment->setIndent((int) ((string) $alignmentXml->alignment['indent']) > 0 ? (int) ((string) $alignmentXml->alignment['indent']) : 0); + $alignment->setReadOrder((int) ((string) $alignmentXml->alignment['readingOrder']) > 0 ? (int) ((string) $alignmentXml->alignment['readingOrder']) : 0); + } + + private function readStyle(Style $docStyle, $style) + { + $docStyle->getNumberFormat()->setFormatCode($style->numFmt); + + if (isset($style->font)) { + self::readFontStyle($docStyle->getFont(), $style->font); + } + + if (isset($style->fill)) { + self::readFillStyle($docStyle->getFill(), $style->fill); + } + + if (isset($style->border)) { + self::readBorderStyle($docStyle->getBorders(), $style->border); + } + + if (isset($style->alignment)) { + self::readAlignmentStyle($docStyle->getAlignment(), $style->alignment); + } + + // protection + if (isset($style->protection)) { + $this->readProtectionLocked($docStyle, $style); + $this->readProtectionHidden($docStyle, $style); + } + + // top-level style settings + if (isset($style->quotePrefix)) { + $docStyle->setQuotePrefix(true); + } + } + + private function readProtectionLocked(Style $docStyle, $style) + { + if (isset($style->protection['locked'])) { + if (self::boolean((string) $style->protection['locked'])) { + $docStyle->getProtection()->setLocked(Protection::PROTECTION_PROTECTED); + } else { + $docStyle->getProtection()->setLocked(Protection::PROTECTION_UNPROTECTED); + } + } + } + + private function readProtectionHidden(Style $docStyle, $style) + { + if (isset($style->protection['hidden'])) { + if (self::boolean((string) $style->protection['hidden'])) { + $docStyle->getProtection()->setHidden(Protection::PROTECTION_PROTECTED); + } else { + $docStyle->getProtection()->setHidden(Protection::PROTECTION_UNPROTECTED); + } + } + } + + private static function readColor($color, $background = false) + { + if (isset($color['rgb'])) { + return (string) $color['rgb']; + } elseif (isset($color['indexed'])) { + return Color::indexedColor($color['indexed'] - 7, $background)->getARGB(); + } elseif (isset($color['theme'])) { + if (self::$theme !== null) { + $returnColour = self::$theme->getColourByIndex((int) $color['theme']); + if (isset($color['tint'])) { + $tintAdjust = (float) $color['tint']; + $returnColour = Color::changeBrightness($returnColour, $tintAdjust); + } + + return 'FF' . $returnColour; + } + } + + return ($background) ? 'FFFFFFFF' : 'FF000000'; + } + + public function dxfs($readDataOnly = false) + { + $dxfs = []; + if (!$readDataOnly && $this->styleXml) { + // Conditional Styles + if ($this->styleXml->dxfs) { + foreach ($this->styleXml->dxfs->dxf as $dxf) { + $style = new Style(false, true); + $this->readStyle($style, $dxf); + $dxfs[] = $style; + } + } + // Cell Styles + if ($this->styleXml->cellStyles) { + foreach ($this->styleXml->cellStyles->cellStyle as $cellStyle) { + if ((int) ($cellStyle['builtinId']) == 0) { + if (isset($this->cellStyles[(int) ($cellStyle['xfId'])])) { + // Set default style + $style = new Style(); + $this->readStyle($style, $this->cellStyles[(int) ($cellStyle['xfId'])]); + + // normal style, currently not using it for anything + } + } + } + } + } + + return $dxfs; + } + + public function styles() + { + return $this->styles; + } + + private static function getArrayItem($array, $key = 0) + { + return isset($array[$key]) ? $array[$key] : null; + } +} diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Theme.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xlsx/Theme.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Theme.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xml.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xml.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php index 2b7959f47c1..8ab7a9c3954 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Reader/Xml.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml.php @@ -41,7 +41,7 @@ class Xml extends BaseReader */ public function __construct() { - $this->readFilter = new DefaultReadFilter(); + parent::__construct(); $this->securityScanner = XmlScanner::getInstance($this); } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/ReferenceHelper.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php similarity index 98% rename from htdocs/includes/phpoffice/PhpSpreadsheet/ReferenceHelper.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php index 54bc182a8eb..13dbe042a75 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/ReferenceHelper.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/ReferenceHelper.php @@ -82,13 +82,13 @@ class ReferenceHelper */ public static function cellSort($a, $b) { - $ac = $bc = ''; - $ar = $br = 0; + // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax + // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. + // Switch when we drop support for 5.6 + list($ac, $ar) = sscanf($a, '%[A-Z]%d'); + list($bc, $br) = sscanf($b, '%[A-Z]%d'); - sscanf($a, '%[A-Z]%d', $ac, $ar); - sscanf($b, '%[A-Z]%d', $bc, $br); - - if ($ar == $br) { + if ($ar === $br) { return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); } @@ -106,13 +106,13 @@ class ReferenceHelper */ public static function cellReverseSort($a, $b) { - $ac = $bc = ''; - $ar = $br = 0; + // TODO Scrutinizer doesn't like sscanf($a, '%[A-Z]%d', $ac, $ar), and we can't use short list() syntax + // [$ac, $ar] = sscanf($a, '%[A-Z]%d') while retaining PHP 5.6 support. + // Switch when we drop support for 5.6 + list($ac, $ar) = sscanf($a, '%[A-Z]%d'); + list($bc, $br) = sscanf($b, '%[A-Z]%d'); - sscanf($a, '%[A-Z]%d', $ac, $ar); - sscanf($b, '%[A-Z]%d', $bc, $br); - - if ($ar == $br) { + if ($ar === $br) { return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); } @@ -625,7 +625,7 @@ class ReferenceHelper * Update references within formulas. * * @param string $pFormula Formula to update - * @param int $pBefore Insert before this one + * @param string $pBefore Insert before this one * @param int $pNumCols Number of columns to insert * @param int $pNumRows Number of rows to insert * @param string $sheetName Worksheet name/title diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/ITextElement.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/ITextElement.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/ITextElement.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/ITextElement.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/RichText.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/RichText.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/RichText.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/Run.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/Run.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/Run.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/Run.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/RichText/TextElement.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/RichText/TextElement.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/RichText/TextElement.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Settings.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php similarity index 70% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Settings.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php index 22196b7e0e2..c297dd682ea 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Settings.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php @@ -24,6 +24,20 @@ class Settings */ private static $libXmlLoaderOptions = null; + /** + * Allow/disallow libxml_disable_entity_loader() call when not thread safe. + * Default behaviour is to do the check, but if you're running PHP versions + * 7.2 < 7.2.1 + * 7.1 < 7.1.13 + * 7.0 < 7.0.27 + * 5.6 ANY + * then you may need to disable this check to prevent unwanted behaviour in other threads + * SECURITY WARNING: Changing this flag is not recommended. + * + * @var bool + */ + private static $libXmlDisableEntityLoader = true; + /** * The cache implementation to be used for cell collection. * @@ -101,6 +115,34 @@ class Settings return self::$libXmlLoaderOptions; } + /** + * Enable/Disable the entity loader for libxml loader. + * Allow/disallow libxml_disable_entity_loader() call when not thread safe. + * Default behaviour is to do the check, but if you're running PHP versions + * 7.2 < 7.2.1 + * 7.1 < 7.1.13 + * 7.0 < 7.0.27 + * 5.6 ANY + * then you may need to disable this check to prevent unwanted behaviour in other threads + * SECURITY WARNING: Changing this flag to false is not recommended. + * + * @param bool $state + */ + public static function setLibXmlDisableEntityLoader($state) + { + self::$libXmlDisableEntityLoader = (bool) $state; + } + + /** + * Return the state of the entity loader (disabled/enabled) for libxml loader. + * + * @return bool $state + */ + public static function getLibXmlDisableEntityLoader() + { + return self::$libXmlDisableEntityLoader; + } + /** * Sets the implementation of cache that should be used for cell collection. * diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/CodePage.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/CodePage.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/CodePage.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/CodePage.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Date.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Date.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php index 91c3ee0e2ca..5d2deb32c95 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Date.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php @@ -192,7 +192,7 @@ class Date $interval = $days . ' days'; return $baseDate->modify($interval) - ->setTime($hours, $minutes, $seconds); + ->setTime((int) $hours, (int) $minutes, (int) $seconds); } /** @@ -244,12 +244,12 @@ class Date public static function dateTimeToExcel(DateTimeInterface $dateValue) { return self::formattedPHPToExcel( - $dateValue->format('Y'), - $dateValue->format('m'), - $dateValue->format('d'), - $dateValue->format('H'), - $dateValue->format('i'), - $dateValue->format('s') + (int) $dateValue->format('Y'), + (int) $dateValue->format('m'), + (int) $dateValue->format('d'), + (int) $dateValue->format('H'), + (int) $dateValue->format('i'), + (int) $dateValue->format('s') ); } @@ -325,11 +325,12 @@ class Date */ public static function isDateTime(Cell $pCell) { - return self::isDateTimeFormat( - $pCell->getWorksheet()->getStyle( - $pCell->getCoordinate() - )->getNumberFormat() - ); + return is_numeric($pCell->getValue()) && + self::isDateTimeFormat( + $pCell->getWorksheet()->getStyle( + $pCell->getCoordinate() + )->getNumberFormat() + ); } /** diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/File.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/File.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CHANGELOG.TXT diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/LUDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/Matrix.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/Matrix.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/Matrix.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/Matrix.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/QRDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/SingularValueDecomposition.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/utils/Maths.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/JAMA/utils/Maths.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php similarity index 94% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php index 2e9ec256734..f09fbc92adc 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php @@ -537,31 +537,37 @@ class OLE /** * Returns a timestamp from an OLE container's date. * - * @param int $string A binary string with the encoded date + * @param string $oleTimestamp A binary string with the encoded date * - * @return string The timestamp corresponding to the string + * @throws ReaderException + * + * @return int The Unix timestamp corresponding to the string */ - public static function OLE2LocalDate($string) + public static function OLE2LocalDate($oleTimestamp) { - if (strlen($string) != 8) { + if (strlen($oleTimestamp) != 8) { throw new ReaderException('Expecting 8 byte string'); } - // factor used for separating numbers into 4 bytes parts - $factor = pow(2, 32); - list(, $high_part) = unpack('V', substr($string, 4, 4)); - list(, $low_part) = unpack('V', substr($string, 0, 4)); + // convert to units of 100 ns since 1601: + $unpackedTimestamp = unpack('v4', $oleTimestamp); + $timestampHigh = (float) $unpackedTimestamp[4] * 65536 + (float) $unpackedTimestamp[3]; + $timestampLow = (float) $unpackedTimestamp[2] * 65536 + (float) $unpackedTimestamp[1]; - $big_date = ($high_part * $factor) + $low_part; - // translate to seconds - $big_date /= 10000000; + // translate to seconds since 1601: + $timestampHigh /= 10000000; + $timestampLow /= 10000000; - // days from 1-1-1601 until the beggining of UNIX era + // days from 1601 to 1970: $days = 134774; - // translate to seconds from beggining of UNIX era - $big_date -= $days * 24 * 3600; + // translate to seconds since 1970: + $unixTimestamp = floor(65536.0 * 65536.0 * $timestampHigh + $timestampLow - $days * 24 * 3600 + 0.5); - return floor($big_date); + if ((int) $unixTimestamp == $unixTimestamp) { + return (int) $unixTimestamp; + } + + return $unixTimestamp >= 0.0 ? PHP_INT_MAX : PHP_INT_MIN; } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/File.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/File.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/File.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/File.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLE/PPS/Root.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLERead.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLERead.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/OLERead.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLERead.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/PasswordHasher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/PasswordHasher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/PasswordHasher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/PasswordHasher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/StringHelper.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/StringHelper.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/TimeZone.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/TimeZone.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/TimeZone.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/TimeZone.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/BestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/BestFit.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/BestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/BestFit.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php similarity index 97% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 03723d84d4e..5b57f4b71fe 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -113,7 +113,9 @@ class ExponentialBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->exponentialRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LinearBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 367e9d6ec56..217f0964770 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -72,7 +72,9 @@ class LinearBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->linearRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 9092cef8215..96ca2ed8794 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -81,7 +81,9 @@ class LogarithmicBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->logarithmicRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php similarity index 98% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index afcf5f477e4..a1510491f73 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -182,7 +182,9 @@ class PolynomialBestFit extends BestFit */ public function __construct($order, $yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { if ($order < $this->valueCount) { $this->bestFitType .= '_' . $order; $this->order = $order; diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php similarity index 97% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PowerBestFit.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index e1b3b8297cb..4eefec8265c 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -105,7 +105,9 @@ class PowerBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->powerRegression($yValues, $xValues, $const); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/Trend.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/Trend.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Trend/Trend.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Trend/Trend.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/XMLWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/XMLWriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/XMLWriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Xls.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Shared/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Xls.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Spreadsheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Spreadsheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php index 150f71b1e4f..8eadcbe8b1a 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Spreadsheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Spreadsheet.php @@ -715,7 +715,7 @@ class Spreadsheet * * @param string $pName Sheet name * - * @return Worksheet + * @return null|Worksheet */ public function getSheetByName($pName) { diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Alignment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Alignment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Border.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Border.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Borders.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Borders.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Color.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Color.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Conditional.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Conditional.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Fill.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Fill.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/NumberFormat.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php similarity index 95% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/NumberFormat.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php index b6b803787cd..37442249a50 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/NumberFormat.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php @@ -49,6 +49,8 @@ class NumberFormat extends Supervisor const FORMAT_CURRENCY_USD = '$#,##0_-'; const FORMAT_CURRENCY_EUR_SIMPLE = '#,##0.00_-"€"'; const FORMAT_CURRENCY_EUR = '#,##0_-"€"'; + const FORMAT_ACCOUNTING_USD = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; + const FORMAT_ACCOUNTING_EUR = '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)'; /** * Excel built-in number formats. @@ -308,6 +310,22 @@ class NumberFormat extends Supervisor self::$builtInFormats[69] = 't# ?/?'; self::$builtInFormats[70] = 't# ??/??'; + // JPN + self::$builtInFormats[28] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[29] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[31] = 'yyyy"年"m"月"d"日"'; + self::$builtInFormats[32] = 'h"時"mm"分"'; + self::$builtInFormats[33] = 'h"時"mm"分"ss"秒"'; + self::$builtInFormats[34] = 'yyyy"年"m"月"'; + self::$builtInFormats[35] = 'm"月"d"日"'; + self::$builtInFormats[51] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[52] = 'yyyy"年"m"月"'; + self::$builtInFormats[53] = 'm"月"d"日"'; + self::$builtInFormats[54] = '[$-411]ggge"年"m"月"d"日"'; + self::$builtInFormats[55] = 'yyyy"年"m"月"'; + self::$builtInFormats[56] = 'm"月"d"日"'; + self::$builtInFormats[58] = '[$-411]ggge"年"m"月"d"日"'; + // Flip array (for faster lookups) self::$flippedBuiltInFormats = array_flip(self::$builtInFormats); } @@ -596,7 +614,7 @@ class NumberFormat extends Supervisor } // Convert any other escaped characters to quoted strings, e.g. (\T to "T") - $format = preg_replace('/(\\\([^ ]))(?=(?:[^"]|"[^"]*")*$)/u', '"${2}"', $format); + $format = preg_replace('/(\\\(((.)(?!((AM\/PM)|(A\/P))))|([^ ])))(?=(?:[^"]|"[^"]*")*$)/u', '"${2}"', $format); // Get the sections, there can be up to four sections, separated with a semi-colon (but only if not a quoted literal) $sections = preg_split('/(;)(?=(?:[^"]|"[^"]*")*$)/u', $format); diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Protection.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Protection.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Style.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Style.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Style/Supervisor.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Style/Supervisor.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/BaseDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/BaseDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/BaseDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/CellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/CellIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/CellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/CellIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Column.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Column.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Column.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Column.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnCellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnDimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnDimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnDimension.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/ColumnIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/ColumnIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Dimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php similarity index 97% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Dimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php index 44e66323206..697fc97efc3 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Dimension.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -64,7 +64,7 @@ abstract class Dimension */ public function setVisible($pValue) { - $this->visible = $pValue; + $this->visible = (bool) $pValue; return $this; } @@ -119,7 +119,7 @@ abstract class Dimension */ public function setCollapsed($pValue) { - $this->collapsed = $pValue; + $this->collapsed = (bool) $pValue; return $this; } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Drawing/Shadow.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Iterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Iterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Iterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/MemoryDrawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageMargins.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageMargins.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageMargins.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageSetup.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/PageSetup.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Protection.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Protection.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Protection.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Row.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Row.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Row.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Row.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowCellIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowCellIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 59ef329c8b9..8510d402a35 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -170,6 +170,16 @@ class RowCellIterator extends CellIterator return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex; } + /** + * Return the current iterator position. + * + * @return int + */ + public function getCurrentColumnIndex() + { + return $this->currentColumnIndex; + } + /** * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary. * diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowDimension.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowDimension.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowDimension.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowDimension.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowIterator.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/RowIterator.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/SheetView.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/SheetView.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/SheetView.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php index d0224037616..1e525a3fecb 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1096,7 +1096,7 @@ class Worksheet implements IComparable * @param string $column Return the highest data row for the specified column, * or the highest data row of any column if no column letter is passed * - * @return string Highest row number that contains data + * @return int Highest row number that contains data */ public function getHighestDataRow($column = null) { @@ -2064,7 +2064,7 @@ class Worksheet implements IComparable /** * Insert a new column, updating all possible related data. * - * @param int $pBefore Insert before this one, eg: 'A' + * @param string $pBefore Insert before this one, eg: 'A' * @param int $pNumCols Number of columns to insert * * @throws Exception diff --git a/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php new file mode 100644 index 00000000000..f13150d7eb3 --- /dev/null +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -0,0 +1,86 @@ +includeCharts; + } + + public function setIncludeCharts($pValue) + { + $this->includeCharts = (bool) $pValue; + + return $this; + } + + public function getPreCalculateFormulas() + { + return $this->preCalculateFormulas; + } + + public function setPreCalculateFormulas($pValue) + { + $this->preCalculateFormulas = (bool) $pValue; + + return $this; + } + + public function getUseDiskCaching() + { + return $this->useDiskCaching; + } + + public function setUseDiskCaching($pValue, $pDirectory = null) + { + $this->useDiskCaching = $pValue; + + if ($pDirectory !== null) { + if (is_dir($pDirectory)) { + $this->diskCachingDirectory = $pDirectory; + } else { + throw new Exception("Directory does not exist: $pDirectory"); + } + } + + return $this; + } + + public function getDiskCachingDirectory() + { + return $this->diskCachingDirectory; + } +} diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Csv.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Csv.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Csv.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Exception.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Exception.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Exception.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Exception.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Html.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Html.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/BaseWriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php similarity index 53% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/BaseWriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php index 122783f30c6..448b532fc2a 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/BaseWriter.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/IWriter.php @@ -2,38 +2,16 @@ namespace PhpOffice\PhpSpreadsheet\Writer; -abstract class BaseWriter implements IWriter +use PhpOffice\PhpSpreadsheet\Spreadsheet; + +interface IWriter { /** - * Write charts that are defined in the workbook? - * Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object;. + * IWriter constructor. * - * @var bool + * @param Spreadsheet $spreadsheet */ - protected $includeCharts = false; - - /** - * Pre-calculate formulas - * Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are - * immediately available to MS Excel or other office spreadsheet viewer when opening the file. - * - * @var bool - */ - protected $preCalculateFormulas = true; - - /** - * Use disk caching where possible? - * - * @var bool - */ - private $useDiskCaching = false; - - /** - * Disk caching directory. - * - * @var string - */ - private $diskCachingDirectory = './'; + public function __construct(Spreadsheet $spreadsheet); /** * Write charts in workbook? @@ -42,10 +20,7 @@ abstract class BaseWriter implements IWriter * * @return bool */ - public function getIncludeCharts() - { - return $this->includeCharts; - } + public function getIncludeCharts(); /** * Set write charts in workbook @@ -56,12 +31,7 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setIncludeCharts($pValue) - { - $this->includeCharts = (bool) $pValue; - - return $this; - } + public function setIncludeCharts($pValue); /** * Get Pre-Calculate Formulas flag @@ -73,10 +43,7 @@ abstract class BaseWriter implements IWriter * * @return bool */ - public function getPreCalculateFormulas() - { - return $this->preCalculateFormulas; - } + public function getPreCalculateFormulas(); /** * Set Pre-Calculate Formulas @@ -87,22 +54,23 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setPreCalculateFormulas($pValue) - { - $this->preCalculateFormulas = (bool) $pValue; + public function setPreCalculateFormulas($pValue); - return $this; - } + /** + * Save PhpSpreadsheet to file. + * + * @param string $pFilename Name of the file to save + * + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception + */ + public function save($pFilename); /** * Get use disk caching where possible? * * @return bool */ - public function getUseDiskCaching() - { - return $this->useDiskCaching; - } + public function getUseDiskCaching(); /** * Set use disk caching where possible? @@ -114,28 +82,12 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setUseDiskCaching($pValue, $pDirectory = null) - { - $this->useDiskCaching = $pValue; - - if ($pDirectory !== null) { - if (is_dir($pDirectory)) { - $this->diskCachingDirectory = $pDirectory; - } else { - throw new Exception("Directory does not exist: $pDirectory"); - } - } - - return $this; - } + public function setUseDiskCaching($pValue, $pDirectory = null); /** * Get disk caching directory. * * @return string */ - public function getDiskCachingDirectory() - { - return $this->diskCachingDirectory; - } + public function getDiskCachingDirectory(); } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Cell/Comment.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Cell/Comment.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Cell/Comment.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Content.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Content.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Content.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Content.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Meta.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Meta.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Meta.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Meta.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/MetaInf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/MetaInf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/MetaInf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/MetaInf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Mimetype.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Mimetype.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Mimetype.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Mimetype.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Settings.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Settings.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Settings.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Settings.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Styles.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Styles.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Styles.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Styles.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Thumbnails.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/Thumbnails.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/Thumbnails.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/WriterPart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/WriterPart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Ods/WriterPart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Ods/WriterPart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Dompdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Mpdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Pdf/Tcpdf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/BIFFwriter.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Escher.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Escher.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Escher.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Escher.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Font.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Font.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Font.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Font.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Parser.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php similarity index 98% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Parser.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php index e87d09a2233..6049e32878b 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -1009,7 +1009,7 @@ class Parser break; case '>': - if ($this->lookAhead == '=') { // it's a GE token + if ($this->lookAhead === '=') { // it's a GE token break; } @@ -1018,7 +1018,7 @@ class Parser break; case '<': // it's a LE or a NE token - if (($this->lookAhead == '=') or ($this->lookAhead == '>')) { + if (($this->lookAhead === '=') or ($this->lookAhead === '>')) { break; } @@ -1027,12 +1027,12 @@ class Parser break; default: // if it's a reference A1 or $A$1 or $A1 or A$1 - if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) { + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.') and ($this->lookAhead !== '!')) { return $token; - } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { + } elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) return $token; - } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) { + } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) { // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) return $token; } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) { @@ -1044,19 +1044,19 @@ class Parser } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) { // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 return $token; - } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) { + } elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead !== '!') and ($this->lookAhead !== ':')) { // If it's a number (check that it's not a sheet name or range) return $token; - } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead != '"' and (substr_count($token, '"') % 2 == 0)) { + } elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead !== '"' and (substr_count($token, '"') % 2 == 0)) { // If it's a string (of maximum 255 characters) return $token; - } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') { + } elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token === '#N/A') { // If it's an error code return $token; - } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead == '(')) { + } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead === '(')) { // if it's a function call return $token; - } elseif (substr($token, -1) == ')') { + } elseif (substr($token, -1) === ')') { // It's an argument of some description (e.g. a named range), // precise nature yet to be determined return $token; @@ -1078,8 +1078,7 @@ class Parser { $this->currentCharacter = 0; $this->formula = $formula; - $this->lookAhead = isset($formula[1]) ? $formula[1] - : ''; + $this->lookAhead = isset($formula[1]) ? $formula[1] : ''; $this->advance(); $this->parseTree = $this->condition(); @@ -1248,10 +1247,10 @@ class Parser */ private function fact() { - if ($this->currentToken == '(') { + if ($this->currentToken === '(') { $this->advance(); // eat the "(" $result = $this->parenthesizedExpression(); - if ($this->currentToken != ')') { + if ($this->currentToken !== ')') { throw new WriterException("')' token expected."); } $this->advance(); // eat the ")" @@ -1299,7 +1298,7 @@ class Parser return $result; } elseif (is_numeric($this->currentToken)) { // If it's a number or a percent - if ($this->lookAhead == '%') { + if ($this->lookAhead === '%') { $result = $this->createTree('ptgPercent', $this->currentToken, ''); $this->advance(); // Skip the percentage operator once we've pre-built that tree } else { @@ -1331,9 +1330,9 @@ class Parser $result = ''; // initialize result $this->advance(); $this->advance(); // eat the "(" - while ($this->currentToken != ')') { + while ($this->currentToken !== ')') { if ($num_args > 0) { - if ($this->currentToken == ',' || $this->currentToken == ';') { + if ($this->currentToken === ',' || $this->currentToken === ';') { $this->advance(); // eat the "," or ";" } else { throw new WriterException("Syntax error: comma expected in function $function, arg #{$num_args}"); diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Workbook.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php index b463ce4a8f0..41c8e64e297 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -267,9 +267,7 @@ class Workbook extends BIFFwriter $this->xfWriters[] = $xfWriter; - $xfIndex = count($this->xfWriters) - 1; - - return $xfIndex; + return count($this->xfWriters) - 1; } /** @@ -319,7 +317,7 @@ class Workbook extends BIFFwriter if ($colorIndex) { $this->colors[$rgb] = $colorIndex; } else { - if (count($this->colors) == 0) { + if (count($this->colors) === 0) { $lastColor = 7; } else { $lastColor = end($this->colors); @@ -437,7 +435,7 @@ class Workbook extends BIFFwriter // Prepare part 3 of the workbook global stream, what goes after the SHEET records $part3 = ''; - if ($this->countryCode != -1) { + if ($this->countryCode !== -1) { $part3 .= $this->writeCountry(); } $part3 .= $this->writeRecalcId(); @@ -918,7 +916,7 @@ class Workbook extends BIFFwriter $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) + $f1904 = (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) ? 1 : 0; // Flag for 1904 date system diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Xf.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Xf.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xls/Xf.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Xf.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php similarity index 96% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php index dd19021e46e..58897639024 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php @@ -328,6 +328,17 @@ class Xlsx extends BaseWriter $zip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts)); } + // Add unparsed drawings + if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'])) { + foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'] as $relId => $drawingXml) { + $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']); + if ($drawingFile !== false) { + $drawingFile = ltrim($drawingFile, '.'); + $zip->addFromString('xl' . $drawingFile, $drawingXml); + } + } + } + // Add comment relationship parts if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) { // VML Comments @@ -338,8 +349,8 @@ class Xlsx extends BaseWriter } // Add unparsed relationship parts - if (isset($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'])) { - foreach ($unparsedLoadedData['sheets'][$this->spreadSheet->getSheet($i)->getCodeName()]['vmlDrawings'] as $vmlDrawing) { + if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) { + foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) { $zip->addFromString($vmlDrawing['filePath'], $vmlDrawing['content']); } } diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Chart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Chart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Chart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Chart.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Comments.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Comments.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Comments.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Comments.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/DocProps.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Drawing.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Rels.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Rels.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Rels.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Rels.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/StringTable.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Style.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Style.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Style.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Style.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Theme.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Theme.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Theme.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Theme.php diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php similarity index 99% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Workbook.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index e3ddb03c143..b9f8f99b71f 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -93,7 +93,7 @@ class Workbook extends WriterPart { $objWriter->startElement('workbookPr'); - if (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) { + if (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) { $objWriter->writeAttribute('date1904', '1'); } @@ -225,7 +225,7 @@ class Workbook extends WriterPart $objWriter->startElement('sheet'); $objWriter->writeAttribute('name', $pSheetname); $objWriter->writeAttribute('sheetId', $pSheetId); - if ($sheetState != 'visible' && $sheetState != '') { + if ($sheetState !== 'visible' && $sheetState != '') { $objWriter->writeAttribute('state', $sheetState); } $objWriter->writeAttribute('r:id', 'rId' . $pRelId); diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php similarity index 98% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Worksheet.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 78a62e9eca4..065eaaf1c9b 100644 --- a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -141,7 +141,7 @@ class Worksheet extends WriterPart $objWriter->startElement('sheetPr'); if ($pSheet->getParent()->hasMacros()) { //if the workbook have macros, we need to have codeName for the sheet - if ($pSheet->hasCodeName() == false) { + if (!$pSheet->hasCodeName()) { $pSheet->setCodeName($pSheet->getTitle()); } $objWriter->writeAttribute('codeName', $pSheet->getCodeName()); @@ -322,7 +322,7 @@ class Worksheet extends WriterPart } // Set Zero Height row - if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() == '1' || + if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' || strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') { $objWriter->writeAttribute('zeroHeight', '1'); } @@ -383,7 +383,7 @@ class Worksheet extends WriterPart } // Column visibility - if ($colDimension->getVisible() == false) { + if ($colDimension->getVisible() === false) { $objWriter->writeAttribute('hidden', 'true'); } @@ -398,7 +398,7 @@ class Worksheet extends WriterPart } // Collapsed - if ($colDimension->getCollapsed() == true) { + if ($colDimension->getCollapsed() === true) { $objWriter->writeAttribute('collapsed', 'true'); } @@ -428,7 +428,7 @@ class Worksheet extends WriterPart // sheetProtection $objWriter->startElement('sheetProtection'); - if ($pSheet->getProtection()->getPassword() != '') { + if ($pSheet->getProtection()->getPassword() !== '') { $objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword()); } @@ -519,6 +519,9 @@ class Worksheet extends WriterPart // Formula $objWriter->writeElement('formula', $formula); } + } elseif ($conditional->getConditionType() == Conditional::CONDITION_CONTAINSBLANKS) { + // formula copied from ms xlsx xml source file + $objWriter->writeElement('formula', 'LEN(TRIM(' . $cellCoordinate . '))=0'); } $objWriter->endElement(); @@ -624,8 +627,9 @@ class Worksheet extends WriterPart $objWriter->writeAttribute('location', str_replace('sheet://', '', $hyperlink->getUrl())); } - if ($hyperlink->getTooltip() != '') { + if ($hyperlink->getTooltip() !== '') { $objWriter->writeAttribute('tooltip', $hyperlink->getTooltip()); + $objWriter->writeAttribute('display', $hyperlink->getTooltip()); } $objWriter->endElement(); @@ -991,12 +995,12 @@ class Worksheet extends WriterPart } // Row visibility - if ($rowDimension->getVisible() == false) { + if (!$rowDimension->getVisible() === true) { $objWriter->writeAttribute('hidden', 'true'); } // Collapsed - if ($rowDimension->getCollapsed() == true) { + if ($rowDimension->getCollapsed() === true) { $objWriter->writeAttribute('collapsed', 'true'); } @@ -1101,7 +1105,7 @@ class Worksheet extends WriterPart break; case 'f': // Formula $attributes = $pCell->getFormulaAttributes(); - if ($attributes['t'] == 'array') { + if ($attributes['t'] === 'array') { $objWriter->startElement('f'); $objWriter->writeAttribute('t', 'array'); $objWriter->writeAttribute('ref', $pCellAddress); @@ -1114,7 +1118,7 @@ class Worksheet extends WriterPart } if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getPreCalculateFormulas()) { - if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') { + if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') { $objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue)); } else { $objWriter->writeElement('v', '0'); @@ -1135,7 +1139,7 @@ class Worksheet extends WriterPart break; case 'e': // Error - if (substr($cellValue, 0, 1) == '=') { + if (substr($cellValue, 0, 1) === '=') { $objWriter->writeElement('f', substr($cellValue, 1)); $objWriter->writeElement('v', substr($cellValue, 1)); } else { diff --git a/htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php similarity index 100% rename from htdocs/includes/phpoffice/PhpSpreadsheet/Writer/Xlsx/WriterPart.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php diff --git a/htdocs/includes/phpoffice/autoloader.php b/htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php similarity index 81% rename from htdocs/includes/phpoffice/autoloader.php rename to htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php index 71e94e9b738..809725dfb6f 100644 --- a/htdocs/includes/phpoffice/autoloader.php +++ b/htdocs/includes/phpoffice/phpspreadsheet/src/autoloader.php @@ -5,6 +5,6 @@ spl_autoload_register(function ($class_name) { if (1 === $preg_match) { $class_name = preg_replace('/\\\/', '/', $class_name); $class_name = preg_replace('/^PhpOffice\\/PhpSpreadsheet\\//', '', $class_name); - require_once(__DIR__ . '/PhpSpreadsheet/' . $class_name . '.php'); + require_once __DIR__ . '/PhpSpreadsheet/' . $class_name . '.php'; } }); diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index cfe42adc79f..0ca5805ba24 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -33,7 +33,7 @@ global $langs; $err = 0; -$setuplang = GETPOST("selectlang", '', 3) ?GETPOST("selectlang", '', 3) : (isset($_GET["lang"]) ? $_GET["lang"] : 'auto'); +$setuplang = GETPOST("selectlang", '', 3) ? GETPOST("selectlang", '', 3) : (GETPOST('lang', 'alpha', 1) ? GETPOST('lang', 'alpha', 1) : 'auto'); $langs->setDefaultLang($setuplang); $langs->loadLangs(array("install", "errors")); diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 91ceae9eaaa..27a3fc01abd 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -518,7 +518,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas } } if ($setuplang) { - print ''; + print ''; } print ''."\n"; diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index 6133f3eccc8..242fbff25d4 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -106,7 +106,7 @@ function checkLinkedElements($sourcetype, $targettype) foreach ($elements as $key => $element) { if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element'; - $sql .= ' WHERE rowid = '.$key; + $sql .= ' WHERE rowid = '.((int) $key); $resql = $db->query($sql); $deleted++; } diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 882bcd09960..0c6e5bd9be8 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -11,10 +11,6 @@ -- Copyright (C) 2015 Ferran Marcet -- Copyright (C) 2019~ Lao Tian <281388879@qq.com> -- Copyright (C) 2020-2021 Udo Tamm - - - --- LICENSE --------------------------------------------------------------------- -- -- 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 @@ -51,13 +47,67 @@ -- 7 United Kingdom (NOT England) -- +-- CONTENT ------------------------------------------------------------------- +-- +-- Algeria -> for Departmements +-- Andorra -> for Departmements +-- Angola -> for Departmements +-- Argentina +-- Australia -> for Departmements +-- Austria -> for Departmements +-- Barbados -> for Departmements +-- Belgium +-- Bolivia +-- Brazil -> for Departmements +-- Canada -> for Departmements +-- Chile +-- Colombie -> for Departmements +-- France +-- Germany -> for Departmements +-- Greece +-- Italy +-- Netherlands -> for Departmements +-- San Salvador +-- Spain +-- Switzerland/Suisse -> for Departmements/Cantons +-- United Kingdom + + -- TEMPLATE ---------------------------------------------------------------------------------------- insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 0, 0, '0',0,'-'); +-- Algeria Regions (id country=13) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 13, 1301, '', 0, 'Algerie'); + + +-- Andorra Regions (id country=18) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 34, 34000, 'AD', NULL, 'Andorra'); + + +-- Angola Regions (id country=35) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES ( 35, 35001, 'AO', NULL, 'Angola'); + + +-- Argentina Regions (id country=23) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2301, '', 0, 'Norte'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2302, '', 0, 'Litoral'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2303, '', 0, 'Cuyana'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2304, '', 0, 'Central'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 23, 2305, '', 0, 'Patagonia'); + + +-- Australia Regions (id country=28) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 28, 2801, '', 0, 'Australia'); + + -- Austria Regions (id country=41) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 41, 4101, '', 0, 'Österreich', 1); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 41, 4101, '', 0, 'Österreich'); + + +-- Barbados Regions (id country=46) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 46, 4601, '', 0, 'Barbados'); -- Belgium Regions (id country=2) @@ -66,98 +116,156 @@ insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2, 203, '',3,'Bruxelles-Capitale'); --- Regions France (id country=1) -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 1,'97105',3,'Guadeloupe'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 2,'97209',3,'Martinique'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 3,'97302',3,'Guyane'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 4,'97411',3,'Réunion'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 6,'97601',3,'Mayotte'); - -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 11,'75056',1,'Île-de-France'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 24,'45234',2,'Centre-Val de Loire'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 27,'21231',0,'Bourgogne-Franche-Comté'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 28,'76540',0,'Normandie'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 32,'59350',4,'Hauts-de-France'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 44,'67482',2,'Grand Est'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 52,'44109',4,'Pays de la Loire'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 53,'35238',0,'Bretagne'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 75,'33063',0,'Nouvelle-Aquitaine'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 76,'31355',1,'Occitanie'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 84,'69123',1,'Auvergne-Rhône-Alpes'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 93,'13055',0,'Provence-Alpes-Côte d''Azur'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 1, 94,'2A004',0,'Corse'); +-- Bolivia Regions (id country=52) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5201, '', 0, 'Chuquisaca'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5202, '', 0, 'La Paz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5203, '', 0, 'Cochabamba'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5204, '', 0, 'Oruro'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5205, '', 0, 'Potosí'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5206, '', 0, 'Tarija'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5207, '', 0, 'Santa Cruz'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5208, '', 0, 'El Beni'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 52, 5209, '', 0, 'Pando'); --- Regions Italy (id country=3) -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 301, NULL, 1, 'Abruzzo'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 302, NULL, 1, 'Basilicata'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 303, NULL, 1, 'Calabria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 304, NULL, 1, 'Campania'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 305, NULL, 1, 'Emilia-Romagna'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 306, NULL, 1, 'Friuli-Venezia Giulia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 307, NULL, 1, 'Lazio'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 308, NULL, 1, 'Liguria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 309, NULL, 1, 'Lombardia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 310, NULL, 1, 'Marche'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 311, NULL, 1, 'Molise'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 312, NULL, 1, 'Piemonte'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 313, NULL, 1, 'Puglia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 314, NULL, 1, 'Sardegna'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 315, NULL, 1, 'Sicilia'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 316, NULL, 1, 'Toscana'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 317, NULL, 1, 'Trentino-Alto Adige'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 318, NULL, 1, 'Umbria'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 319, NULL, 1, 'Valle d Aosta'); -insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values ( 3, 320, NULL, 1, 'Veneto'); +-- Brazil Regions (id country=56) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 56, 5601, '', 0, 'Brasil'); --- Regions Spain (id country=4) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 401, '', 0, 'Andalucia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 402, '', 0, 'Aragón', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 403, '', 0, 'Castilla y León', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 404, '', 0, 'Castilla la Mancha', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 405, '', 0, 'Canarias', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 406, '', 0, 'Cataluña', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 407, '', 0, 'Comunidad de Ceuta', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 408, '', 0, 'Comunidad Foral de Navarra', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 409, '', 0, 'Comunidad de Melilla', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 410, '', 0, 'Cantabria', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 411, '', 0, 'Comunidad Valenciana', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 412, '', 0, 'Extemadura', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 413, '', 0, 'Galicia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 414, '', 0, 'Islas Baleares', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 415, '', 0, 'La Rioja', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 416, '', 0, 'Comunidad de Madrid', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 417, '', 0, 'Región de Murcia', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 418, '', 0, 'Principado de Asturias', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 419, '', 0, 'Pais Vasco', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 4, 420, '', 0, 'Otros', 1); --- Regions Germany (id country=5) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 5, 501, '', 0, 'Deutschland', 1); +-- Canada Region (id country=14) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 14, 1401, '', 0, 'Canada'); --- Regions Greece (id_country=102) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10201, 102, NULL, NULL, 'Αττική', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10202, 102, NULL, NULL, 'Στερεά Ελλάδα', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10203, 102, NULL, NULL, 'Κεντρική Μακεδονία', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10204, 102, NULL, NULL, 'Κρήτη', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10205, 102, NULL, NULL, 'Ανατολική Μακεδονία και Θράκη', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10206, 102, NULL, NULL, 'Ήπειρος', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10207, 102, NULL, NULL, 'Ιόνια νησιά', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10208, 102, NULL, NULL, 'Βόρειο Αιγαίο', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10209, 102, NULL, NULL, 'Πελοπόννησος', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10210, 102, NULL, NULL, 'Νότιο Αιγαίο', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10211, 102, NULL, NULL, 'Δυτική Ελλάδα', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10212, 102, NULL, NULL, 'Θεσσαλία', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 10213, 102, NULL, NULL, 'Δυτική Μακεδονία', 1); --- Regions Switzerland (id country=6) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 6, 601, '', 1, 'Cantons', 1); +-- Chile Regions (id country=67) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6701, NULL, NULL, 'Tarapacá'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6702, NULL, NULL, 'Antofagasta'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6703, NULL, NULL, 'Atacama'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6704, NULL, NULL, 'Coquimbo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6705, NULL, NULL, 'Valparaíso'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6706, NULL, NULL, 'General Bernardo O Higgins'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6707, NULL, NULL, 'Maule'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6708, NULL, NULL, 'Biobío'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6709, NULL, NULL, 'Raucanía'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6710, NULL, NULL, 'Los Lagos'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6711, NULL, NULL, 'Aysén General Carlos Ibáñez del Campo'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6712, NULL, NULL, 'Magallanes y Antártica Chilena'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6713, NULL, NULL, 'Metropolitana de Santiago'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6714, NULL, NULL, 'Los Ríos'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 67, 6715, NULL, NULL, 'Arica y Parinacota'); + + +-- Colombie Regions (id country=70) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 70, 7001, '', 0, 'Colombie'); + + +-- France Regions (id country=1) +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 1, '97105', 3, 'Guadeloupe'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 2, '97209', 3, 'Martinique'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 3, '97302', 3, 'Guyane'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 4, '97411', 3, 'Réunion'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 6, '97601', 3, 'Mayotte'); + +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 11, '75056', 1, 'Île-de-France'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 24, '45234', 2, 'Centre-Val de Loire'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 27, '21231', 0, 'Bourgogne-Franche-Comté'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 28, '76540', 0, 'Normandie'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 32, '59350', 4, 'Hauts-de-France'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 44, '67482', 2, 'Grand Est'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 52, '44109', 4, 'Pays de la Loire'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 53, '35238', 0, 'Bretagne'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 75, '33063', 0, 'Nouvelle-Aquitaine'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 76, '31355', 1, 'Occitanie'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 84, '69123', 1, 'Auvergne-Rhône-Alpes'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 93, '13055', 0, 'Provence-Alpes-Côte d''Azur'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 1, 94, '2A004', 0, 'Corse'); + + +-- Germany Regions (id country=5) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 5, 501, '', 0, 'Deutschland'); + + +-- Greece Regions (id_country=102) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10201, NULL, NULL, 'Αττική'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10202, NULL, NULL, 'Στερεά Ελλάδα'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10203, NULL, NULL, 'Κεντρική Μακεδονία'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10204, NULL, NULL, 'Κρήτη'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10205, NULL, NULL, 'Ανατολική Μακεδονία και Θράκη'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10206, NULL, NULL, 'Ήπειρος'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10207, NULL, NULL, 'Ιόνια νησιά'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10208, NULL, NULL, 'Βόρειο Αιγαίο'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10209, NULL, NULL, 'Πελοπόννησος'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10210, NULL, NULL, 'Νότιο Αιγαίο'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10211, NULL, NULL, 'Δυτική Ελλάδα'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10212, NULL, NULL, 'Θεσσαλία'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (102, 10213, NULL, NULL, 'Δυτική Μακεδονία'); + + +-- Italy Regions (id country=3) +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 301, NULL, 1, 'Abruzzo'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 302, NULL, 1, 'Basilicata'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 303, NULL, 1, 'Calabria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 304, NULL, 1, 'Campania'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 305, NULL, 1, 'Emilia-Romagna'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 306, NULL, 1, 'Friuli-Venezia Giulia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 307, NULL, 1, 'Lazio'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 308, NULL, 1, 'Liguria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 309, NULL, 1, 'Lombardia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 310, NULL, 1, 'Marche'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 311, NULL, 1, 'Molise'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 312, NULL, 1, 'Piemonte'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 313, NULL, 1, 'Puglia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 314, NULL, 1, 'Sardegna'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 315, NULL, 1, 'Sicilia'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 316, NULL, 1, 'Toscana'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 317, NULL, 1, 'Trentino-Alto Adige'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 318, NULL, 1, 'Umbria'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 319, NULL, 1, 'Valle d Aosta'); +insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 3, 320, NULL, 1, 'Veneto'); + + +-- Netherlands Regions (id country=17) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 17, 1701, '', 0,'Provincies van Nederland '); + + +-- San Salvador Regions (id country=86) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8601, NULL, NULL, 'Central'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8602, NULL, NULL, 'Oriental'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values (86, 8603, NULL, NULL, 'Occidental'); + + +-- Spain Regions (id country=4) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 401, '', 0, 'Andalucia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 402, '', 0, 'Aragón'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 403, '', 0, 'Castilla y León'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 404, '', 0, 'Castilla la Mancha'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 405, '', 0, 'Canarias'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 406, '', 0, 'Cataluña'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 407, '', 0, 'Comunidad de Ceuta'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 408, '', 0, 'Comunidad Foral de Navarra'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 409, '', 0, 'Comunidad de Melilla'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 410, '', 0, 'Cantabria'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 411, '', 0, 'Comunidad Valenciana'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 412, '', 0, 'Extemadura'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 413, '', 0, 'Galicia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 414, '', 0, 'Islas Baleares'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 415, '', 0, 'La Rioja'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 416, '', 0, 'Comunidad de Madrid'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 417, '', 0, 'Región de Murcia'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 418, '', 0, 'Principado de Asturias'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 419, '', 0, 'Pais Vasco'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 4, 420, '', 0, 'Otros'); + + +-- Switzerland Regions (id country=6) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 6, 601, '', 1, 'Cantons'); + + +-- UK United Kingdom Regions (id_country=7) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 701, '', 0, 'England'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 702, '', 0, 'Wales'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 703, '', 0, 'Scotland'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 7, 704, '', 0, 'Northern Ireland'); --- Regions UK United Kingdom (id_country=7) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 701, '', 0, 'England', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 702, '', 0, 'Wales', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 703, '', 0, 'Scotland', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 7, 704, '', 0, 'Northern Ireland', 1); -- Regions Tunisia (id country=10) insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1001, '',0,'Ariana'); @@ -185,76 +293,19 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,102 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1023, '',0,'Tunis'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (10,1024, '',0,'Zaghouan'); + -- Region USA (id country=11) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 11, 1101, '', 0, 'United-States', 1); --- Regions Algeria (id country=13) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 13, 1301, '', 0, 'Algerie', 1); - --- Region Canada (id country=14) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 14, 1401, '', 0, 'Canada', 1); - --- Regions The Netherlands (id country=17) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 17, 1701, '', 0,'Provincies van Nederland ', 1); - --- Regions Argentina (id country=23) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2301, '', 0, 'Norte', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2302, '', 0, 'Litoral', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2303, '', 0, 'Cuyana', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2304, '', 0, 'Central', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 23, 2305, '', 0, 'Patagonia', 1); - --- Regions Australia (id country=28) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 28, 2801, '', 0, 'Australia', 1); - --- Regions Barbados (id country=46) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 46, 4601, '', 0, 'Barbados', 1); - --- Regions Bolivia (id country=52) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5201, '', 0, 'Chuquisaca', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5202, '', 0, 'La Paz', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5203, '', 0, 'Cochabamba', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5204, '', 0, 'Oruro', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5205, '', 0, 'Potosí', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5206, '', 0, 'Tarija', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5207, '', 0, 'Santa Cruz', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5208, '', 0, 'El Beni', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5209, '', 0, 'Pando', 1); - --- Regions Brazil (id country=56) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 56, 5601, '', 0, 'Brasil', 1); - --- Regions Colombie (id country=70) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 70, 7001, '', 0, 'Colombie', 1); - --- Regions Chile (id country=67) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6701, 67, NULL, NULL, 'Tarapacá', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6702, 67, NULL, NULL, 'Antofagasta', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6703, 67, NULL, NULL, 'Atacama', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6704, 67, NULL, NULL, 'Coquimbo', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6705, 67, NULL, NULL, 'Valparaíso', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6706, 67, NULL, NULL, 'General Bernardo O Higgins', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6707, 67, NULL, NULL, 'Maule', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6708, 67, NULL, NULL, 'Biobío', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6709, 67, NULL, NULL, 'Raucanía', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6710, 67, NULL, NULL, 'Los Lagos', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6711, 67, NULL, NULL, 'Aysén General Carlos Ibáñez del Campo', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6712, 67, NULL, NULL, 'Magallanes y Antártica Chilena', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6713, 67, NULL, NULL, 'Metropolitana de Santiago', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6714, 67, NULL, NULL, 'Los Ríos', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 6715, 67, NULL, NULL, 'Arica y Parinacota', 1); - --- Regions San Salvador (id country=86) -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8601, 86, NULL, NULL, 'Central', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8602, 86, NULL, NULL, 'Oriental', 1); -INSERT INTO llx_c_regions ( code_region, fk_pays, cheflieu, tncc, nom, active) values ( 8603, 86, NULL, NULL, 'Occidental', 1); -- Regions Honduras (id country=114) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 114, 11401, '', 0, 'Honduras', 1); + -- Regions India (id country=117) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 117, 11701, '', 0, 'India', 1); + -- Regions Indonesia (id country=118) insert into llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 118, 11801, '', 0, 'Indonesia', 1); @@ -347,8 +398,6 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) va -- Regions United Arab Emirates (rowid country=227) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 227, 22701, '', 0, 'United Arab Emirates', 1); --- Regions Andorra (rowid country=18) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (34, 34000, 'AD', NULL, 'Andorra'); -- Regions Hungary (rowid country=18) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (18, 183100, 'HU31', NULL, 'Northern Hungary'); @@ -403,8 +452,6 @@ insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 932 insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 933, '港',0,'香港特别行政区'); insert into llx_c_regions (fk_pays,code_region,cheflieu,tncc,nom) values (9, 934, '澳',0,'澳门特别行政区'); --- Regions Angola (rowid country=35) -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (35, 35001, 'AO', NULL, 'Angola'); -- Regions Taiwan (rowid country=213) INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) VALUES (213, 21301, 'TW', NULL, 'Taiwan'); diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 82201f8d3a6..b48831bbd39 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -7,11 +7,10 @@ -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2010-2016 Juanjo Menent -- Copyright (C) 2012 Sebastian Neuwert --- Copyright (C) 2012 Ricardo Schluter --- Copyright (C) 2015 Ferran Marcet +-- Copyright (C) 2012 Ricardo Schluter +-- Copyright (C) 2015 Ferran Marcet +-- Copyright (C) 2020-2021 Udo Tamm -- - --- LICENSE ------------------------------------------------------------------- -- 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 @@ -27,15 +26,36 @@ -- --- WARNING ------------------------------------------------------------------- +-- WARNING --------------------------------------------------------------------- -- Do not put comments at the end of the lines, this file is parsed during -- the install and all '-' prefixed texts are removed. -- Do not concatenate the values in a single query, for the same reason. --- NOTES ---------------------------------- +-- NOTES/CONTENT --------------------------------------------------------------- -- Departements/Cantons/Provinces/States -- +-- Algeria +-- Andorra +-- Angola +-- Argentina +-- Australia +-- Austria +-- Barbados +-- Belgium +-- Brazil +-- Canada +-- Chile +-- Colombia +-- France +-- Germany +-- Honduras +-- (Italy) +-- Luxembourg +-- Netherlands +-- (Moroco) +-- Romania + -- TEMPLATE ------------------------------------------------------------------------------------------------------------- @@ -43,109 +63,309 @@ insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc -- Algeria Provinces (id country=13) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL01', '', 0, '', 'Wilaya d''Adrar', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL02', '', 0, '', 'Wilaya de Chlef', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL03', '', 0, '', 'Wilaya de Laghouat', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL04', '', 0, '', 'Wilaya d''Oum El Bouaghi', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL05', '', 0, '', 'Wilaya de Batna', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL06', '', 0, '', 'Wilaya de Béjaïa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL07', '', 0, '', 'Wilaya de Biskra', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL08', '', 0, '', 'Wilaya de Béchar', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL09', '', 0, '', 'Wilaya de Blida', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL10', '', 0, '', 'Wilaya de Bouira', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL11', '', 0, '', 'Wilaya de Tamanrasset', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL12', '', 0, '', 'Wilaya de Tébessa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL13', '', 0, '', 'Wilaya de Tlemcen', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL14', '', 0, '', 'Wilaya de Tiaret', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL15', '', 0, '', 'Wilaya de Tizi Ouzou', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL16', '', 0, '', 'Wilaya d''Alger', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL17', '', 0, '', 'Wilaya de Djelfa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL18', '', 0, '', 'Wilaya de Jijel', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL19', '', 0, '', 'Wilaya de Sétif ', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL20', '', 0, '', 'Wilaya de Saïda', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL21', '', 0, '', 'Wilaya de Skikda', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL22', '', 0, '', 'Wilaya de Sidi Bel Abbès', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL23', '', 0, '', 'Wilaya d''Annaba', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL24', '', 0, '', 'Wilaya de Guelma', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL25', '', 0, '', 'Wilaya de Constantine', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL26', '', 0, '', 'Wilaya de Médéa', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL27', '', 0, '', 'Wilaya de Mostaganem', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL28', '', 0, '', 'Wilaya de M''Sila', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL29', '', 0, '', 'Wilaya de Mascara', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL30', '', 0, '', 'Wilaya d''Ouargla', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL31', '', 0, '', 'Wilaya d''Oran', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL32', '', 0, '', 'Wilaya d''El Bayadh', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL33', '', 0, '', 'Wilaya d''Illizi', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL34', '', 0, '', 'Wilaya de Bordj Bou Arreridj', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL35', '', 0, '', 'Wilaya de Boumerdès', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL36', '', 0, '', 'Wilaya d''El Tarf', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL37', '', 0, '', 'Wilaya de Tindouf', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL38', '', 0, '', 'Wilaya de Tissemsilt', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL39', '', 0, '', 'Wilaya d''El Oued', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL40', '', 0, '', 'Wilaya de Khenchela', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL41', '', 0, '', 'Wilaya de Souk Ahras', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL42', '', 0, '', 'Wilaya de Tipaza', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL43', '', 0, '', 'Wilaya de Mila', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL44', '', 0, '', 'Wilaya d''Aïn Defla', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL45', '', 0, '', 'Wilaya de Naâma', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL46', '', 0, '', 'Wilaya d''Aïn Témouchent', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL47', '', 0, '', 'Wilaya de Ghardaia', 1); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom, active) VALUES(1301, 'AL48', '', 0, '', 'Wilaya de Relizane', 1); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL01', '', 0, '', 'Wilaya d''Adrar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL02', '', 0, '', 'Wilaya de Chlef'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL03', '', 0, '', 'Wilaya de Laghouat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL04', '', 0, '', 'Wilaya d''Oum El Bouaghi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL05', '', 0, '', 'Wilaya de Batna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL06', '', 0, '', 'Wilaya de Béjaïa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL07', '', 0, '', 'Wilaya de Biskra'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL08', '', 0, '', 'Wilaya de Béchar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL09', '', 0, '', 'Wilaya de Blida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL10', '', 0, '', 'Wilaya de Bouira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL11', '', 0, '', 'Wilaya de Tamanrasset'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL12', '', 0, '', 'Wilaya de Tébessa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL13', '', 0, '', 'Wilaya de Tlemcen'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL14', '', 0, '', 'Wilaya de Tiaret'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL15', '', 0, '', 'Wilaya de Tizi Ouzou'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL16', '', 0, '', 'Wilaya d''Alger'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL17', '', 0, '', 'Wilaya de Djelfa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL18', '', 0, '', 'Wilaya de Jijel'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL19', '', 0, '', 'Wilaya de Sétif'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL20', '', 0, '', 'Wilaya de Saïda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL21', '', 0, '', 'Wilaya de Skikda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL22', '', 0, '', 'Wilaya de Sidi Bel Abbès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL23', '', 0, '', 'Wilaya d''Annaba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL24', '', 0, '', 'Wilaya de Guelma'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL25', '', 0, '', 'Wilaya de Constantine'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL26', '', 0, '', 'Wilaya de Médéa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL27', '', 0, '', 'Wilaya de Mostaganem'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL28', '', 0, '', 'Wilaya de M''Sila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL29', '', 0, '', 'Wilaya de Mascara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL30', '', 0, '', 'Wilaya d''Ouargla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL31', '', 0, '', 'Wilaya d''Oran'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL32', '', 0, '', 'Wilaya d''El Bayadh'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL33', '', 0, '', 'Wilaya d''Illizi'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL34', '', 0, '', 'Wilaya de Bordj Bou Arreridj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL35', '', 0, '', 'Wilaya de Boumerdès'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL36', '', 0, '', 'Wilaya d''El Tarf'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL37', '', 0, '', 'Wilaya de Tindouf'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL38', '', 0, '', 'Wilaya de Tissemsilt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL39', '', 0, '', 'Wilaya d''El Oued'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL40', '', 0, '', 'Wilaya de Khenchela'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL41', '', 0, '', 'Wilaya de Souk Ahras'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL42', '', 0, '', 'Wilaya de Tipaza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL43', '', 0, '', 'Wilaya de Mila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL44', '', 0, '', 'Wilaya d''Aïn Defla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL45', '', 0, '', 'Wilaya de Naâma'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL46', '', 0, '', 'Wilaya d''Aïn Témouchent'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL47', '', 0, '', 'Wilaya de Ghardaia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1301, 'AL48', '', 0, '', 'Wilaya de Relizane'); -- Andorra Parròquies (id country=34) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-002', 'AD100', NULL, NULL, 'Canillo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-003', 'AD200', NULL, NULL, 'Encamp'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-004', 'AD400', NULL, NULL, 'La Massana'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-005', 'AD300', NULL, NULL, 'Ordino'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-006', 'AD600', NULL, NULL, 'Sant Julià de Lòria'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-007', 'AD500', NULL, NULL, 'Andorra la Vella'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-002', 'AD100', NULL, NULL, 'Canillo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-003', 'AD200', NULL, NULL, 'Encamp'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-004', 'AD400', NULL, NULL, 'La Massana'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-005', 'AD300', NULL, NULL, 'Ordino'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-006', 'AD600', NULL, NULL, 'Sant Julià de Lòria'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-007', 'AD500', NULL, NULL, 'Andorra la Vella'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (34000, 'AD-008', 'AD700', NULL, NULL, 'Escaldes-Engordany'); + + +-- Angola Provinces (postal districts) (id country=35) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-ABO', NULL, NULL, 'BENGO', 'Bengo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-BGU', NULL, NULL, 'BENGUELA', 'Benguela'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-BIE', NULL, NULL, 'BIÉ', 'Bié'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CAB', NULL, NULL, 'CABINDA', 'Cabinda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CCU', NULL, NULL, 'KUANDO KUBANGO', 'Kuando Kubango'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CNO', NULL, NULL, 'KWANZA NORTE', 'Kwanza Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CUS', NULL, NULL, 'KWANZA SUL', 'Kwanza Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-CNN', NULL, NULL, 'CUNENE', 'Cunene'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-HUA', NULL, NULL, 'HUAMBO', 'Huambo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-HUI', NULL, NULL, 'HUÍLA', 'Huila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LUA', NULL, NULL, 'LUANDA', 'Luanda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LNO', NULL, NULL, 'LUNDA-NORTE', 'Lunda-Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-LSU',NULL, NULL, 'LUNDA-SUL', 'Lunda-Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-MAL', NULL, NULL, 'MALANGE', 'Malange'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-MOX', NULL, NULL, 'MOXICO', 'Moxico'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-NAM', NULL, NULL, 'NAMÍBE', 'Namíbe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-UIG', NULL, NULL, 'UÍGE', 'Uíge'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (35001, 'AO-ZAI', NULL, NULL, 'ZAÍRE', 'Zaíre'); + + +-- Argentina Provinces / provincias (id country=23) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2301', '', 0, 'CATAMARCA', 'Catamarca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2302', '', 0, 'JUJUY', 'Jujuy'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2303', '', 0, 'TUCAMAN', 'Tucamán'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2304', '', 0, 'SANTIAGO DEL ESTERO', 'Santiago del Estero'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2301, '2305', '', 0, 'SALTA', 'Salta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2306', '', 0, 'CHACO', 'Chaco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2307', '', 0, 'CORRIENTES', 'Corrientes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2308', '', 0, 'ENTRE RIOS', 'Entre Ríos'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2309', '', 0, 'FORMOSA', 'Formosa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2302, '2310', '', 0, 'SANTA FE', 'Santa Fe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2311', '', 0, 'LA RIOJA', 'La Rioja'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2312', '', 0, 'MENDOZA', 'Mendoza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2313', '', 0, 'SAN JUAN', 'San Juan'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2303, '2314', '', 0, 'SAN LUIS', 'San Luis'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2315', '', 0, 'CORDOBA', 'Córdoba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2316', '', 0, 'BUENOS AIRES', 'Buenos Aires'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2304, '2317', '', 0, 'CABA', 'Caba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2318', '', 0, 'LA PAMPA', 'La Pampa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2319', '', 0, 'NEUQUEN', 'Neuquén'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2320', '', 0, 'RIO NEGRO', 'Río Negro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2321', '', 0, 'CHUBUT', 'Chubut'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2322', '', 0, 'SANTA CRUZ', 'Santa Cruz'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2323', '', 0, 'TIERRA DEL FUEGO', 'Tierra del Fuego'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2324', '', 0, 'ISLAS MALVINAS', 'Islas Malvinas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2325', '', 0, 'ANTARTIDA', 'Antártida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (2305, '2326', '', 0, 'MISIONES', 'Misiones'); -- Australia States & Territories (id country=28) -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'NSW','',1,'','New South Wales'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'VIC','',1,'','Victoria'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'QLD','',1,'','Queensland'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'SA' ,'',1,'','South Australia'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'ACT','',1,'','Australia Capital Territory'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'TAS','',1,'','Tasmania'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'WA' ,'',1,'','Western Australia'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801,'NT' ,'',1,'','Northern Territory'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'NSW','',1,'','New South Wales'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'VIC','',1,'','Victoria'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'QLD','',1,'','Queensland'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'SA' ,'',1,'','South Australia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'ACT','',1,'','Australia Capital Territory'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'TAS','',1,'','Tasmania'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'WA' ,'',1,'','Western Australia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (2801, 'NT' ,'',1,'','Northern Territory'); -- Austria States / Österreich Bundesländer (id country=41) -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'B','BURGENLAND','Burgenland',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'K','KAERNTEN','Kärnten',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'N','NIEDEROESTERREICH','Niederösterreich',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'O','OBEROESTERREICH','Oberösterreich',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'S','SALZBURG','Salzburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'ST','STEIERMARK','Steiermark',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'T','TIROL','Tirol',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'V','VORARLBERG','Vorarlberg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101,'W','WIEN','Wien',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'B','BURGENLAND','Burgenland',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'K','KAERNTEN','Kärnten',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'N','NIEDEROESTERREICH','Niederösterreich',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'O','OBEROESTERREICH','Oberösterreich',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'S','SALZBURG','Salzburg',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'ST','STEIERMARK','Steiermark',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'T','TIROL','Tirol',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'V','VORARLBERG','Vorarlberg',1); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (4101, 'W','WIEN','Wien',1); + + +-- Barbados Parish (id country=46) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'CC', 'Oistins', 0, 'CC', 'Christ Church'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SA', 'Greenland', 0, 'SA', 'Saint Andrew'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SG', 'Bulkeley', 0, 'SG', 'Saint George'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'JA', 'Holetown', 0, 'JA', 'Saint James'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SJ', 'Four Roads', 0, 'SJ', 'Saint John'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SB', 'Bathsheba', 0, 'SB', 'Saint Joseph'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SL', 'Crab Hill', 0, 'SL', 'Saint Lucy'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SM', 'Bridgetown', 0, 'SM', 'Saint Michael'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SP', 'Speightstown', 0, 'SP', 'Saint Peter'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'SC', 'Crane', 0, 'SC', 'Saint Philip'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (4601, 'ST', 'Hillaby', 0, 'ST', 'Saint Thomas'); -- Belgium Provinces (id country=2) -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'01','',1,'ANVERS','Anvers'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (203,'02','',3,'BRUXELLES-CAPITALE','Bruxelles-Capitale'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202,'03','',2,'BRABANT-WALLON','Brabant-Wallon'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'04','',1,'BRABANT-FLAMAND','Brabant-Flamand'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'05','',1,'FLANDRE-OCCIDENTALE','Flandre-Occidentale'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'06','',1,'FLANDRE-ORIENTALE','Flandre-Orientale'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202,'07','',2,'HAINAUT','Hainaut'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'08','',2,'LIEGE','Liège'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202,'09','',1,'LIMBOURG','Limbourg'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202,'10','',2,'LUXEMBOURG','Luxembourg'); -insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201,'11','',2,'NAMUR','Namur'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '01','',1,'ANVERS','Anvers'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (203, '02','',3,'BRUXELLES-CAPITALE','Bruxelles-Capitale'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202, '03','',2,'BRABANT-WALLON','Brabant-Wallon'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '04','',1,'BRABANT-FLAMAND','Brabant-Flamand'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '05','',1,'FLANDRE-OCCIDENTALE','Flandre-Occidentale'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '06','',1,'FLANDRE-ORIENTALE','Flandre-Orientale'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202, '07','',2,'HAINAUT','Hainaut'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '08','',2,'LIEGE','Liège'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202, '09','',1,'LIMBOURG','Limbourg'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (202, '10','',2,'LUXEMBOURG','Luxembourg'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (201, '11','',2,'NAMUR','Namur'); --- Departements France (id country=1) -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 1,'971','97105',3,'GUADELOUPE','Guadeloupe'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 2,'972','97209',3,'MARTINIQUE','Martinique'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 3,'973','97302',3,'GUYANE','Guyane'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 4,'974','97411',3,'REUNION','Réunion'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values ( 6,'976','97601',3,'MAYOTTE','Mayotte'); +-- Brazil Provinces (id country=56) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AC', 'ACRE', 0, 'AC', 'Acre'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AL', 'ALAGOAS', 0, 'AL', 'Alagoas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AP', 'AMAPA', 0, 'AP', 'Amapá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'AM', 'AMAZONAS', 0, 'AM', 'Amazonas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'BA', 'BAHIA', 0, 'BA', 'Bahia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'CE', 'CEARA', 0, 'CE', 'Ceará'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'ES', 'ESPIRITO SANTO', 0, 'ES', 'Espirito Santo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'GO', 'GOIAS', 0, 'GO', 'Goiás'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MA', 'MARANHAO', 0, 'MA', 'Maranhão'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MT', 'MATO GROSSO', 0, 'MT', 'Mato Grosso'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MS', 'MATO GROSSO DO SUL', 0, 'MS', 'Mato Grosso do Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'MG', 'MINAS GERAIS', 0, 'MG', 'Minas Gerais'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PA', 'PARA', 0, 'PA', 'Pará'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PB', 'PARAIBA', 0, 'PB', 'Paraiba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PR', 'PARANA', 0, 'PR', 'Paraná'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PE', 'PERNAMBUCO', 0, 'PE', 'Pernambuco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'PI', 'PIAUI', 0, 'PI', 'Piauí'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RJ', 'RIO DE JANEIRO', 0, 'RJ', 'Rio de Janeiro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RN', 'RIO GRANDE DO NORTE', 0, 'RN', 'Rio Grande do Norte'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RS', 'RIO GRANDE DO SUL', 0, 'RS', 'Rio Grande do Sul'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RO', 'RONDONIA', 0, 'RO', 'Rondônia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'RR', 'RORAIMA', 0, 'RR', 'Roraima'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SC', 'SANTA CATARINA', 0, 'SC', 'Santa Catarina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SE', 'SERGIPE', 0, 'SE', 'Sergipe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'SP', 'SAO PAULO', 0, 'SP', 'Sao Paulo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'TO', 'TOCANTINS', 0, 'TO', 'Tocantins'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (5601, 'DF', 'DISTRITO FEDERAL', 0, 'DF', 'Distrito Federal'); + + +-- Canada Provinces & Territories (id country=14) +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'ON','',1,'','Ontario'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'QC','',1,'','Quebec'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'NS','',1,'','Nova Scotia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'NB','',1,'','New Brunswick'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'MB','',1,'','Manitoba'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'BC','',1,'','British Columbia'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'PE','',1,'','Prince Edward Island'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'SK','',1,'','Saskatchewan'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'AB','',1,'','Alberta'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values (1401, 'NL','',1,'','Newfoundland and Labrador'); + + +-- Chile Provinces (id country=67) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6701, '011', '', 0, '011', 'Iquique'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6701, '014', '', 0, '014', 'Tamarugal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '021', '', 0, '021', 'Antofagasa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '022', '', 0, '022', 'El Loa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6702, '023', '', 0, '023', 'Tocopilla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '031', '', 0, '031', 'Copiapó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '032', '', 0, '032', 'Chañaral'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6703, '033', '', 0, '033', 'Huasco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '041', '', 0, '041', 'Elqui'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '042', '', 0, '042', 'Choapa'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6704, '043', '', 0, '043', 'Limarí'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '051', '', 0, '051', 'Valparaíso'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '052', '', 0, '052', 'Isla de Pascua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '053', '', 0, '053', 'Los Andes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '054', '', 0, '054', 'Petorca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '055', '', 0, '055', 'Quillota'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '056', '', 0, '056', 'San Antonio'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '057', '', 0, '057', 'San Felipe de Aconcagua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6705, '058', '', 0, '058', 'Marga Marga'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '061', '', 0, '061', 'Cachapoal'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '062', '', 0, '062', 'Cardenal Caro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6706, '063', '', 0, '063', 'Colchagua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '071', '', 0, '071', 'Talca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '072', '', 0, '072', 'Cauquenes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '073', '', 0, '073', 'Curicó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6707, '074', '', 0, '074', 'Linares'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '081', '', 0, '081', 'Concepción'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '082', '', 0, '082', 'Arauco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '083', '', 0, '083', 'Biobío'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6708, '084', '', 0, '084', 'Ñuble'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6709, '091', '', 0, '091', 'Cautín'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6709, '092', '', 0, '092', 'Malleco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '101', '', 0, '101', 'Llanquihue'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '102', '', 0, '102', 'Chiloé'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '103', '', 0, '103', 'Osorno'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6710, '104', '', 0, '104', 'Palena'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '111', '', 0, '111', 'Coihaique'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '112', '', 0, '112', 'Aisén'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '113', '', 0, '113', 'Capitán Prat'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6711, '114', '', 0, '114', 'General Carrera'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '121', '', 0, '121', 'Magallanes'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '122', '', 0, '122', 'Antártica Chilena'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '123', '', 0, '123', 'Tierra del Fuego'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6712, '124', '', 0, '124', 'Última Esperanza'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '131', '', 0, '131', 'Santiago'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '132', '', 0, '132', 'Cordillera'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '133', '', 0, '133', 'Chacabuco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '134', '', 0, '134', 'Maipo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '135', '', 0, '135', 'Melipilla'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6713, '136', '', 0, '136', 'Talagante'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6714, '141', '', 0, '141', 'Valdivia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6714, '142', '', 0, '142', 'Ranco'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6715, '151', '', 0, '151', 'Arica'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (6715, '152', '', 0, '152', 'Parinacota'); + + +-- Colombia Departamentos (id country=70) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ANT', '', 0, 'ANT', 'Antioquia'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOL', '', 0, 'BOL', 'Bolívar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOY', '', 0, 'BOY', 'Boyacá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAL', '', 0, 'CAL', 'Caldas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAU', '', 0, 'CAU', 'Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CUN', '', 0, 'CUN', 'Cundinamarca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'HUI', '', 0, 'HUI', 'Huila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'LAG', '', 0, 'LAG', 'La Guajira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MET', '', 0, 'MET', 'Meta'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NAR', '', 0, 'NAR', 'Nariño'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'NDS', '', 0, 'NDS', 'Norte de Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAN', '', 0, 'SAN', 'Santander'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SUC', '', 0, 'SUC', 'Sucre'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'TOL', '', 0, 'TOL', 'Tolima'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAC', '', 0, 'VAC', 'Valle del Cauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'RIS', '', 0, 'RIS', 'Risalda'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ATL', '', 0, 'ATL', 'Atlántico'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'COR', '', 0, 'COR', 'Córdoba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'SAP', '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'ARA', '', 0, 'ARA', 'Arauca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAS', '', 0, 'CAS', 'Casanare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'AMA', '', 0, 'AMA', 'Amazonas'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CAQ', '', 0, 'CAQ', 'Caquetá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CHO', '', 0, 'CHO', 'Chocó'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUA', '', 0, 'GUA', 'Guainía'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'GUV', '', 0, 'GUV', 'Guaviare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'PUT', '', 0, 'PUT', 'Putumayo'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'QUI', '', 0, 'QUI', 'Quindío'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VAU', '', 0, 'VAU', 'Vaupés'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'BOG', '', 0, 'BOG', 'Bogotá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'VID', '', 0, 'VID', 'Vichada'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'CES', '', 0, 'CES', 'Cesar'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (7001, 'MAG', '', 0, 'MAG', 'Magdalena'); + + +-- France Departements (id country=1) +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 1, '971','97105',3,'GUADELOUPE','Guadeloupe'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 2, '972','97209',3,'MARTINIQUE','Martinique'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 3, '973','97302',3,'GUYANE','Guyane'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 4, '974','97411',3,'REUNION','Réunion'); +insert into llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) values ( 6, '976','97601',3,'MAYOTTE','Mayotte'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (84,'01','01053',5,'AIN','Ain'); insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (32,'02','02408',5,'AISNE','Aisne'); @@ -245,6 +465,47 @@ insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,no insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (11,'95','95500',2,'VAL-D OISE','Val-d Oise'); +-- Germany States / Bundesländer (id country=5) +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BW', 'BADEN-WÜRTTEMBERG', 'Baden-Württemberg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BY', 'BAYERN', 'Bayern'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BE', 'BERLIN', 'Berlin'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'BB', 'BRANDENBURG', 'Brandenburg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HB', 'BREMEN', 'Bremen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HH', 'HAMBURG', 'Hamburg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'HE', 'HESSEN', 'Hessen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'MV', 'MECKLENBURG-VORPOMMERN', 'Mecklenburg-Vorpommern'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'NI', 'NIEDERSACHSEN', 'Niedersachsen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'NW', 'NORDRHEIN-WESTFALEN', 'Nordrhein-Westfalen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'RP', 'RHEINLAND-PFALZ', 'Rheinland-Pfalz'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SL', 'SAARLAND', 'Saarland'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SN', 'SACHSEN', 'Sachsen'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'ST', 'SACHSEN-ANHALT', 'Sachsen-Anhalt'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'SH', 'SCHLESWIG-HOLSTEIN', 'Schleswig-Holstein'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (501, 'TH', 'THÜRINGEN', 'Thüringen'); + + +-- Honduras Departamentos (id country=114) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'AT', '', 0, 'AT', 'Atlántida'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'CH', '', 0, 'CH', 'Choluteca'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'CL', '', 0, 'CL', 'Colón'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'CM', '', 0, 'CM', 'Comayagua'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'CO', '', 0, 'CO', 'Copán'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'CR', '', 0, 'CR', 'Cortés'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'EP', '', 0, 'EP', 'El Paraíso'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'FM', '', 0, 'FM', 'Francisco Morazán'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'GD', '', 0, 'GD', 'Gracias a Dios'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'IN', '', 0, 'IN', 'Intibucá'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'IB', '', 0, 'IB', 'Islas de la Bahía'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'LP', '', 0, 'LP', 'La Paz'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'LM', '', 0, 'LM', 'Lempira'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'OC', '', 0, 'OC', 'Ocotepeque'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'OL', '', 0, 'OL', 'Olancho'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'SB', '', 0, 'SB', 'Santa Bárbara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'VL', '', 0, 'VL', 'Valle'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'YO', '', 0, 'YO', 'Yoro'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (11401, 'DC', '', 0, 'DC', 'Distrito Central'); + + -- Provinces Italy (id=3) insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('AG',315,NULL,NULL,NULL,'AGRIGENTO'); insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('AL',312,NULL,NULL,NULL,'ALESSANDRIA'); @@ -358,6 +619,36 @@ insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom insert into llx_c_departements (code_departement,fk_region,cheflieu,tncc,ncc,nom) values ('VT',307,NULL,NULL,NULL,'VITERBO'); +-- Luxembourg Cantons (id country=140) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14001, 'LU0001', '', 0, '', 'Clervaux'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14001, 'LU0002', '', 0, '', 'Diekirch'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14001, 'LU0003', '', 0, '', 'Redange'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14001, 'LU0004', '', 0, '', 'Vianden'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14001, 'LU0005', '', 0, '', 'Wiltz'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14002, 'LU0006', '', 0, '', 'Echternach'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14002, 'LU0007', '', 0, '', 'Grevenmacher'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14002, 'LU0008', '', 0, '', 'Remich'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0009', '', 0, '', 'Capellen'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0010', '', 0, '', 'Esch-sur-Alzette'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0011', '', 0, '', 'Luxembourg'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (14003, 'LU0012', '', 0, '', 'Mersch'); + + +-- 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'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'DR', NULL, NULL, NULL, 'Drenthe'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'OV', NULL, NULL, NULL, 'Overijssel'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'GD', NULL, NULL, NULL, 'Gelderland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'FL', NULL, NULL, NULL, 'Flevoland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'UT', NULL, NULL, NULL, 'Utrecht'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'NH', NULL, NULL, NULL, 'Noord-Holland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'ZH', NULL, NULL, NULL, 'Zuid-Holland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'ZL', NULL, NULL, NULL, 'Zeeland'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (1701, 'NB', NULL, NULL, NULL, 'Noord-Brabant'); +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); @@ -442,6 +733,52 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc 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); + +-- Romania Provinces (id country=188) +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AB', '', 0, '', 'Alba'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AR', '', 0, '', 'Arad'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'AG', '', 0, '', 'Argeș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BC', '', 0, '', 'Bacău'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BH', '', 0, '', 'Bihor'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BN', '', 0, '', 'Bistrița-Năsăud'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BT', '', 0, '', 'Botoșani'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BV', '', 0, '', 'Brașov'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BR', '', 0, '', 'Brăila'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BU', '', 0, '', 'Bucuresti'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'BZ', '', 0, '', 'Buzău'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CL', '', 0, '', 'Călărași'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CS', '', 0, '', 'Caraș-Severin'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CJ', '', 0, '', 'Cluj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CT', '', 0, '', 'Constanța'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'CV', '', 0, '', 'Covasna'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'DB', '', 0, '', 'Dâmbovița'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'DJ', '', 0, '', 'Dolj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GL', '', 0, '', 'Galați'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GR', '', 0, '', 'Giurgiu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'GJ', '', 0, '', 'Gorj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'HR', '', 0, '', 'Harghita'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'HD', '', 0, '', 'Hunedoara'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IL', '', 0, '', 'Ialomița'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IS', '', 0, '', 'Iași'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'IF', '', 0, '', 'Ilfov'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MM', '', 0, '', 'Maramureș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MH', '', 0, '', 'Mehedinți'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'MS', '', 0, '', 'Mureș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'NT', '', 0, '', 'Neamț'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'OT', '', 0, '', 'Olt'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'PH', '', 0, '', 'Prahova'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SM', '', 0, '', 'Satu Mare'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SJ', '', 0, '', 'Sălaj'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SB', '', 0, '', 'Sibiu'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'SV', '', 0, '', 'Suceava'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TR', '', 0, '', 'Teleorman'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TM', '', 0, '', 'Timiș'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'TL', '', 0, '', 'Tulcea'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VS', '', 0, '', 'Vaslui'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VL', '', 0, '', 'Vâlcea'); +INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES (18801, 'VN', '', 0, '', 'Vrancea'); + + -- Provinces Tunisia (id country=10) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN01', 1001, '', 0, '', 'Ariana', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN02', 1001, '', 0, '', 'Béja', 1); @@ -468,6 +805,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN23', 1001, '', 0, '', 'Tunis', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES('TN24', 1001, '', 0, '', 'Zaghouan', 1); + -- Provinces Bolivia (id country=52) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('001', 5201, '', 0, '', 'Belisario Boeto', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('002', 5201, '', 0, '', 'Hernando Siles', 1); @@ -583,18 +921,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('112', 5209, '', 0, '', 'General Federico Román', 1); --- Provinces Canada (id country=14) -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'ON','',1,'','Ontario'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'QC','',1,'','Quebec'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'NS','',1,'','Nova Scotia'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'NB','',1,'','New Brunswick'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'MB','',1,'','Manitoba'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'BC','',1,'','British Columbia'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'PE','',1,'','Prince Edward Island'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'SK','',1,'','Saskatchewan'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'AB','',1,'','Alberta'); -insert into llx_c_departements (fk_region, code_departement,cheflieu,tncc,ncc,nom) values (1401,'NL','',1,'','Newfoundland and Labrador'); - -- Provinces Spain (id country=4) in order of province (for logical pick list) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('VI', '419', '01', 19, 'ALAVA', 'Álava'); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('AB', '404', '02', 4, 'ALBACETE', 'Albacete'); @@ -649,23 +975,6 @@ INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('ZA', '403', '49', 3, 'ZAMORA', 'Zamora'); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom) VALUES ('Z', '402', '50', 1, 'ZARAGOZA', 'Zaragoza'); --- Provinces Germany (id country=5) -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BW','BADEN-WÜRTTEMBERG','Baden-Württemberg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BY','BAYERN','Bayern',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BE','BERLIN','Berlin',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'BB','BRANDENBURG','Brandenburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HB','BREMEN','Bremen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HH','HAMBURG','Hamburg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'HE','HESSEN','Hessen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'MV','MECKLENBURG-VORPOMMERN','Mecklenburg-Vorpommern',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'NI','NIEDERSACHSEN','Niedersachsen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'NW','NORDRHEIN-WESTFALEN','Nordrhein-Westfalen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'RP','RHEINLAND-PFALZ','Rheinland-Pfalz',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SL','SAARLAND','Saarland',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SN','SACHSEN','Sachsen',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'ST','SACHSEN-ANHALT','Sachsen-Anhalt',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'SH','SCHLESWIG-HOLSTEIN','Schleswig-Holstein',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (501,'TH','THÜRINGEN','Thüringen',1); -- Provinces Greece (id country=102) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('66', 10201, '', 0, '', 'Αθήνα', 1); @@ -736,33 +1045,35 @@ INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('64', 10204, '', 0, '', 'Ρέθυμνο', 1); INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('65', 10204, '', 0, '', 'Χανιά', 1); --- Cantons Switzerland (id country=6) -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'AG','ARGOVIE','Argovie',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'AI','APPENZELL RHODES INTERIEURES','Appenzell Rhodes intérieures',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'AR','APPENZELL RHODES EXTERIEURES','Appenzell Rhodes extérieures',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'BE','BERNE','Berne',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'BL','BALE CAMPAGNE','Bâle Campagne',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'BS','BALE VILLE','Bâle Ville',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'FR','FRIBOURG','Fribourg',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'GE','GENEVE','Genève',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'GL','GLARIS','Glaris',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'GR','GRISONS','Grisons',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'JU','JURA','Jura',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'LU','LUCERNE','Lucerne',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'NE','NEUCHATEL','Neuchâtel',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'NW','NIDWALD','Nidwald',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'OW','OBWALD','Obwald',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'SG','SAINT-GALL','Saint-Gall',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'SH','SCHAFFHOUSE','Schaffhouse',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'SO','SOLEURE','Soleure',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'SZ','SCHWYZ','Schwyz',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'TG','THURGOVIE','Thurgovie',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'TI','TESSIN','Tessin',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'UR','URI','Uri',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'VD','VAUD','Vaud',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'VS','VALAIS','Valais',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'ZG','ZUG','Zug',1); -INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom, active) VALUES (601,'ZH','ZURICH','Zürich',1); + +-- Switzerland Cantons (id country=6) +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'AG','ARGOVIE','Argovie'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'AI','APPENZELL RHODES INTERIEURES','Appenzell Rhodes intérieures'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'AR','APPENZELL RHODES EXTERIEURES','Appenzell Rhodes extérieures'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'BE','BERNE','Berne'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'BL','BALE CAMPAGNE','Bâle Campagne'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'BS','BALE VILLE','Bâle Ville'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'FR','FRIBOURG','Fribourg'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'GE','GENEVE','Genève'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'GL','GLARIS','Glaris'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'GR','GRISONS','Grisons'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'JU','JURA','Jura'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'LU','LUCERNE','Lucerne'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'NE','NEUCHATEL','Neuchâtel'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'NW','NIDWALD','Nidwald'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'OW','OBWALD','Obwald'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'SG','SAINT-GALL','Saint-Gall'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'SH','SCHAFFHOUSE','Schaffhouse'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'SO','SOLEURE','Soleure'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'SZ','SCHWYZ','Schwyz'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'TG','THURGOVIE','Thurgovie'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'TI','TESSIN','Tessin'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'UR','URI','Uri'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'VD','VAUD','Vaud'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'VS','VALAIS','Valais'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'ZG','ZUG','Zug'); +INSERT INTO llx_c_departements (fk_region, code_departement, ncc, nom) VALUES (601, 'ZH','ZURICH','Zürich'); + -- Provinces GB (id country=7) INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('701', 701, NULL, 0,NULL, 'Bedfordshire', 1); @@ -938,19 +1249,6 @@ insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) values ('WI', 1101, '', 0, 'WISCONSIN', 'Wisconsin', 1); insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) values ('WY', 1101, '', 0, 'WYOMING', 'Wyoming', 1); --- Provincies van het Koninkrijk der Nederlanden (id country=17) -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('GR',1701,NULL,NULL,NULL,'Groningen',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('FR',1701,NULL,NULL,NULL,'Friesland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('DR',1701,NULL,NULL,NULL,'Drenthe',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('OV',1701,NULL,NULL,NULL,'Overijssel',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('GD',1701,NULL,NULL,NULL,'Gelderland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('FL',1701,NULL,NULL,NULL,'Flevoland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('UT',1701,NULL,NULL,NULL,'Utrecht',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('NH',1701,NULL,NULL,NULL,'Noord-Holland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('ZH',1701,NULL,NULL,NULL,'Zuid-Holland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('ZL',1701,NULL,NULL,NULL,'Zeeland',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('NB',1701,NULL,NULL,NULL,'Noord-Brabant',1); -INSERT INTO llx_c_departements ( code_departement,fk_region,cheflieu,tncc,ncc,nom,active) VALUES ('LB',1701,NULL,NULL,NULL,'Limburg',1); -- San Salvador (id country=86) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SS', 8601, '', 0, '', 'San Salvador', 1); @@ -968,132 +1266,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SV', 8601, '', 0, '', 'San Vicente', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CU', 8601, '', 0, '', 'Cuscatlan', 1); --- Provinces Argentina (id country=23) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2301', 2301, '', 0, 'CATAMARCA', 'Catamarca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2302', 2301, '', 0, 'JUJUY', 'Jujuy', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2303', 2301, '', 0, 'TUCAMAN', 'Tucamán', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2304', 2301, '', 0, 'SANTIAGO DEL ESTERO', 'Santiago del Estero', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2305', 2301, '', 0, 'SALTA', 'Salta', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2306', 2302, '', 0, 'CHACO', 'Chaco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2307', 2302, '', 0, 'CORRIENTES', 'Corrientes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2308', 2302, '', 0, 'ENTRE RIOS', 'Entre Ríos', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2309', 2302, '', 0, 'FORMOSA', 'Formosa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2310', 2302, '', 0, 'SANTA FE', 'Santa Fe', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2311', 2303, '', 0, 'LA RIOJA', 'La Rioja', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2312', 2303, '', 0, 'MENDOZA', 'Mendoza', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2313', 2303, '', 0, 'SAN JUAN', 'San Juan', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2314', 2303, '', 0, 'SAN LUIS', 'San Luis', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2315', 2304, '', 0, 'CORDOBA', 'Córdoba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2316', 2304, '', 0, 'BUENOS AIRES', 'Buenos Aires', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2317', 2304, '', 0, 'CABA', 'Caba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2318', 2305, '', 0, 'LA PAMPA', 'La Pampa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2319', 2305, '', 0, 'NEUQUEN', 'Neuquén', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2320', 2305, '', 0, 'RIO NEGRO', 'Río Negro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2321', 2305, '', 0, 'CHUBUT', 'Chubut', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2322', 2305, '', 0, 'SANTA CRUZ', 'Santa Cruz', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2323', 2305, '', 0, 'TIERRA DEL FUEGO', 'Tierra del Fuego', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2324', 2305, '', 0, 'ISLAS MALVINAS', 'Islas Malvinas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2325', 2305, '', 0, 'ANTARTIDA', 'Antártida', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('2326', 2305, '', 0, 'MISIONES', 'Misiones', 1); - --- Parish Barbados (id country=46) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CC', 4601, 'Oistins', 0, 'CC', 'Christ Church', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SA', 4601, 'Greenland', 0, 'SA', 'Saint Andrew', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SG', 4601, 'Bulkeley', 0, 'SG', 'Saint George', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('JA', 4601, 'Holetown', 0, 'JA', 'Saint James', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SJ', 4601, 'Four Roads', 0, 'SJ', 'Saint John', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SB', 4601, 'Bathsheba', 0, 'SB', 'Saint Joseph', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SL', 4601, 'Crab Hill', 0, 'SL', 'Saint Lucy', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SM', 4601, 'Bridgetown', 0, 'SM', 'Saint Michael', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SP', 4601, 'Speightstown', 0, 'SP', 'Saint Peter', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SC', 4601, 'Crane', 0, 'SC', 'Saint Philip', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ST', 4601, 'Hillaby', 0, 'ST', 'Saint Thomas', 1); - --- Provinces Brazil (id country=56) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AC', 5601, 'ACRE', 0, 'AC', 'Acre', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AL', 5601, 'ALAGOAS', 0, 'AL', 'Alagoas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AP', 5601, 'AMAPA', 0, 'AP', 'Amapá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AM', 5601, 'AMAZONAS', 0, 'AM', 'Amazonas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BA', 5601, 'BAHIA', 0, 'BA', 'Bahia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CE', 5601, 'CEARA', 0, 'CE', 'Ceará', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ES', 5601, 'ESPIRITO SANTO', 0, 'ES', 'Espirito Santo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GO', 5601, 'GOIAS', 0, 'GO', 'Goiás', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MA', 5601, 'MARANHAO', 0, 'MA', 'Maranhão', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MT', 5601, 'MATO GROSSO', 0, 'MT', 'Mato Grosso', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MS', 5601, 'MATO GROSSO DO SUL', 0, 'MS', 'Mato Grosso do Sul', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MG', 5601, 'MINAS GERAIS', 0, 'MG', 'Minas Gerais', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PA', 5601, 'PARA', 0, 'PA', 'Pará', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PB', 5601, 'PARAIBA', 0, 'PB', 'Paraiba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PR', 5601, 'PARANA', 0, 'PR', 'Paraná', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PE', 5601, 'PERNAMBUCO', 0, 'PE', 'Pernambuco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PI', 5601, 'PIAUI', 0, 'PI', 'Piauí', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RJ', 5601, 'RIO DE JANEIRO', 0, 'RJ', 'Rio de Janeiro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RN', 5601, 'RIO GRANDE DO NORTE', 0, 'RN', 'Rio Grande do Norte', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RS', 5601, 'RIO GRANDE DO SUL', 0, 'RS', 'Rio Grande do Sul', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RO', 5601, 'RONDONIA', 0, 'RO', 'Rondônia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RR', 5601, 'RORAIMA', 0, 'RR', 'Roraima', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SC', 5601, 'SANTA CATARINA', 0, 'SC', 'Santa Catarina', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SE', 5601, 'SERGIPE', 0, 'SE', 'Sergipe', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SP', 5601, 'SAO PAULO', 0, 'SP', 'Sao Paulo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TO', 5601, 'TOCANTINS', 0, 'TO', 'Tocantins', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DF', 5601, 'DISTRITO FEDERAL', 0, 'DF', 'Distrito Federal', 1); - - --- Provinces Chile (id country=67) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('151', 6715, '', 0, '151', 'Arica', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('152', 6715, '', 0, '152', 'Parinacota', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('011', 6701, '', 0, '011', 'Iquique', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('014', 6701, '', 0, '014', 'Tamarugal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('021', 6702, '', 0, '021', 'Antofagasa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('022', 6702, '', 0, '022', 'El Loa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('023', 6702, '', 0, '023', 'Tocopilla', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('031', 6703, '', 0, '031', 'Copiapó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('032', 6703, '', 0, '032', 'Chañaral', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('033', 6703, '', 0, '033', 'Huasco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('041', 6704, '', 0, '041', 'Elqui', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('042', 6704, '', 0, '042', 'Choapa', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('043', 6704, '', 0, '043', 'Limarí', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('051', 6705, '', 0, '051', 'Valparaíso', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('052', 6705, '', 0, '052', 'Isla de Pascua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('053', 6705, '', 0, '053', 'Los Andes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('054', 6705, '', 0, '054', 'Petorca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('055', 6705, '', 0, '055', 'Quillota', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('056', 6705, '', 0, '056', 'San Antonio', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('057', 6705, '', 0, '057', 'San Felipe de Aconcagua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('058', 6705, '', 0, '058', 'Marga Marga', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('061', 6706, '', 0, '061', 'Cachapoal', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('062', 6706, '', 0, '062', 'Cardenal Caro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('063', 6706, '', 0, '063', 'Colchagua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('071', 6707, '', 0, '071', 'Talca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('072', 6707, '', 0, '072', 'Cauquenes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('073', 6707, '', 0, '073', 'Curicó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('074', 6707, '', 0, '074', 'Linares', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('081', 6708, '', 0, '081', 'Concepción', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('082', 6708, '', 0, '082', 'Arauco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('083', 6708, '', 0, '083', 'Biobío', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('084', 6708, '', 0, '084', 'Ñuble', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('091', 6709, '', 0, '091', 'Cautín', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('092', 6709, '', 0, '092', 'Malleco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('141', 6714, '', 0, '141', 'Valdivia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('142', 6714, '', 0, '142', 'Ranco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('101', 6710, '', 0, '101', 'Llanquihue', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('102', 6710, '', 0, '102', 'Chiloé', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('103', 6710, '', 0, '103', 'Osorno', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('104', 6710, '', 0, '104', 'Palena', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('111', 6711, '', 0, '111', 'Coihaique', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('112', 6711, '', 0, '112', 'Aisén', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('113', 6711, '', 0, '113', 'Capitán Prat', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('114', 6711, '', 0, '114', 'General Carrera', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('121', 6712, '', 0, '121', 'Magallanes', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('122', 6712, '', 0, '122', 'Antártica Chilena', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('123', 6712, '', 0, '123', 'Tierra del Fuego', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('124', 6712, '', 0, '124', 'Última Esperanza', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('131', 6713, '', 0, '131', 'Santiago', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('132', 6713, '', 0, '132', 'Cordillera', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('133', 6713, '', 0, '133', 'Chacabuco', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('134', 6713, '', 0, '134', 'Maipo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('135', 6713, '', 0, '135', 'Melipilla', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('136', 6713, '', 0, '136', 'Talagante', 1); -- Provinces India (id country=117) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AN', 11701, NULL, 0, 'AN', 'Andaman & Nicobar', 1); @@ -1204,106 +1376,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ZAC', 15401, '', 0, 'ZAC', 'Zacatecas', 1); --- Provinces Colombia (id country=70) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ANT', 7001, '', 0, 'ANT', 'Antioquia', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOL', 7001, '', 0, 'BOL', 'Bolívar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOY', 7001, '', 0, 'BOY', 'Boyacá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAL', 7001, '', 0, 'CAL', 'Caldas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAU', 7001, '', 0, 'CAU', 'Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CUN', 7001, '', 0, 'CUN', 'Cundinamarca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HUI', 7001, '', 0, 'HUI', 'Huila', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LAG', 7001, '', 0, 'LAG', 'La Guajira', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MET', 7001, '', 0, 'MET', 'Meta', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NAR', 7001, '', 0, 'NAR', 'Nariño', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NDS', 7001, '', 0, 'NDS', 'Norte de Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAN', 7001, '', 0, 'SAN', 'Santander', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SUC', 7001, '', 0, 'SUC', 'Sucre', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TOL', 7001, '', 0, 'TOL', 'Tolima', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAC', 7001, '', 0, 'VAC', 'Valle del Cauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('RIS', 7001, '', 0, 'RIS', 'Risalda', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ATL', 7001, '', 0, 'ATL', 'Atlántico', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('COR', 7001, '', 0, 'COR', 'Córdoba', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SAP', 7001, '', 0, 'SAP', 'San Andrés, Providencia y Santa Catalina', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ARA', 7001, '', 0, 'ARA', 'Arauca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAS', 7001, '', 0, 'CAS', 'Casanare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AMA', 7001, '', 0, 'AMA', 'Amazonas', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CAQ', 7001, '', 0, 'CAQ', 'Caquetá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CHO', 7001, '', 0, 'CHO', 'Chocó', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUA', 7001, '', 0, 'GUA', 'Guainía', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GUV', 7001, '', 0, 'GUV', 'Guaviare', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PUT', 7001, '', 0, 'PUT', 'Putumayo', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('QUI', 7001, '', 0, 'QUI', 'Quindío', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VAU', 7001, '', 0, 'VAU', 'Vaupés', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOG', 7001, '', 0, 'BOG', 'Bogotá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VID', 7001, '', 0, 'VID', 'Vichada', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CES', 7001, '', 0, 'CES', 'Cesar', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MAG', 7001, '', 0, 'MAG', 'Magdalena', 1); - --- Provinces Honduras (id country=114) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AT', 11401, '', 0, 'AT', 'Atlántida', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CH', 11401, '', 0, 'CH', 'Choluteca', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CL', 11401, '', 0, 'CL', 'Colón', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CM', 11401, '', 0, 'CM', 'Comayagua', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CO', 11401, '', 0, 'CO', 'Copán', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CR', 11401, '', 0, 'CR', 'Cortés', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('EP', 11401, '', 0, 'EP', 'El Paraíso', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('FM', 11401, '', 0, 'FM', 'Francisco Morazán', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GD', 11401, '', 0, 'GD', 'Gracias a Dios', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IN', 11401, '', 0, 'IN', 'Intibucá', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IB', 11401, '', 0, 'IB', 'Islas de la Bahía', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LP', 11401, '', 0, 'LP', 'La Paz', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LM', 11401, '', 0, 'LM', 'Lempira', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('OC', 11401, '', 0, 'OC', 'Ocotepeque', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('OL', 11401, '', 0, 'OL', 'Olancho', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SB', 11401, '', 0, 'SB', 'Santa Bárbara', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VL', 11401, '', 0, 'VL', 'Valle', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('YO', 11401, '', 0, 'YO', 'Yoro', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DC', 11401, '', 0, 'DC', 'Distrito Central', 1); - --- Provinces Romania (id country=188) -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AB', 18801, '', 0, '', 'Alba', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AR', 18801, '', 0, '', 'Arad', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AG', 18801, '', 0, '', 'Argeș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BC', 18801, '', 0, '', 'Bacău', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BH', 18801, '', 0, '', 'Bihor', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BN', 18801, '', 0, '', 'Bistrița-Năsăud', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BT', 18801, '', 0, '', 'Botoșani', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BV', 18801, '', 0, '', 'Brașov', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BR', 18801, '', 0, '', 'Brăila', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BZ', 18801, '', 0, '', 'Buzău', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CL', 18801, '', 0, '', 'Călărași', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CS', 18801, '', 0, '', 'Caraș-Severin', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CJ', 18801, '', 0, '', 'Cluj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CT', 18801, '', 0, '', 'Constanța', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CV', 18801, '', 0, '', 'Covasna', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DB', 18801, '', 0, '', 'Dâmbovița', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DJ', 18801, '', 0, '', 'Dolj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GL', 18801, '', 0, '', 'Galați', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GR', 18801, '', 0, '', 'Giurgiu', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('GJ', 18801, '', 0, '', 'Gorj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HR', 18801, '', 0, '', 'Harghita', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('HD', 18801, '', 0, '', 'Hunedoara', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IL', 18801, '', 0, '', 'Ialomița', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IS', 18801, '', 0, '', 'Iași', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('IF', 18801, '', 0, '', 'Ilfov', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MM', 18801, '', 0, '', 'Maramureș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MH', 18801, '', 0, '', 'Mehedinți', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('MS', 18801, '', 0, '', 'Mureș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('NT', 18801, '', 0, '', 'Neamț', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('OT', 18801, '', 0, '', 'Olt', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('PH', 18801, '', 0, '', 'Prahova', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SM', 18801, '', 0, '', 'Satu Mare', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SJ', 18801, '', 0, '', 'Sălaj', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SB', 18801, '', 0, '', 'Sibiu', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('SV', 18801, '', 0, '', 'Suceava', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TR', 18801, '', 0, '', 'Teleorman', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TM', 18801, '', 0, '', 'Timiș', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('TL', 18801, '', 0, '', 'Tulcea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VS', 18801, '', 0, '', 'Vaslui', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VL', 18801, '', 0, '', 'Vâlcea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VN', 18801, '', 0, '', 'Vrancea', 1); -INSERT INTO llx_c_departements (code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BU', 18801, '', 0, '', 'Bucuresti', 1); - -- Provinces Venezuela (id country=232) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-L', 23201, '', 0, 'VE-L', 'Mérida', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-T', 23201, '', 0, 'VE-T', 'Trujillo', 1); @@ -1331,19 +1403,6 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-V', 23209, '', 0, 'VE-V', 'Zulia', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('VE-S', 23209, '', 0, 'VE-S', 'Táchira', 1); --- Cantons Luxembourg (id country=140) -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0001', 14001, '', 0, '', 'Clervaux', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0002', 14001, '', 0, '', 'Diekirch', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0003', 14001, '', 0, '', 'Redange', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0004', 14001, '', 0, '', 'Vianden', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0005', 14001, '', 0, '', 'Wiltz', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0006', 14002, '', 0, '', 'Echternach', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0007', 14002, '', 0, '', 'Grevenmacher', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0008', 14002, '', 0, '', 'Remich', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0009', 14003, '', 0, '', 'Capellen', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0010', 14003, '', 0, '', 'Esch-sur-Alzette', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0011', 14003, '', 0, '', 'Luxembourg', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0012', 14003, '', 0, '', 'Mersch', 1); -- Provinces Peru (id country=181) INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('0101', 18101, '', 0, '', 'Chachapoyas', 1); @@ -1622,25 +1681,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 ('20204', 'SI043', NULL, NULL, 'GORIZIA', 'Gorizia'); INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('20204', 'SI044', NULL, NULL, 'COASTAL–KARST', 'Coastal–Karst'); --- Provinces (postal districts) Angola (rowid country=35) -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-ABO', NULL, NULL, 'BENGO', 'Bengo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-BGU', NULL, NULL, 'BENGUELA', 'Benguela'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-BIE', NULL, NULL, 'BIÉ', 'Bié'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CAB', NULL, NULL, 'CABINDA', 'Cabinda'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CCU', NULL, NULL, 'KUANDO KUBANGO', 'Kuando Kubango'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CNO', NULL, NULL, 'KWANZA NORTE', 'Kwanza Norte'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CUS', NULL, NULL, 'KWANZA SUL', 'Kwanza Sul'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-CNN', NULL, NULL, 'CUNENE', 'Cunene'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-HUA', NULL, NULL, 'HUAMBO', 'Huambo'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-HUI', NULL, NULL, 'HUÍLA', 'Huila'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LUA', NULL, NULL, 'LUANDA', 'Luanda'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LNO', NULL, NULL, 'LUNDA-NORTE', 'Lunda-Norte'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-LSU',NULL, NULL, 'LUNDA-SUL', 'Lunda-Sul'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-MAL', NULL, NULL, 'MALANGE', 'Malange'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-MOX', NULL, NULL, 'MOXICO', 'Moxico'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-NAM', NULL, NULL, 'NAMÍBE', 'Namíbe'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-UIG', NULL, NULL, 'UÍGE', 'Uíge'); -INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, ncc, nom) VALUES ('35001', 'AO-ZAI', NULL, NULL, 'ZAÍRE', 'Zaíre'); -- Provinces Taiwan (rowid country=886) INSERT INTO llx_c_departements (fk_region, code_departement, cheflieu, tncc, nom) VALUES (21301, 'TW-KLU', 'KLU', NULL, '基隆市'); diff --git a/htdocs/install/mysql/data/llx_accounting_account_be.sql b/htdocs/install/mysql/data/llx_accounting_account_be.sql index b1e3dadff90..e99fa1e54fe 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_be.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_be.sql @@ -655,11 +655,11 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1062, 'PCMN-BASE', 'FINAN', '578', '1060', 'Caisses - timbres ( 0 - fiscaux ; 1 - postaux)', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1063, 'PCMN-BASE', 'FINAN', '58', '1355', 'Virements internes', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1064, 'PCMN-BASE', 'EXPENSE', '60', '1356', 'Approvisionnements et marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1065, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '600', '1064', 'Achats de matières premières', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1066, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '601', '1064', 'Achats de fournitures', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1067, 'PCMN-BASE', 'EXPENSE', 'SERVICE', '602', '1064', 'Achats de services, travaux et études', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1065, 'PCMN-BASE', 'EXPENSE', '600', '1064', 'Achats de matières premières', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1066, 'PCMN-BASE', 'EXPENSE', '601', '1064', 'Achats de fournitures', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1067, 'PCMN-BASE', 'EXPENSE', '602', '1064', 'Achats de services, travaux et études', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1068, 'PCMN-BASE', 'EXPENSE', '603', '1064', 'Sous-traitances générales', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1069, 'PCMN-BASE', 'EXPENSE', 'PRODUCT', '604', '1064', 'Achats de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1069, 'PCMN-BASE', 'EXPENSE', '604', '1064', 'Achats de marchandises', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1070, 'PCMN-BASE', 'EXPENSE', '605', '1064', 'Achats d''immeubles destinés à la revente', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1071, 'PCMN-BASE', 'EXPENSE', '608', '1064', 'Remises , ristournes et rabais obtenus sur achats', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1072, 'PCMN-BASE', 'EXPENSE', '609', '1064', 'Variations de stocks', 1); @@ -849,24 +849,24 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1256, 'PCMN-BASE', 'EXPENSE', '695', '1250', 'Administrateurs ou gérants', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1257, 'PCMN-BASE', 'EXPENSE', '696', '1250', 'Autres allocataires', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1258, 'PCMN-BASE', 'INCOME', '70', '1357', 'Chiffre d''affaires', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1260, 'PCMN-BASE', 'INCOME', 'PRODUCT', '700', '1258', 'Ventes de marchandises', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1261, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7000', '1260', 'Ventes en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1262, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7001', '1260', 'Ventes dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1263, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7002', '1260', 'Ventes à l''exportation', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1264, 'PCMN-BASE', 'INCOME', 'PRODUCT', '701', '1258', 'Ventes de produits finis', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1265, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7010', '1264', 'Ventes en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1266, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7011', '1264', 'Ventes dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1267, 'PCMN-BASE', 'INCOME', 'PRODUCT', '7012', '1264', 'Ventes à l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1260, 'PCMN-BASE', 'INCOME', '700', '1258', 'Ventes de marchandises', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1261, 'PCMN-BASE', 'INCOME', '7000', '1260', 'Ventes en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1262, 'PCMN-BASE', 'INCOME', '7001', '1260', 'Ventes dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1263, 'PCMN-BASE', 'INCOME', '7002', '1260', 'Ventes à l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1264, 'PCMN-BASE', 'INCOME', '701', '1258', 'Ventes de produits finis', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1265, 'PCMN-BASE', 'INCOME', '7010', '1264', 'Ventes en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1266, 'PCMN-BASE', 'INCOME', '7011', '1264', 'Ventes dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1267, 'PCMN-BASE', 'INCOME', '7012', '1264', 'Ventes à l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1268, 'PCMN-BASE', 'INCOME', '702', '1258', 'Ventes de déchets et rebuts', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1269, 'PCMN-BASE', 'INCOME', '7020', '1268', 'Ventes en Belgique', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1270, 'PCMN-BASE', 'INCOME', '7021', '1268', 'Ventes dans les pays membres de la C.E.E.', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1271, 'PCMN-BASE', 'INCOME', '7022', '1268', 'Ventes à l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1272, 'PCMN-BASE', 'INCOME', '703', '1258', 'Ventes d''emballages récupérables', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1273, 'PCMN-BASE', 'INCOME', '704', '1258', 'Facturations des travaux en cours (associations momentanées)', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1274, 'PCMN-BASE', 'INCOME', 'SERVICE', '705', '1258', 'Prestations de services', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1275, 'PCMN-BASE', 'INCOME', 'SERVICE', '7050', '1274', 'Prestations de services en Belgique', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1276, 'PCMN-BASE', 'INCOME', 'SERVICE', '7051', '1274', 'Prestations de services dans les pays membres de la C.E.E.', 1); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1277, 'PCMN-BASE', 'INCOME', 'SERVICE', '7052', '1274', 'Prestations de services en vue de l''exportation', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1274, 'PCMN-BASE', 'INCOME', '705', '1258', 'Prestations de services', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1275, 'PCMN-BASE', 'INCOME', '7050', '1274', 'Prestations de services en Belgique', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1276, 'PCMN-BASE', 'INCOME', '7051', '1274', 'Prestations de services dans les pays membres de la C.E.E.', 1); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1277, 'PCMN-BASE', 'INCOME', '7052', '1274', 'Prestations de services en vue de l''exportation', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1278, 'PCMN-BASE', 'INCOME', '706', '1258', 'Pénalités et dédits obtenus par l''entreprise', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1279, 'PCMN-BASE', 'INCOME', '708', '1258', 'Remises, ristournes et rabais accordés', 1); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1280, 'PCMN-BASE', 'INCOME', '7080', '1279', 'Sur ventes de marchandises', 1); diff --git a/htdocs/install/mysql/data/llx_accounting_account_de.sql b/htdocs/install/mysql/data/llx_accounting_account_de.sql index f6f6ab702fb..41f5b623d7b 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_de.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_de.sql @@ -268,83 +268,83 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1306, 'SKR03', '0', '898', '870', 'Gesellschafter-Darlehen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1307, 'SKR03', '0', '899', '870', 'Gesellschafter-Darlehen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1309, 'SKR03', '0', '900', '0', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1310, 'SKR03', '0', '901', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1311, 'SKR03', '0', '902', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1312, 'SKR03', '0', '903', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1313, 'SKR03', '0', '904', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1314, 'SKR03', '0', '905', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1315, 'SKR03', '0', '906', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1316, 'SKR03', '0', '907', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1317, 'SKR03', '0', '908', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1318, 'SKR03', '0', '909', '900', 'Kommandit-Kapital'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1319, 'SKR03', '0', '910', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1320, 'SKR03', '0', '911', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1321, 'SKR03', '0', '912', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1322, 'SKR03', '0', '913', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1323, 'SKR03', '0', '914', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1324, 'SKR03', '0', '915', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1325, 'SKR03', '0', '916', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1326, 'SKR03', '0', '917', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1327, 'SKR03', '0', '918', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1328, 'SKR03', '0', '919', '900', 'Verlustausgleichskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1329, 'SKR03', '0', '920', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1330, 'SKR03', '0', '921', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1331, 'SKR03', '0', '922', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1332, 'SKR03', '0', '923', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1333, 'SKR03', '0', '924', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1334, 'SKR03', '0', '925', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1335, 'SKR03', '0', '926', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1336, 'SKR03', '0', '927', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1337, 'SKR03', '0', '928', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1338, 'SKR03', '0', '929', '900', 'Gesellschafter-Darlehen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1341, 'SKR03', '0', '930', '900', 'Sonderposten mit Rücklageanteil steuerfreie Rücklagen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1342, 'SKR03', '0', '931', '930', 'Sonderposten mit Rücklageanteil nach § 6b EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1343, 'SKR03', '0', '932', '930', 'Sonderposten mit Rücklageanteil nach Abschnitt 35 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1344, 'SKR03', '0', '933', '930', 'Sonderposten mit Rücklageanteil nach § 6d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1345, 'SKR03', '0', '934', '930', 'Sonderposten mit Rücklageanteil nach § 1 EntwLStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1347, 'SKR03', '0', '935', '900', 'Sonderposten aus der Währungsumstellung auf den Euro'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1348, 'SKR03', '0', '936', '930', 'Sonderposten mit Rücklageanteil nach § 7 d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1349, 'SKR03', '0', '937', '930', 'Sonderposten mit Rücklageanteil nach § 79 EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1350, 'SKR03', '0', '938', '930', 'Sonderposten mit Rücklageanteil nach § 80 EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1351, 'SKR03', '0', '939', '930', 'Sonderposten mit Rücklageanteil nach § 52 Abs.16 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1352, 'SKR03', '0', '940', '930', 'Sonderposten mit Rücklageanteil Sonderabschreibungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1353, 'SKR03', '0', '941', '930', 'Sonderposten mit Rücklageanteil § 82 a EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1354, 'SKR03', '0', '942', '930', 'Sonderposten mit Rücklageanteil § 82 d EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1355, 'SKR03', '0', '943', '930', 'Sonderposten mit Rücklageanteil nach § 82 e EStDV'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1356, 'SKR03', '0', '944', '930', 'Sonderposten mit Rücklageanteil nach § 14 BerlinFG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1357, 'SKR03', '0', '945', '930', 'Sonderposten mit Rücklageanteil für Förderung nach § 3 Zonen-RFG/§ 4-6 FördergebietsG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1358, 'SKR03', '0', '946', '930', 'Sonderposten mit Rücklageanteil nach § 4d EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1359, 'SKR03', '0', '947', '930', 'Sonderposten mit Rücklageanteil nach § 7g Abs.1 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1360, 'SKR03', '0', '948', '930', 'Sonderposten mit Rücklageanteil nach § 7g Abs.3 u.7 EStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1362, 'SKR03', '0', '949', '900', 'Sonderposten für Zuschüsse und Zulagen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1365, 'SKR03', '0', '950', '900', 'Rückstellungen für Pensionen und ähnliche Verpflichtungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1367, 'SKR03', '0', '955', '900', 'Steuerrückstellungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1368, 'SKR03', '0', '957', '955', 'Gewerbesteuerrückstellung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1369, 'SKR03', '0', '963', '955', 'Körperschaftsteuerrückstellung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1371, 'SKR03', '0', '965', '900', 'Rückstellungen für Personalkosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1372, 'SKR03', '0', '966', '900', 'Rückstellungen zur Erfüllung der Aufbewahrungspflichten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1373, 'SKR03', '0', '969', '900', 'Rückstellung für latente Steuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1374, 'SKR03', '0', '970', '900', 'Sonstige Rückstellungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1375, 'SKR03', '0', '971', '900', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung in den ersten drei Monaten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1376, 'SKR03', '0', '972', '900', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung innerhalb des 4. bis 12. Monats'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1377, 'SKR03', '0', '973', '900', 'Rückstellungen für Abraum- und Abfallbeseitigung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1378, 'SKR03', '0', '974', '900', 'Rückstellungen für Gewährleistungen ( Gegenkonto 4790 )'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1379, 'SKR03', '0', '976', '900', 'Rückstellungen für drohende Verluste aus schwebenden Geschäften'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1380, 'SKR03', '0', '977', '900', 'Rückstellungen für Abschluss- und Prüfungskosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1381, 'SKR03', '0', '978', '900', 'Aufwandsrückstellungen gemäß § 249 Abs. 2 HGB'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1382, 'SKR03', '0', '979', '900', 'Rückstellungen für Umweltschutz'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1385, 'SKR03', '0', '980', '900', 'Aktive Rechnungsabgrenzung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1387, 'SKR03', '0', '983', '980', 'Abgrenzung aktive latente Steuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1388, 'SKR03', '0', '984', '900', 'Als Aufwand berücksichtigte Zölle und Verbrauchsteuern'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1389, 'SKR03', '0', '985', '900', 'Als Aufwand berücksichtigte Umsatzsteuer auf Anzahlungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1390, 'SKR03', '0', '986', '900', 'Damnum / Disagio'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1393, 'SKR03', '0', '990', '900', 'Passive Rechnungsabgrenzung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1395, 'SKR03', '0', '992', '990', 'Abgenzungsposten zur unterjährigen Kostenverrechnung für BWA'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1396, 'SKR03', '0', '993', '990', 'Forderungen aus Lieferungen und Leistungen H-Saldo'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1397, 'SKR03', '0', '996', '990', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1398, 'SKR03', '0', '997', '990', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1399, 'SKR03', '0', '998', '990', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1400, 'SKR03', '0', '999', '990', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1310, 'SKR03', '0', '901', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1311, 'SKR03', '0', '902', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1312, 'SKR03', '0', '903', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1313, 'SKR03', '0', '904', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1314, 'SKR03', '0', '905', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1315, 'SKR03', '0', '906', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1316, 'SKR03', '0', '907', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1317, 'SKR03', '0', '908', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1318, 'SKR03', '0', '909', '1309', 'Kommandit-Kapital'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1319, 'SKR03', '0', '910', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1320, 'SKR03', '0', '911', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1321, 'SKR03', '0', '912', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1322, 'SKR03', '0', '913', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1323, 'SKR03', '0', '914', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1324, 'SKR03', '0', '915', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1325, 'SKR03', '0', '916', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1326, 'SKR03', '0', '917', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1327, 'SKR03', '0', '918', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1328, 'SKR03', '0', '919', '1309', 'Verlustausgleichskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1329, 'SKR03', '0', '920', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1330, 'SKR03', '0', '921', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1331, 'SKR03', '0', '922', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1332, 'SKR03', '0', '923', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1333, 'SKR03', '0', '924', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1334, 'SKR03', '0', '925', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1335, 'SKR03', '0', '926', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1336, 'SKR03', '0', '927', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1337, 'SKR03', '0', '928', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1338, 'SKR03', '0', '929', '1309', 'Gesellschafter-Darlehen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1341, 'SKR03', '0', '930', '1309', 'Sonderposten mit Rücklageanteil steuerfreie Rücklagen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1342, 'SKR03', '0', '931', '1341', 'Sonderposten mit Rücklageanteil nach § 6b EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1343, 'SKR03', '0', '932', '1341', 'Sonderposten mit Rücklageanteil nach Abschnitt 35 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1344, 'SKR03', '0', '933', '1341', 'Sonderposten mit Rücklageanteil nach § 6d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1345, 'SKR03', '0', '934', '1341', 'Sonderposten mit Rücklageanteil nach § 1 EntwLStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1347, 'SKR03', '0', '935', '1309', 'Sonderposten aus der Währungsumstellung auf den Euro'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1348, 'SKR03', '0', '936', '1341', 'Sonderposten mit Rücklageanteil nach § 7 d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1349, 'SKR03', '0', '937', '1341', 'Sonderposten mit Rücklageanteil nach § 79 EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1350, 'SKR03', '0', '938', '1341', 'Sonderposten mit Rücklageanteil nach § 80 EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1351, 'SKR03', '0', '939', '1341', 'Sonderposten mit Rücklageanteil nach § 52 Abs.16 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1352, 'SKR03', '0', '940', '1341', 'Sonderposten mit Rücklageanteil Sonderabschreibungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1353, 'SKR03', '0', '941', '1341', 'Sonderposten mit Rücklageanteil § 82 a EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1354, 'SKR03', '0', '942', '1341', 'Sonderposten mit Rücklageanteil § 82 d EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1355, 'SKR03', '0', '943', '1341', 'Sonderposten mit Rücklageanteil nach § 82 e EStDV'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1356, 'SKR03', '0', '944', '1341', 'Sonderposten mit Rücklageanteil nach § 14 BerlinFG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1357, 'SKR03', '0', '945', '1341', 'Sonderposten mit Rücklageanteil für Förderung nach § 3 Zonen-RFG/§ 4-6 FördergebietsG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1358, 'SKR03', '0', '946', '1341', 'Sonderposten mit Rücklageanteil nach § 4d EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1359, 'SKR03', '0', '947', '1341', 'Sonderposten mit Rücklageanteil nach § 7g Abs.1 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1360, 'SKR03', '0', '948', '1341', 'Sonderposten mit Rücklageanteil nach § 7g Abs.3 u.7 EStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1362, 'SKR03', '0', '949', '1309', 'Sonderposten für Zuschüsse und Zulagen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1365, 'SKR03', '0', '950', '1309', 'Rückstellungen für Pensionen und ähnliche Verpflichtungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1367, 'SKR03', '0', '955', '1309', 'Steuerrückstellungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1368, 'SKR03', '0', '957', '1367', 'Gewerbesteuerrückstellung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1369, 'SKR03', '0', '963', '1367', 'Körperschaftsteuerrückstellung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1371, 'SKR03', '0', '965', '1309', 'Rückstellungen für Personalkosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1372, 'SKR03', '0', '966', '1309', 'Rückstellungen zur Erfüllung der Aufbewahrungspflichten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1373, 'SKR03', '0', '969', '1309', 'Rückstellung für latente Steuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1374, 'SKR03', '0', '970', '1309', 'Sonstige Rückstellungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1375, 'SKR03', '0', '971', '1309', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung in den ersten drei Monaten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1376, 'SKR03', '0', '972', '1309', 'Rückstellungen für unterlassene Aufwendungen für Instandhaltung Nachholung innerhalb des 4. bis 12. Monats'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1377, 'SKR03', '0', '973', '1309', 'Rückstellungen für Abraum- und Abfallbeseitigung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1378, 'SKR03', '0', '974', '1309', 'Rückstellungen für Gewährleistungen ( Gegenkonto 4790 )'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1379, 'SKR03', '0', '976', '1309', 'Rückstellungen für drohende Verluste aus schwebenden Geschäften'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1380, 'SKR03', '0', '977', '1309', 'Rückstellungen für Abschluss- und Prüfungskosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1381, 'SKR03', '0', '978', '1309', 'Aufwandsrückstellungen gemäß § 249 Abs. 2 HGB'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1382, 'SKR03', '0', '979', '1309', 'Rückstellungen für Umweltschutz'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1385, 'SKR03', '0', '980', '1309', 'Aktive Rechnungsabgrenzung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1387, 'SKR03', '0', '983', '1385', 'Abgrenzung aktive latente Steuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1388, 'SKR03', '0', '984', '1309', 'Als Aufwand berücksichtigte Zölle und Verbrauchsteuern'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1389, 'SKR03', '0', '985', '1309', 'Als Aufwand berücksichtigte Umsatzsteuer auf Anzahlungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1390, 'SKR03', '0', '986', '1309', 'Damnum / Disagio'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1393, 'SKR03', '0', '990', '1309', 'Passive Rechnungsabgrenzung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1395, 'SKR03', '0', '992', '1393', 'Abgenzungsposten zur unterjährigen Kostenverrechnung für BWA'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1396, 'SKR03', '0', '993', '1393', 'Forderungen aus Lieferungen und Leistungen H-Saldo'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1397, 'SKR03', '0', '996', '1393', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1398, 'SKR03', '0', '997', '1393', 'Pauschalwertberichtigung auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1399, 'SKR03', '0', '998', '1393', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit bis zu 1 Jahr'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1400, 'SKR03', '0', '999', '1393', 'Einzelwertberichtigungen auf Forderungen mit einer Restlaufzeit von mehr als 1 Jahr'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1403, 'SKR03', '1', '1000', '0', 'Kasse'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1404, 'SKR03', '1', '1010', '1403', 'Nebenkasse 1'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1405, 'SKR03', '1', '1020', '1403', 'Nebenkasse 2'); @@ -884,7 +884,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1966, 'SKR03', '2', '2010', '0', 'Betriebsfremde Aufwendungen (soweit nicht außerordentlich)'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1967, 'SKR03', '2', '2020', '0', 'Periodenfremde Aufwendungen (soweit nicht außerordentlich)'); -); + INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1970, 'SKR03', '2', '2100', '0', 'Zinsen und ähnliche Aufwendungen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1971, 'SKR03', '2', '2103', '0', 'Steuerlich abzugsfähige andere Nebenleistungen zu steuern'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 1972, 'SKR03', '2', '2104', '0', 'Steuerlich nicht abzugsfähige andere Nebenleistungen zu Steuern'); @@ -1051,7 +1051,7 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2138, 'SKR03', '2', '2680', '0', 'Zinsähnliche Erträge'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2139, 'SKR03', '2', '2689', '0', 'Zinsähnliche Erträge aus verbundenen Unternehmen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2142, 'SKR03', '2', '2700', '0',, 'Sonstige Erträge'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2142, 'SKR03', '2', '2700', '0', 'Sonstige Erträge'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2143, 'SKR03', '2', '2705', '0', 'Sonstige Erträge betrieblich und regelmäßig'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2144, 'SKR03', '2', '2707', '0', 'Sonstige Erträge betriebsfremd und regelmäßig'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2145, 'SKR03', '2', '2709', '0', 'Sonstige Erträge unregelmäßig'); @@ -1145,133 +1145,133 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2240, 'SKR03', '3', '3200', '0', 'Wareneingang'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2241, 'SKR03', '3', '3300', '2240', 'Wareneingang 7% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2242, 'SKR03', '3', '3301', '2240', 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2243, 'SKR03', '3', '3302', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2244, 'SKR03', '3', '3303', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2245, 'SKR03', '3', '3304', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2246, 'SKR03', '3', '3305', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2247, 'SKR03', '3', '3306', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2248, 'SKR03', '3', '3307', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2249, 'SKR03', '3', '3308', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2250, 'SKR03', '3', '3309', '2240' 'Wareneingang 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2251, 'SKR03', '3', '3340', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2252, 'SKR03', '3', '3341', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2253, 'SKR03', '3', '3342', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2254, 'SKR03', '3', '3343', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2255, 'SKR03', '3', '3344', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2256, 'SKR03', '3', '3345', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2257, 'SKR03', '3', '3346', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2258, 'SKR03', '3', '3347', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2259, 'SKR03', '3', '3348', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2260, 'SKR03', '3', '3349', '2240' 'Wareneingang 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2261, 'SKR03', '3', '3400', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2262, 'SKR03', '3', '3401', '2240' 'Produkt Ausgaben'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2263, 'SKR03', '3', '3402', '2240' 'Produkt Vertriebsausgaben'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2264, 'SKR03', '3', '3403', '2240' 'Konto Kasse Aufwand'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2265, 'SKR03', '3', '3404', '2240' 'Einstandskosten Verrechnungskonto'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2266, 'SKR03', '3', '3405', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2267, 'SKR03', '3', '3406', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2268, 'SKR03', '3', '3407', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2269, 'SKR03', '3', '3408', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2270, 'SKR03', '3', '3409', '2240' 'Wareneingang 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2271, 'SKR03', '3', '3420', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2272, 'SKR03', '3', '3421', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2273, 'SKR03', '3', '3422', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2274, 'SKR03', '3', '3423', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2275, 'SKR03', '3', '3424', '2240' 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2276, 'SKR03', '3', '3425', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2277, 'SKR03', '3', '3426', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2278, 'SKR03', '3', '3427', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2279, 'SKR03', '3', '3428', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2280, 'SKR03', '3', '3429', '2240' 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2281, 'SKR03', '3', '3430', '2240' 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2282, 'SKR03', '3', '3433', '2240' 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2283, 'SKR03', '3', '3434', '2240' 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2284, 'SKR03', '3', '3435', '2240' 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2285, 'SKR03', '3', '3440', '2240' 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2286, 'SKR03', '3', '3441', '2240' 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2287, 'SKR03', '3', '3500', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2288, 'SKR03', '3', '3501', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2289, 'SKR03', '3', '3502', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2290, 'SKR03', '3', '3503', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2291, 'SKR03', '3', '3504', '2240' 'Wareneingang 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2292, 'SKR03', '3', '3505', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2293, 'SKR03', '3', '3506', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2294, 'SKR03', '3', '3507', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2295, 'SKR03', '3', '3508', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2296, 'SKR03', '3', '3509', '2240' 'Wareneingang 5 5% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2297, 'SKR03', '3', '3530', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2298, 'SKR03', '3', '3531', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2299, 'SKR03', '3', '3532', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2300, 'SKR03', '3', '3533', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2301, 'SKR03', '3', '3534', '2240' 'Wareneingang 9% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2302, 'SKR03', '3', '3540', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2303, 'SKR03', '3', '3541', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2304, 'SKR03', '3', '3542', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2305, 'SKR03', '3', '3543', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2306, 'SKR03', '3', '3544', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2307, 'SKR03', '3', '3545', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2308, 'SKR03', '3', '3546', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2309, 'SKR03', '3', '3547', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2310, 'SKR03', '3', '3548', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2311, 'SKR03', '3', '3549', '2240' 'Wareneingang 10 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2312, 'SKR03', '3', '3550', '2240' 'steuerfreier innergemeinschaftlicher Erwerb'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2313, 'SKR03', '3', '3551', '2240' 'Wareneingang im Drittland steuerbar'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2314, 'SKR03', '3', '3559', '2240' 'Steuerfreier Einfuhren'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2315, 'SKR03', '3', '3558', '2240' 'Wareneingang I.a. EG-Land steuerbar'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2316, 'SKR03', '3', '3560', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2317, 'SKR03', '3', '3565', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2318, 'SKR03', '3', '3566', '2240' 'waren aus einem Umsatzsteuerlager § 13a UStG 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2319, 'SKR03', '3', '3600', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2320, 'SKR03', '3', '3601', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2321, 'SKR03', '3', '3602', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2322, 'SKR03', '3', '3603', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2323, 'SKR03', '3', '3604', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2324, 'SKR03', '3', '3605', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2325, 'SKR03', '3', '3606', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2326, 'SKR03', '3', '3607', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2327, 'SKR03', '3', '3608', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2328, 'SKR03', '3', '3609', '2240' 'Nicht abziehbare Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2329, 'SKR03', '3', '3610', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2330, 'SKR03', '3', '3611', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2331, 'SKR03', '3', '3612', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2332, 'SKR03', '3', '3613', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2333, 'SKR03', '3', '3614', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2334, 'SKR03', '3', '3615', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2335, 'SKR03', '3', '3616', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2336, 'SKR03', '3', '3617', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2337, 'SKR03', '3', '3618', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2338, 'SKR03', '3', '3619', '2240' 'Nicht abziehbare Vorsteuer 7%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2339, 'SKR03', '3', '3650', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2340, 'SKR03', '3', '3651', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2341, 'SKR03', '3', '3652', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2342, 'SKR03', '3', '3653', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2343, 'SKR03', '3', '3654', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2344, 'SKR03', '3', '3655', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2345, 'SKR03', '3', '3656', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2346, 'SKR03', '3', '3657', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2347, 'SKR03', '3', '3658', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2348, 'SKR03', '3', '3659', '2240' 'Nicht abziehbare Vorsteuer 16%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2349, 'SKR03', '3', '3660', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2350, 'SKR03', '3', '3661', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2351, 'SKR03', '3', '3662', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2352, 'SKR03', '3', '3663', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2353, 'SKR03', '3', '3664', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2354, 'SKR03', '3', '3665', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2355, 'SKR03', '3', '3666', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2356, 'SKR03', '3', '3667', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2357, 'SKR03', '3', '3668', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2358, 'SKR03', '3', '3669', '2240' 'Nicht abziehbare Vorsteuer 19%'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2359, 'SKR03', '3', '3700', '2240' 'Nachlässe'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2360, 'SKR03', '3', '3710', '2240' 'Nachlässe 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2361, 'SKR03', '3', '3711', '2240' 'Nachlässe 7% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2362, 'SKR03', '3', '3720', '2240' 'Nachlässe 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2363, 'SKR03', '3', '3721', '2240' 'Nachlässe 19% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2364, 'SKR03', '3', '3722', '2240' 'Nachlässe 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2365, 'SKR03', '3', '3723', '2240' 'Nachlässe 15% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2366, 'SKR03', '3', '3724', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2367, 'SKR03', '3', '3725', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2368, 'SKR03', '3', '3726', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2369, 'SKR03', '3', '3727', '2240' 'Nachlässe aus innergemeinschaftlichem Erwerb 15% Vorsteuer und 15% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2243, 'SKR03', '3', '3302', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2244, 'SKR03', '3', '3303', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2245, 'SKR03', '3', '3304', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2246, 'SKR03', '3', '3305', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2247, 'SKR03', '3', '3306', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2248, 'SKR03', '3', '3307', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2249, 'SKR03', '3', '3308', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2250, 'SKR03', '3', '3309', '2240', 'Wareneingang 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2251, 'SKR03', '3', '3340', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2252, 'SKR03', '3', '3341', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2253, 'SKR03', '3', '3342', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2254, 'SKR03', '3', '3343', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2255, 'SKR03', '3', '3344', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2256, 'SKR03', '3', '3345', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2257, 'SKR03', '3', '3346', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2258, 'SKR03', '3', '3347', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2259, 'SKR03', '3', '3348', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2260, 'SKR03', '3', '3349', '2240', 'Wareneingang 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2261, 'SKR03', '3', '3400', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2262, 'SKR03', '3', '3401', '2240', 'Produkt Ausgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2263, 'SKR03', '3', '3402', '2240', 'Produkt Vertriebsausgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2264, 'SKR03', '3', '3403', '2240', 'Konto Kasse Aufwand'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2265, 'SKR03', '3', '3404', '2240', 'Einstandskosten Verrechnungskonto'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2266, 'SKR03', '3', '3405', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2267, 'SKR03', '3', '3406', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2268, 'SKR03', '3', '3407', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2269, 'SKR03', '3', '3408', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2270, 'SKR03', '3', '3409', '2240', 'Wareneingang 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2271, 'SKR03', '3', '3420', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2272, 'SKR03', '3', '3421', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2273, 'SKR03', '3', '3422', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2274, 'SKR03', '3', '3423', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2275, 'SKR03', '3', '3424', '2240', 'Innergemeinschaftlicher Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2276, 'SKR03', '3', '3425', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2277, 'SKR03', '3', '3426', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2278, 'SKR03', '3', '3427', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2279, 'SKR03', '3', '3428', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2280, 'SKR03', '3', '3429', '2240', 'Innergemeinschaftlicher Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2281, 'SKR03', '3', '3430', '2240', 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2282, 'SKR03', '3', '3433', '2240', 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2283, 'SKR03', '3', '3434', '2240', 'Innergemeinschaftlicher Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2284, 'SKR03', '3', '3435', '2240', 'Innergemeinschaftlicher Erwerb ohne Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2285, 'SKR03', '3', '3440', '2240', 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2286, 'SKR03', '3', '3441', '2240', 'Innergemeinschaftlicher Erwerb von Neufahrzeugen von Lieferanten ohne Umsatzsteuer-Identifikationsnummer 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2287, 'SKR03', '3', '3500', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2288, 'SKR03', '3', '3501', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2289, 'SKR03', '3', '3502', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2290, 'SKR03', '3', '3503', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2291, 'SKR03', '3', '3504', '2240', 'Wareneingang 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2292, 'SKR03', '3', '3505', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2293, 'SKR03', '3', '3506', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2294, 'SKR03', '3', '3507', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2295, 'SKR03', '3', '3508', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2296, 'SKR03', '3', '3509', '2240', 'Wareneingang 5 5% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2297, 'SKR03', '3', '3530', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2298, 'SKR03', '3', '3531', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2299, 'SKR03', '3', '3532', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2300, 'SKR03', '3', '3533', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2301, 'SKR03', '3', '3534', '2240', 'Wareneingang 9% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2302, 'SKR03', '3', '3540', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2303, 'SKR03', '3', '3541', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2304, 'SKR03', '3', '3542', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2305, 'SKR03', '3', '3543', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2306, 'SKR03', '3', '3544', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2307, 'SKR03', '3', '3545', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2308, 'SKR03', '3', '3546', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2309, 'SKR03', '3', '3547', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2310, 'SKR03', '3', '3548', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2311, 'SKR03', '3', '3549', '2240', 'Wareneingang 10 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2312, 'SKR03', '3', '3550', '2240', 'steuerfreier innergemeinschaftlicher Erwerb'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2313, 'SKR03', '3', '3551', '2240', 'Wareneingang im Drittland steuerbar'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2314, 'SKR03', '3', '3559', '2240', 'Steuerfreier Einfuhren'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2315, 'SKR03', '3', '3558', '2240', 'Wareneingang I.a. EG-Land steuerbar'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2316, 'SKR03', '3', '3560', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2317, 'SKR03', '3', '3565', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2318, 'SKR03', '3', '3566', '2240', 'waren aus einem Umsatzsteuerlager § 13a UStG 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2319, 'SKR03', '3', '3600', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2320, 'SKR03', '3', '3601', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2321, 'SKR03', '3', '3602', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2322, 'SKR03', '3', '3603', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2323, 'SKR03', '3', '3604', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2324, 'SKR03', '3', '3605', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2325, 'SKR03', '3', '3606', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2326, 'SKR03', '3', '3607', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2327, 'SKR03', '3', '3608', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2328, 'SKR03', '3', '3609', '2240', 'Nicht abziehbare Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2329, 'SKR03', '3', '3610', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2330, 'SKR03', '3', '3611', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2331, 'SKR03', '3', '3612', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2332, 'SKR03', '3', '3613', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2333, 'SKR03', '3', '3614', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2334, 'SKR03', '3', '3615', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2335, 'SKR03', '3', '3616', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2336, 'SKR03', '3', '3617', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2337, 'SKR03', '3', '3618', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2338, 'SKR03', '3', '3619', '2240', 'Nicht abziehbare Vorsteuer 7%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2339, 'SKR03', '3', '3650', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2340, 'SKR03', '3', '3651', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2341, 'SKR03', '3', '3652', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2342, 'SKR03', '3', '3653', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2343, 'SKR03', '3', '3654', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2344, 'SKR03', '3', '3655', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2345, 'SKR03', '3', '3656', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2346, 'SKR03', '3', '3657', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2347, 'SKR03', '3', '3658', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2348, 'SKR03', '3', '3659', '2240', 'Nicht abziehbare Vorsteuer 16%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2349, 'SKR03', '3', '3660', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2350, 'SKR03', '3', '3661', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2351, 'SKR03', '3', '3662', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2352, 'SKR03', '3', '3663', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2353, 'SKR03', '3', '3664', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2354, 'SKR03', '3', '3665', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2355, 'SKR03', '3', '3666', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2356, 'SKR03', '3', '3667', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2357, 'SKR03', '3', '3668', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2358, 'SKR03', '3', '3669', '2240', 'Nicht abziehbare Vorsteuer 19%'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2359, 'SKR03', '3', '3700', '2240', 'Nachlässe'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2360, 'SKR03', '3', '3710', '2240', 'Nachlässe 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2361, 'SKR03', '3', '3711', '2240', 'Nachlässe 7% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2362, 'SKR03', '3', '3720', '2240', 'Nachlässe 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2363, 'SKR03', '3', '3721', '2240', 'Nachlässe 19% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2364, 'SKR03', '3', '3722', '2240', 'Nachlässe 16% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2365, 'SKR03', '3', '3723', '2240', 'Nachlässe 15% Vorsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2366, 'SKR03', '3', '3724', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 7% Vorsteuer und 7% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2367, 'SKR03', '3', '3725', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 19% Vorsteuer und 19% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2368, 'SKR03', '3', '3726', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 16% Vorsteuer und 16% Umsatzsteuer'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2369, 'SKR03', '3', '3727', '2240', 'Nachlässe aus innergemeinschaftlichem Erwerb 15% Vorsteuer und 15% Umsatzsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2372, 'SKR03', '3', '3730', '0', 'Erhaltene Skonti'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2373, 'SKR03', '3', '3731', '0', 'Erhaltene Skonti 7% Vorsteuer'); @@ -1295,9 +1295,9 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2391, 'SKR03', '3', '3791', '0', 'Erhaltene Rabatte 19% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2392, 'SKR03', '3', '3794', '0', 'Erhaltene Rabatte 16% Vorsteuer'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2393, 'SKR03', '3', '3795', '0', 'Erhaltene Rabatte 16% Vorsteuer'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2394, 'SKR03', '3', '3800', '0' 'Bezugsnebenkosten'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2395, 'SKR03', '3', '3830', '0' 'Leergut'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2396, 'SKR03', '3', '3850', '0' 'Zölle und Einfuhrabgaben'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2394, 'SKR03', '3', '3800', '0', 'Bezugsnebenkosten'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2395, 'SKR03', '3', '3830', '0', 'Leergut'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2396, 'SKR03', '3', '3850', '0', 'Zölle und Einfuhrabgaben'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2399, 'SKR03', '3', '3960', '0', 'Bestandsveränderungen Roh- Hilfs- und Betriebsstoffe sowie bezogene Waren'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 2400, 'SKR03', '3', '3961', '0', 'Bestandsveränderungen Roh- Hilfs- und Betriebsstoffe sowie bezogene Waren'); @@ -1965,42 +1965,42 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3071, 'SKR03', '8', '8700', '0', 'Erlösschmälerungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3072, 'SKR03', '8', '8701', '8700', 'Nicht abgerechnete Einnahmen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3073, 'SKR03', '8', '8705', '8700', 'Erlösschmälerungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3074, 'SKR03', '8', '8705', '8700', 'Erlösschmälerungen aus steuerfreien Umsätzen §4 Nr. 1a UStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3075, 'SKR03', '8', '8710', '8700', 'Erlösschmälerungen 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3076, 'SKR03', '8', '8720', '8700', 'Erlösschmälerungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3077, 'SKR03', '8', '8721', '8700', 'Erlösschmälerungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3078, 'SKR03', '8', '8723', '8700', 'Erlösschmälerungen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3079, 'SKR03', '8', '8724', '8700', 'Erlösschmälerungen aus steuerfreien innergemeinschaftlichen Lieferung'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3080, 'SKR03', '8', '8725', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 7 % USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3081, 'SKR03', '8', '8726', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 19 % USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3082, 'SKR03', '8', '8727', '8700', 'Erlösschmälerungen aus im anderen EG-Land steuerpflichtigen Lieferungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3083, 'SKR03', '8', '8729', '8700', 'Erlösschmälerungen aus im Inland steuerpflichtigen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3084, 'SKR03', '8', '8730', '8700', 'Gewährte Skonti'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3085, 'SKR03', '8', '8731', '8700', 'Gewährte Skonti 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3086, 'SKR03', '8', '8735', '8700', 'Gewährte Skonti 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3087, 'SKR03', '8', '8736', '8700', 'Gewährte Skonti 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3088, 'SKR03', '8', '8741', '8700', 'Gewährte Skonti aus Lieferungen für die der Leistungsempfänger die Umsatzsteuer nach § 13b UStG schuldet'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3089, 'SKR03', '8', '8743', '8700', 'Gewährte Skonti aus steuerfreien innergemeinschaftlichen Lieferungen § 4 Nr. 1b UStG'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3090, 'SKR03', '8', '8745', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3091, 'SKR03', '8', '8746', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3092, 'SKR03', '8', '8748', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3093, 'SKR03', '8', '8749', '8700', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3094, 'SKR03', '8', '8750', '8700', 'Gewährte Boni 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3095, 'SKR03', '8', '8751', '8700', 'Gewährte Boni 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3096, 'SKR03', '8', '8760', '8700', 'Gewährte Boni 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3097, 'SKR03', '8', '8761', '8700', 'Gewährte Boni 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3098, 'SKR03', '8', '8764', '8700', 'Gewährte Boni 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3099, 'SKR03', '8', '8765', '8700', 'Gewährte Boni 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3100, 'SKR03', '8', '8769', '8700', 'Gewährte Boni'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3101, 'SKR03', '8', '8770', '8700', 'Gewährte Rabatte'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3102, 'SKR03', '8', '8780', '8700', 'Gewährte Rabatte 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3103, 'SKR03', '8', '8781', '8700', 'Gewährte Rabatte 7% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3104, 'SKR03', '8', '8790', '8700', 'Gewährte Rabatte 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3105, 'SKR03', '8', '8791', '8700', 'Gewährte Rabatte 19% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3106, 'SKR03', '8', '8794', '8700', 'Gewährte Rabatte 16% USt'); -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3107, 'SKR03', '8', '8795', '8700', 'Gewährte Rabatte 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3072, 'SKR03', '8', '8701', '3071', 'Nicht abgerechnete Einnahmen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3073, 'SKR03', '8', '8705', '3071', 'Erlösschmälerungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3074, 'SKR03', '8', '8705', '3071', 'Erlösschmälerungen aus steuerfreien Umsätzen §4 Nr. 1a UStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3075, 'SKR03', '8', '8710', '3071', 'Erlösschmälerungen 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3076, 'SKR03', '8', '8720', '3071', 'Erlösschmälerungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3077, 'SKR03', '8', '8721', '3071', 'Erlösschmälerungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3078, 'SKR03', '8', '8723', '3071', 'Erlösschmälerungen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3079, 'SKR03', '8', '8724', '3071', 'Erlösschmälerungen aus steuerfreien innergemeinschaftlichen Lieferung'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3080, 'SKR03', '8', '8725', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 7 % USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3081, 'SKR03', '8', '8726', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen EG-Lieferungen 19 % USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3082, 'SKR03', '8', '8727', '3071', 'Erlösschmälerungen aus im anderen EG-Land steuerpflichtigen Lieferungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3083, 'SKR03', '8', '8729', '3071', 'Erlösschmälerungen aus im Inland steuerpflichtigen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3084, 'SKR03', '8', '8730', '3071', 'Gewährte Skonti'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3085, 'SKR03', '8', '8731', '3071', 'Gewährte Skonti 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3086, 'SKR03', '8', '8735', '3071', 'Gewährte Skonti 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3087, 'SKR03', '8', '8736', '3071', 'Gewährte Skonti 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3088, 'SKR03', '8', '8741', '3071', 'Gewährte Skonti aus Lieferungen für die der Leistungsempfänger die Umsatzsteuer nach § 13b UStG schuldet'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3089, 'SKR03', '8', '8743', '3071', 'Gewährte Skonti aus steuerfreien innergemeinschaftlichen Lieferungen § 4 Nr. 1b UStG'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3090, 'SKR03', '8', '8745', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3091, 'SKR03', '8', '8746', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3092, 'SKR03', '8', '8748', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3093, 'SKR03', '8', '8749', '3071', 'Gewährte Skonti aus im Inland steuerpflichtigen EG-Lieferungen 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3094, 'SKR03', '8', '8750', '3071', 'Gewährte Boni 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3095, 'SKR03', '8', '8751', '3071', 'Gewährte Boni 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3096, 'SKR03', '8', '8760', '3071', 'Gewährte Boni 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3097, 'SKR03', '8', '8761', '3071', 'Gewährte Boni 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3098, 'SKR03', '8', '8764', '3071', 'Gewährte Boni 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3099, 'SKR03', '8', '8765', '3071', 'Gewährte Boni 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3100, 'SKR03', '8', '8769', '3071', 'Gewährte Boni'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3101, 'SKR03', '8', '8770', '3071', 'Gewährte Rabatte'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3102, 'SKR03', '8', '8780', '3071', 'Gewährte Rabatte 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3103, 'SKR03', '8', '8781', '3071', 'Gewährte Rabatte 7% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3104, 'SKR03', '8', '8790', '3071', 'Gewährte Rabatte 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3105, 'SKR03', '8', '8791', '3071', 'Gewährte Rabatte 19% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3106, 'SKR03', '8', '8794', '3071', 'Gewährte Rabatte 16% USt'); +INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3107, 'SKR03', '8', '8795', '3071', 'Gewährte Rabatte 16% USt'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3109, 'SKR03', '8', '8800', '0', 'Erlöse aus Verkäufen Sachanlagevermögen (Bei Buchverlust)'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3110, 'SKR03', '8', '8801', '3109', 'Erlöse aus Verkäufen Sachanlagevermögen 19% USt (Bei Buchverlust)'); @@ -2707,7 +2707,6 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc -- SKR04 -- Some lines of SKR04 has been disabled because the fiel account_parent is wrong, it must be the rowid of parent line and not the account_number of parent line -INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3837, 'SKR04', 'Anlagevermögen', 0, 0, 'Anlagevermögen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3838, 'SKR04', 'Anlagevermögen', 100, 0, 'Entgeltlich erworbene Konzessionen, gewerbliche Schutzrechte und ähnliche Rechte und Werte sowie Lizenzen an solchen Rechten und Werten'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3839, 'SKR04', 'Anlagevermögen', 110, 3838, 'Konzessionen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3840, 'SKR04', 'Anlagevermögen', 120, 3838, 'Gewerbliche Schutzrechte'); @@ -2715,66 +2714,66 @@ INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, acc INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3842, 'SKR04', 'Anlagevermögen', 135, 3838, 'EDV-Software'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3843, 'SKR04', 'Anlagevermögen', 140, 3838, 'Lizenzen an gewerblichen Schutzrechten und ähnlichen Rechten und Werte'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3844, 'SKR04', 'Anlagevermögen', 143, 0, 'Selbst geschaffene immaterielle Vermögensgegenstände'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3845, 'SKR04', 'Anlagevermögen', 144, 143, 'EDV-Software'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3846, 'SKR04', 'Anlagevermögen', 145, 143, 'Lizenzen und Franchiseverträge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3847, 'SKR04', 'Anlagevermögen', 146, 143, 'Konzessionen und gewerbliche Schutzrechte'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3848, 'SKR04', 'Anlagevermögen', 147, 143, 'Rezepte, Verfahren, Prototypen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3849, 'SKR04', 'Anlagevermögen', 148, 143, 'Immaterielle Vermögensgegenstände in Entwicklung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3845, 'SKR04', 'Anlagevermögen', 144, 3844, 'EDV-Software'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3846, 'SKR04', 'Anlagevermögen', 145, 3844, 'Lizenzen und Franchiseverträge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3847, 'SKR04', 'Anlagevermögen', 146, 3844, 'Konzessionen und gewerbliche Schutzrechte'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3848, 'SKR04', 'Anlagevermögen', 147, 3844, 'Rezepte, Verfahren, Prototypen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3849, 'SKR04', 'Anlagevermögen', 148, 3844, 'Immaterielle Vermögensgegenstände in Entwicklung'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3850, 'SKR04', 'Anlagevermögen', 150, 0, 'Geschäfts- oder Firmenwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3851, 'SKR04', 'Anlagevermögen', 160, 0, 'Verschmelzungsmehrwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3852, 'SKR04', 'Anlagevermögen', 170, 0, 'Geleistete Anzahlungen auf immaterielle Vermögensgegenstände'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3853, 'SKR04', 'Anlagevermögen', 179, 0, 'Anzahlungen auf Geschäfts- oder Firmenwert'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3854, 'SKR04', 'Anlagevermögen', 200, 0, 'Grundstücke, grundstücksgleiche Rechte und Bauten einschließlich der Bauten auf fremden Grundstück'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3855, 'SKR04', 'Anlagevermögen', 210, 200, 'Grundstücksgleiche Rechte ohne Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3856, 'SKR04', 'Anlagevermögen', 215, 200, 'Unbebaute Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3857, 'SKR04', 'Anlagevermögen', 220, 200, 'Grundstücksgleiche Rechte (Erbbaurecht, Dauerwohnrecht, unbebaute Grundstücke)'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3858, 'SKR04', 'Anlagevermögen', 225, 200, 'Grundstücke mit Substanzverkehr'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3859, 'SKR04', 'Anlagevermögen', 229, 200, 'Grundstücksanteil des häuslichen Arbeitszimmers'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3860, 'SKR04', 'Anlagevermögen', 230, 200, 'Bauten auf eigenen Grundstücken und grundstücksgleichen Rechten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3861, 'SKR04', 'Anlagevermögen', 235, 200, 'Grundstückswerte eigener bebauter Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3862, 'SKR04', 'Anlagevermögen', 240, 200, 'Geschäftsbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3863, 'SKR04', 'Anlagevermögen', 250, 200, 'Fabrikbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3864, 'SKR04', 'Anlagevermögen', 260, 200, 'Andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3865, 'SKR04', 'Anlagevermögen', 270, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3866, 'SKR04', 'Anlagevermögen', 280, 200, 'Außenanlagen für Geschäfts-, Fabrik- und andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3867, 'SKR04', 'Anlagevermögen', 285, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3868, 'SKR04', 'Anlagevermögen', 290, 200, 'Einrichtungen für Geschäfts-. Fabrik- und andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3869, 'SKR04', 'Anlagevermögen', 300, 200, 'Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3870, 'SKR04', 'Anlagevermögen', 305, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3871, 'SKR04', 'Anlagevermögen', 310, 200, 'Außenanlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3872, 'SKR04', 'Anlagevermögen', 315, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3873, 'SKR04', 'Anlagevermögen', 320, 200, 'Einrichtungen für Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3874, 'SKR04', 'Anlagevermögen', 329, 200, 'Gebäudeteil des häuslichen Arbeitszimmers'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3875, 'SKR04', 'Anlagevermögen', 330, 200, 'Bauten auf fremden Grundstücken'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3876, 'SKR04', 'Anlagevermögen', 340, 200, 'Geschäftsbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3877, 'SKR04', 'Anlagevermögen', 350, 200, 'Fabrikbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3878, 'SKR04', 'Anlagevermögen', 360, 200, 'Wohnbauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3879, 'SKR04', 'Anlagevermögen', 370, 200, 'Andere Bauten'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3880, 'SKR04', 'Anlagevermögen', 380, 200, 'Garagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3881, 'SKR04', 'Anlagevermögen', 390, 200, 'Außenanlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3882, 'SKR04', 'Anlagevermögen', 395, 200, 'Hof- und Wegbefestigungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3883, 'SKR04', 'Anlagevermögen', 398, 200, 'Einrichtungen für Geschäfts-. Fabrik-, Wohn- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3855, 'SKR04', 'Anlagevermögen', 210, 3854, Grundstücksgleiche Rechte ohne Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3856, 'SKR04', 'Anlagevermögen', 215, 3854, Unbebaute Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3857, 'SKR04', 'Anlagevermögen', 220, 3854, Grundstücksgleiche Rechte (Erbbaurecht, Dauerwohnrecht, unbebaute Grundstücke)'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3858, 'SKR04', 'Anlagevermögen', 225, 3854, Grundstücke mit Substanzverkehr'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3859, 'SKR04', 'Anlagevermögen', 229, 3854, Grundstücksanteil des häuslichen Arbeitszimmers'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3860, 'SKR04', 'Anlagevermögen', 230, 3854, Bauten auf eigenen Grundstücken und grundstücksgleichen Rechten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3861, 'SKR04', 'Anlagevermögen', 235, 3854, Grundstückswerte eigener bebauter Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3862, 'SKR04', 'Anlagevermögen', 240, 3854, Geschäftsbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3863, 'SKR04', 'Anlagevermögen', 250, 3854, Fabrikbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3864, 'SKR04', 'Anlagevermögen', 260, 3854, Andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3865, 'SKR04', 'Anlagevermögen', 270, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3866, 'SKR04', 'Anlagevermögen', 280, 3854, Außenanlagen für Geschäfts-, Fabrik- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3867, 'SKR04', 'Anlagevermögen', 285, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3868, 'SKR04', 'Anlagevermögen', 290, 3854, Einrichtungen für Geschäfts-. Fabrik- und andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3869, 'SKR04', 'Anlagevermögen', 300, 3854, Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3870, 'SKR04', 'Anlagevermögen', 305, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3871, 'SKR04', 'Anlagevermögen', 310, 3854, Außenanlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3872, 'SKR04', 'Anlagevermögen', 315, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3873, 'SKR04', 'Anlagevermögen', 320, 3854, Einrichtungen für Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3874, 'SKR04', 'Anlagevermögen', 329, 3854, Gebäudeteil des häuslichen Arbeitszimmers'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3875, 'SKR04', 'Anlagevermögen', 330, 3854, Bauten auf fremden Grundstücken'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3876, 'SKR04', 'Anlagevermögen', 340, 3854, Geschäftsbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3877, 'SKR04', 'Anlagevermögen', 350, 3854, Fabrikbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3878, 'SKR04', 'Anlagevermögen', 360, 3854, Wohnbauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3879, 'SKR04', 'Anlagevermögen', 370, 3854, Andere Bauten'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3880, 'SKR04', 'Anlagevermögen', 380, 3854, Garagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3881, 'SKR04', 'Anlagevermögen', 390, 3854, Außenanlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3882, 'SKR04', 'Anlagevermögen', 395, 3854, Hof- und Wegbefestigungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3883, 'SKR04', 'Anlagevermögen', 398, 3854, Einrichtungen für Geschäfts-. Fabrik-, Wohn- und andere Bauten'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3884, 'SKR04', 'Anlagevermögen', 400, 0, 'Technische Anlagen und Maschinen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3885, 'SKR04', 'Anlagevermögen', 420, 400, 'Technische Anlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3886, 'SKR04', 'Anlagevermögen', 440, 400, 'Maschinen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3887, 'SKR04', 'Anlagevermögen', 450, 400, 'Transportanlagen und Ähnlichen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3888, 'SKR04', 'Anlagevermögen', 460, 400, 'Maschinengebundene Werkzeuge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3889, 'SKR04', 'Anlagevermögen', 470, 400, 'Betriebsvorrichtungen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3885, 'SKR04', 'Anlagevermögen', 420, 3884, 'Technische Anlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3886, 'SKR04', 'Anlagevermögen', 440, 3884, 'Maschinen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3887, 'SKR04', 'Anlagevermögen', 450, 3884, 'Transportanlagen und Ähnlichen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3888, 'SKR04', 'Anlagevermögen', 460, 3884, 'Maschinengebundene Werkzeuge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3889, 'SKR04', 'Anlagevermögen', 470, 3884, 'Betriebsvorrichtungen'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3890, 'SKR04', 'Anlagevermögen', 500, 0, 'Andere Anlagen, Betriebs- und Geschäftsausstattungen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3891, 'SKR04', 'Anlagevermögen', 510, 500, 'Andere Anlagen'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3892, 'SKR04', 'Anlagevermögen', 520, 500, 'PKW'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3893, 'SKR04', 'Anlagevermögen', 540, 500, 'LKW'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3894, 'SKR04', 'Anlagevermögen', 560, 500, 'Sonstige Transportmittel'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3895, 'SKR04', 'Anlagevermögen', 620, 500, 'Werkzeuge'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3896, 'SKR04', 'Anlagevermögen', 630, 500, 'Betriebsausstattung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3897, 'SKR04', 'Anlagevermögen', 635, 500, 'Geschäftsausstattung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3898, 'SKR04', 'Anlagevermögen', 640, 500, 'Ladeneinrichtung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3899, 'SKR04', 'Anlagevermögen', 650, 500, 'Büroeinrichtung'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3900, 'SKR04', 'Anlagevermögen', 660, 500, 'Gerüst- und Schalungsmaterial'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3901, 'SKR04', 'Anlagevermögen', 670, 500, 'Geringwertige Wirtschaftsgüter'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3902, 'SKR04', 'Anlagevermögen', 675, 500, 'Wirtschaftsgüter (Sammelposten)'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3903, 'SKR04', 'Anlagevermögen', 680, 500, 'Einbauten in fremde Grundstücke'); ---INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3904, 'SKR04', 'Anlagevermögen', 690, 500, 'Sonstige Betriebs- und Geschäftsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3891, 'SKR04', 'Anlagevermögen', 510, 3890, 'Andere Anlagen'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3892, 'SKR04', 'Anlagevermögen', 520, 3890, 'PKW'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3893, 'SKR04', 'Anlagevermögen', 540, 3890, 'LKW'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3894, 'SKR04', 'Anlagevermögen', 560, 3890, 'Sonstige Transportmittel'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3895, 'SKR04', 'Anlagevermögen', 620, 3890, 'Werkzeuge'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3896, 'SKR04', 'Anlagevermögen', 630, 3890, 'Betriebsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3897, 'SKR04', 'Anlagevermögen', 635, 3890, 'Geschäftsausstattung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3898, 'SKR04', 'Anlagevermögen', 640, 3890, 'Ladeneinrichtung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3899, 'SKR04', 'Anlagevermögen', 650, 3890, 'Büroeinrichtung'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3900, 'SKR04', 'Anlagevermögen', 660, 3890, 'Gerüst- und Schalungsmaterial'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3901, 'SKR04', 'Anlagevermögen', 670, 3890, 'Geringwertige Wirtschaftsgüter'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3902, 'SKR04', 'Anlagevermögen', 675, 3890, 'Wirtschaftsgüter (Sammelposten)'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3903, 'SKR04', 'Anlagevermögen', 680, 3890, 'Einbauten in fremde Grundstücke'); +--INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3904, 'SKR04', 'Anlagevermögen', 690, 3890, 'Sonstige Betriebs- und Geschäftsausstattung'); INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3905, 'SKR04', 'Anlagevermögen', 700, 0, 'Geleistete Anzahlungen und Anlagen im Bau'); --INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3906, 'SKR04', 'Anlagevermögen', 705, 700, 'Anzahlungen auf Grundstücke und grundstücksgleiche Rechte ohne Bauten'); --INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label) VALUES (__ENTITY__, 3907, 'SKR04', 'Anlagevermögen', 710, 700, 'Geschäfts-, Fabrik- und andere Bauten im Bau auf eigenen Grundstücken'); diff --git a/htdocs/install/mysql/data/llx_accounting_account_dz.sql b/htdocs/install/mysql/data/llx_accounting_account_dz.sql index 0a80cf0f4b4..3895c1ff604 100644 --- a/htdocs/install/mysql/data/llx_accounting_account_dz.sql +++ b/htdocs/install/mysql/data/llx_accounting_account_dz.sql @@ -24,7 +24,7 @@ -- ID 15000 - 15811 -- ADD 1300000 to rowid # Do no remove this comment -- -INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (17000,'NSCF','CAPIT','1',0,'Comptes de capitaux','1'); +INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15000,'NSCF','CAPIT','1',0,'Comptes de capitaux','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15001,'NSCF','CAPIT','10',17000,'Capital, réserves et assimilés','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15002,'NSCF','CAPIT','101',15001,'Capital émis','1'); INSERT IGNORE INTO llx_accounting_account (rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (15003,'NSCF','CAPIT','1011',15002,'Capital souscrit, non appelé','1'); diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index 713a7f31a4f..fabbbf2e700 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -36,5 +36,5 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql index 7b02ee60ffa..07a09724ed2 100644 --- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql +++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql @@ -10,6 +10,7 @@ -- Copyright (C) 2012 Tommaso Basilici -- Copyright (C) 2012 Ricardo Schluter -- Copyright (C) 2013 Cedric GROSS +-- Copyright (C) 2020-2021 Udo Tamm -- -- 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 @@ -25,14 +26,24 @@ -- along with this program. If not, see . -- +-- WARNING ---------------------------------------------------------------- -- +-- EN: +-- Do not put a comment at the end of the line, this file is parsed during +-- install and all '--' symbols are removed. +-- +-- FR: -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- +-- CONTENT ---------------------------------------------------------------- -- --- Formes juridiques +-- Legal Formes (en) / Formes juridiques (fr) -- +-- fk_pays = country_id +-- + delete from llx_c_forme_juridique; @@ -54,6 +65,7 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (23, ' INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (23, '2312', 'Sociedad Anónima con Participación Estatal Mayoritaria', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (23, '2313', 'Sociedad en Comandita por Acciones (arts. 315 a 324, LSC)', 1); + -- Austria INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4100', 'GmbH - Gesellschaft mit beschränkter Haftung', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4101', 'GesmbH - Gesellschaft mit beschränkter Haftung', 1); @@ -71,6 +83,31 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, ' INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4113', 'GesnbR - Gesellschaft nach bürgerlichem Recht', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (41, '4114', 'e.U. - eingetragener Einzelunternehmer', 1); + +-- Belgium +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '200', 'Indépendant'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '201', 'SRL - Société à responsabilité limitée'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '202', 'SA - Société Anonyme'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '203', 'SCRL - Société coopérative à responsabilité limitée'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '204', 'ASBL - Association sans but Lucratif'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '205', 'SCRI - Société coopérative à responsabilité illimitée'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '206', 'SCS - Société en commandite simple'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '207', 'SCA - Société en commandite par action'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '208', 'SNC - Société en nom collectif'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '209', 'GIE - Groupement d intérêt économique'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '210', 'GEIE - Groupement européen d intérêt économique'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '220', 'Eenmanszaak'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '221', 'BVBA - Besloten vennootschap met beperkte aansprakelijkheid'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '222', 'NV - Naamloze Vennootschap'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '223', 'CVBA - Coöperatieve vennootschap met beperkte aansprakelijkheid'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '224', 'VZW - Vereniging zonder winstoogmerk'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '225', 'CVOA - Coöperatieve vennootschap met onbeperkte aansprakelijkheid '); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '226', 'GCV - Gewone commanditaire vennootschap'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '227', 'Comm.VA - Commanditaire vennootschap op aandelen'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '228', 'VOF - Vennootschap onder firma'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '229', 'VS0 - Vennootschap met sociaal oogmerk'); + + -- France: Extrait de http://www.insee.fr/fr/nom_def_met/nomenclatures/cj/cjniveau2.htm insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'11','Artisan Commerçant (EI)'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'12','Commerçant (EI)'); @@ -127,28 +164,6 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'92','Assoc insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'93','Fondation'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'99','Personne morale de droit privé'); --- Belgium -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '200', 'Indépendant'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '201', 'SRL - Société à responsabilité limitée'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '202', 'SA - Société Anonyme'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '203', 'SCRL - Société coopérative à responsabilité limitée'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '204', 'ASBL - Association sans but Lucratif'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '205', 'SCRI - Société coopérative à responsabilité illimitée'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '206', 'SCS - Société en commandite simple'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '207', 'SCA - Société en commandite par action'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '208', 'SNC - Société en nom collectif'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '209', 'GIE - Groupement d intérêt économique'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '210', 'GEIE - Groupement européen d intérêt économique'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '220', 'Eenmanszaak'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '221', 'BVBA - Besloten vennootschap met beperkte aansprakelijkheid'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '222', 'NV - Naamloze Vennootschap'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '223', 'CVBA - Coöperatieve vennootschap met beperkte aansprakelijkheid'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '224', 'VZW - Vereniging zonder winstoogmerk'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '225', 'CVOA - Coöperatieve vennootschap met onbeperkte aansprakelijkheid '); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '226', 'GCV - Gewone commanditaire vennootschap'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '227', 'Comm.VA - Commanditaire vennootschap op aandelen'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '228', 'VOF - Vennootschap onder firma'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '229', 'VS0 - Vennootschap met sociaal oogmerk'); -- Germany insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '500', 'GmbH - Gesellschaft mit beschränkter Haftung'); @@ -160,6 +175,8 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '505', 'Gb insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '506', 'KG - Kommanditgesellschaft'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '507', 'Ltd. - Limited Company'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '508', 'OHG - Offene Handelsgesellschaft'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '509', 'eG - eingetragene Genossenschaft'); + -- Denmark INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8001', 'Aktieselvskab A/S'); diff --git a/htdocs/install/mysql/data/llx_c_socialnetworks.sql b/htdocs/install/mysql/data/llx_c_socialnetworks.sql index 829cbbf0294..5bfbcf090d9 100644 --- a/htdocs/install/mysql/data/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/data/llx_c_socialnetworks.sql @@ -1,4 +1,11 @@ +-- Copyright (C) Year(-Year) Author Name -- +-- eldy +-- frederic34 +-- dolibit-ut +-- + +-- License -- 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 @@ -10,46 +17,46 @@ -- 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 . +-- along with this program. If not, see . -- -- --- +-- Note -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- -- socialnetworks -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', 'fa-tumblr', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'slack', 'Slack', '{socialid}', 'fa-slack', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'xing', 'Xing', '{socialid}', 'fa-xing', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'meetup', 'Meetup', '{socialid}', 'fa-meetup', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'pinterest', 'Pinterest', '{socialid}', 'fa-pinterest', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'flickr', 'Flickr', '{socialid}', 'fa-flickr', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, '500px', '500px', '{socialid}', 'fa-500px', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'giphy', 'Giphy', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'gifycat', 'Gificat', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vimeo', 'Vimeo', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'periscope', 'Periscope', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitch', 'Twitch', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'discord', 'Discord', '{socialid}', 'fa-discord', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'reddit', 'Reddit', '{socialid}', 'fa-reddit', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'quora', 'Quora', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'mastodon', 'Mastodon', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'diaspora', 'Diaspora', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viber', 'Viber', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, '500px', '500px', '{socialid}', 'fa-500px', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'diaspora', 'Diaspora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'discord', 'Discord', '{socialid}', 'fa-discord', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'flickr', 'Flickr', '{socialid}', 'fa-flickr', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'gifycat', 'Gificat', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'giphy', 'Giphy', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'mastodon', 'Mastodon', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'meetup', 'Meetup', '{socialid}', 'fa-meetup', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'periscope', 'Periscope', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'pinterest', 'Pinterest', '{socialid}', 'fa-pinterest', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'quora', 'Quora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'reddit', 'Reddit', '{socialid}', 'fa-reddit', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'slack', 'Slack', '{socialid}', 'fa-slack', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', 'fa-tumblr', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitch', 'Twitch', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viber', 'Viber', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vimeo', 'Vimeo', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'xing', 'Xing', '{socialid}', 'fa-xing', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index f16cf5ca5df..825e21ddf42 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -5,6 +5,7 @@ -- Copyright (C) 2004 Guillaume Delecourt -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2021 Udo Tamm -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -18,84 +19,101 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . --- --- +-- +-- Notes +-- +-- Do not place a comment at the end of the line, this file is parsed when +-- of the install and all the acronyms '-' are removed. -- -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- -- +-- The types of contact of an element -- Les types de contact d'un element -- -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1); - -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial à l''origine de la propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (42, 'propal', 'external', 'SHIPPING', 'Contact client livraison propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); +-- Contract / Contrat +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'invoice_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'invoice_supplier', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); +-- Proposal / Propal +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial à l''origine de la propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (42, 'propal', 'external', 'SHIPPING', 'Contact client livraison propale', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'agenda', 'internal', 'ACTOR', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'agenda', 'internal', 'GUEST', 'Guest', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (85, 'agenda', 'external', 'ACTOR', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (86, 'agenda', 'external', 'GUEST', 'Guest', 1); +-- Customer Invoice / Facture +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101,'commande','external', 'CUSTOMER', 'Contact client suivi commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (102,'commande','external', 'SHIPPING', 'Contact client livraison commande', 1); +-- Supplier Invoice +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (72, 'invoice_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (73, 'invoice_supplier', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (120, 'fichinter','internal', 'INTERREPFOLL', 'Responsable suivi de l''intervention', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (121, 'fichinter','internal', 'INTERVENING', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (130, 'fichinter','external', 'BILLING', 'Contact client facturation intervention', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (131, 'fichinter','external', 'CUSTOMER', 'Contact client suivi de l''intervention', 1); +-- Agenda +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (80, 'agenda', 'internal', 'ACTOR', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (81, 'agenda', 'internal', 'GUEST', 'Guest', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (85, 'agenda', 'external', 'ACTOR', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (86, 'agenda', 'external', 'GUEST', 'Guest', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (140, 'order_supplier','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (141, 'order_supplier','internal', 'SHIPPING', 'Responsable réception de la commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (142, 'order_supplier','external', 'BILLING', 'Contact fournisseur facturation commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (143, 'order_supplier','external', 'CUSTOMER', 'Contact fournisseur suivi commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (145, 'order_supplier','external', 'SHIPPING', 'Contact fournisseur livraison commande', 1); +-- Customer Order / Commande +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (91, 'commande', 'internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (100,'commande', 'external', 'BILLING', 'Contact client facturation commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (101,'commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (102,'commande', 'external', 'SHIPPING', 'Contact client livraison commande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (150, 'dolresource','internal', 'USERINCHARGE', 'In charge of resource', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (151, 'dolresource','external', 'THIRDINCHARGE', 'In charge of resource', 1); +-- Intervention / Fichinter +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (120, 'fichinter', 'internal', 'INTERREPFOLL', 'Responsable suivi de l''intervention', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (121, 'fichinter', 'internal', 'INTERVENING', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (130, 'fichinter', 'external', 'BILLING', 'Contact client facturation intervention', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (131, 'fichinter', 'external', 'CUSTOMER', 'Contact client suivi de l''intervention', 1); --- All project code can start with 'PROJECT' -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); +-- Supplier Order +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (140, 'order_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (141, 'order_supplier', 'internal', 'SHIPPING', 'Responsable réception de la commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (142, 'order_supplier', 'external', 'BILLING', 'Contact fournisseur facturation commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (143, 'order_supplier', 'external', 'CUSTOMER', 'Contact fournisseur suivi commande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (145, 'order_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison commande', 1); --- All task code can start with 'TASK' -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'TASKCONTRIBUTOR', 'Intervenant', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'TASKCONTRIBUTOR', 'Intervenant', 1); +-- Resource +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (150, 'dolresource', 'internal', 'USERINCHARGE', 'In charge of resource', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (151, 'dolresource', 'external', 'THIRDINCHARGE', 'In charge of resource', 1); -- Tickets -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(155, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur contact support', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(156, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(157, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1, NULL); -INSERT INTO llx_c_type_contact (rowid, element, source, code, libelle, active, module) VALUES(158, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (155, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur contact support', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (156, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (157, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1, NULL); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active, module) values (158, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1, NULL); + +-- Projects / Projet - All project code can start with 'PROJECT' +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'PROJECTCONTRIBUTOR', 'Intervenant', 1); + +-- Project Tasks - All task code can start with 'TASK' +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'TASKCONTRIBUTOR', 'Intervenant', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'TASKCONTRIBUTOR', 'Intervenant', 1); -- Supplier proposal +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (110, 'supplier_proposal', 'internal', 'SALESREPFOLL', 'Responsable suivi de la demande', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (111, 'supplier_proposal', 'external', 'BILLING', 'Contact fournisseur facturation', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (112, 'supplier_proposal', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (113, 'supplier_proposal', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110, 'supplier_proposal', 'internal', 'SALESREPFOLL', 'Responsable suivi de la demande', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (111, 'supplier_proposal', 'external', 'BILLING', 'Contact fournisseur facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (112, 'supplier_proposal', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (113, 'supplier_proposal', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); - +-- Event Organization +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); +insert into llx_c_type_contact (rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); 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 cb6e6d6ef4c..f2ae6c7d173 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 @@ -197,7 +197,7 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

    __ONLINE_PAYMENT_TEXT_AND_URL__


    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendes', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendes)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

    __(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

    __(Sincerely)__
    __USER_SIGNATURE__', null, '1', null); ALTER TABLE llx_projet ADD COLUMN accept_conference_suggestions integer DEFAULT 0; @@ -226,6 +226,10 @@ ALTER TABLE llx_supplier_proposal CHANGE COLUMN tva total_tva double(24,8) defau ALTER TABLE llx_supplier_proposal CHANGE COLUMN total total_ttc double(24,8) default 0; ALTER TABLE llx_propal CHANGE COLUMN tva total_tva double(24,8) default 0; ALTER TABLE llx_propal CHANGE COLUMN total total_ttc double(24,8) default 0; +ALTER TABLE llx_facture CHANGE COLUMN tva total_tva double(24,8) default 0; +ALTER TABLE llx_facture CHANGE COLUMN total total_ht double(24,8) default 0; +ALTER TABLE llx_facture_rec CHANGE COLUMN tva total_tva double(24,8) default 0; +ALTER TABLE llx_facture_rec CHANGE COLUMN total total_ht double(24,8) default 0; ALTER TABLE llx_commande_fournisseur CHANGE COLUMN tva total_tva double(24,8) default 0; @@ -278,3 +282,95 @@ DELETE FROM llx_boxes_def WHERE file IN ('box_graph_ticket_by_severity', 'box_ti -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_ticket_last_x_days.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_ticket_last_x_days.php' AND entity = 1); -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_nb_tickets_type.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_nb_tickets_type.php' AND entity = 1); -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_graph_new_vs_close_ticket.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_graph_new_vs_close_ticket.php' AND entity = 1); + +create table llx_product_perentity +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_product integer, + entity integer DEFAULT 1 NOT NULL, -- multi company id + accountancy_code_sell varchar(32), -- Selling accountancy code + accountancy_code_sell_intra varchar(32), -- Selling accountancy code for vat intracommunity + 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 +)ENGINE=innodb; + +ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product); +ALTER TABLE llx_product_perentity ADD UNIQUE INDEX uk_product_perentity (fk_product, entity); + +create table llx_societe_perentity +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_soc integer, + entity integer DEFAULT 1 NOT NULL, -- multi company id +-- code_compta varchar(24), -- code compta client +-- code_compta_fournisseur varchar(24), -- code compta founisseur + accountancy_code_sell varchar(32), -- Selling accountancy code + accountancy_code_buy varchar(32) -- Buying accountancy code +)ENGINE=innodb; + +ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc); +ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity); + +CREATE TABLE llx_eventorganization_conferenceorboothattendee( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + fk_soc integer, + fk_actioncomm integer NOT NULL, + email varchar(100), + date_subscription datetime, + amount double DEFAULT NULL, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email); + +create table llx_eventorganization_conferenceorboothattendee_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object); + +ALTER TABLE llx_c_ticket_category ADD COLUMN public integer DEFAULT 0; +ALTER TABLE llx_c_ticket_category MODIFY COLUMN pos integer DEFAULT 0 NOT NULL; + + +ALTER TABLE llx_propal ADD COLUMN date_signature datetime AFTER date_valid; +ALTER TABLE llx_propal ADD COLUMN fk_user_signature integer AFTER fk_user_valid; +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); + +UPDATE llx_propal SET fk_user_signature = fk_user_cloture WHERE fk_user_signature IS NULL AND fk_user_cloture IS NOT NULL; +UPDATE llx_propal SET date_signature = date_cloture WHERE date_signature IS NULL AND date_cloture IS NOT NULL; + +ALTER TABLE llx_product ADD COLUMN batch_mask VARCHAR(32) NULL; + +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (210, 'conferenceorbooth', 'internal', 'MANAGER', 'Conference or Booth manager', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (211, 'conferenceorbooth', 'external', 'SPEAKER', 'Conference Speaker', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (212, 'conferenceorbooth', 'external', 'RESPONSIBLE', 'Booth responsible', 1); + +ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; +ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; + +ALTER TABLE llx_entrepot ADD COLUMN fk_project INTEGER DEFAULT NULL AFTER entity; -- project associated to warehouse if any diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index 58126633ce1..10d16331a06 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -1,4 +1,5 @@ -- Copyright (C) 2013-2018 Jean-François FERRY +-- Copyright (C) 2020-2021 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -12,19 +13,22 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . + -- --- +-- Table with the categories of a ticket +-- create table llx_c_ticket_category ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1, - code varchar(32) NOT NULL, - pos varchar(32) NOT NULL, + code varchar(32) NOT NULL, -- Example: TIGRP-COMMERCIAL, TIGRP-TECHNICALISSUE, ... label varchar(128) NOT NULL, - active integer DEFAULT 1, + public integer DEFAULT 0, use_default integer DEFAULT 1, fk_parent integer DEFAULT 0 NOT NULL, -- Parent group force_severity varchar(32) NULL, -- To force the severity if we choosed this category - description varchar(255) + description varchar(255), -- A long description of ticket + pos integer DEFAULT 0 NOT NULL, + active integer DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index 2a390f008e2..be49978f6b7 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -25,6 +25,7 @@ create table llx_entrepot datec datetime, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_project integer DEFAULT NULL, -- project associated to warehouse if any description text, lieu varchar(64), -- resume lieu situation address varchar(255), diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql new file mode 100644 index 00000000000..2314221b41d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql @@ -0,0 +1,31 @@ +-- 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 https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_rowid (rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_ref (ref); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_soc (fk_soc); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT llx_eventorganization_conferenceorboothattendee_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status); +-- END MODULEBUILDER INDEXES + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email); + + diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql new file mode 100644 index 00000000000..c6ff6dedf66 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql @@ -0,0 +1,37 @@ +-- 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 https://www.gnu.org/licenses/. + + +CREATE TABLE llx_eventorganization_conferenceorboothattendee( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + fk_soc integer, + fk_actioncomm integer NOT NULL, + email varchar(100), + date_subscription datetime, + amount double DEFAULT NULL, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + last_main_doc varchar(255), + import_key varchar(14), + model_pdf varchar(255), + status smallint NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql new file mode 100644 index 00000000000..5fa3554fae3 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.key.sql @@ -0,0 +1,19 @@ +-- 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 https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_eventorganization_conferenceorboothattendee_extrafields ADD INDEX idx_conferenceorboothattendee_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.sql new file mode 100644 index 00000000000..5455314ff06 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee_extrafields.sql @@ -0,0 +1,23 @@ +-- 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 https://www.gnu.org/licenses/. + +create table llx_eventorganization_conferenceorboothattendee_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 010cf1c1573..acb43444ad2 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -50,11 +50,11 @@ create table llx_facture close_code varchar(16), -- Code motif cloture sans paiement complet close_note varchar(128), -- Commentaire cloture sans paiement complet - tva double(24,8) DEFAULT 0, -- amount total tva apres remise totale + total_tva double(24,8) DEFAULT 0, -- amount total tva apres remise totale localtax1 double(24,8) DEFAULT 0, -- amount total localtax1 localtax2 double(24,8) DEFAULT 0, -- amount total localtax2 revenuestamp double(24,8) DEFAULT 0, -- amount total revenuestamp - total double(24,8) DEFAULT 0, -- amount total ht apres remise totale + total_ht double(24,8) DEFAULT 0, -- amount total ht apres remise totale total_ttc double(24,8) DEFAULT 0, -- amount total ttc apres remise totale fk_statut smallint DEFAULT 0 NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index ef7e980b8aa..e5e78f87028 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -1,8 +1,9 @@ -- =========================================================================== --- Copyright (C) 2001-2003 Rodolphe Quiedeville --- Copyright (C) 2007-2017 Laurent Destailleur --- Copyright (C) 2007-2012 Regis Houssin --- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2001-2003 Rodolphe Quiedeville +-- Copyright (C) 2007-2017 Laurent Destailleur +-- Copyright (C) 2007-2012 Regis Houssin +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2021 Alexandre Spangaro -- -- 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 @@ -32,10 +33,11 @@ create table llx_facture_fourn fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture - datef date, -- date de la facture + datef date, -- date invoice date_pointoftax date DEFAULT NULL, -- date point of tax (for GB) date_valid date, -- date validation tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date + date_closing datetime, -- date closing libelle varchar(255), paye smallint DEFAULT 0 NOT NULL, amount double(24,8) DEFAULT 0 NOT NULL, @@ -57,14 +59,15 @@ create table llx_facture_fourn fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating + fk_user_closing integer, -- user closing fk_facture_source integer, -- facture origine si facture avoir fk_projet integer, -- projet auquel est associee la facture fk_account integer, -- bank account - fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) - fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) - date_lim_reglement date, -- date limite de reglement + fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) + fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) + date_lim_reglement date, -- date limite de reglement note_private text, note_public text, diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index 0db78d62252..c3cb6aeed46 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -36,11 +36,11 @@ create table llx_facture_rec remise_absolue real DEFAULT 0, vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. - tva double(24,8) DEFAULT 0, + total_tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, -- amount localtax1 localtax2 double(24,8) DEFAULT 0, -- amount localtax2 revenuestamp double(24,8) DEFAULT 0, -- amount total revenuestamp - total double(24,8) DEFAULT 0, + total_ht double(24,8) DEFAULT 0, total_ttc double(24,8) DEFAULT 0, fk_user_author integer, -- user creating diff --git a/htdocs/install/mysql/tables/llx_holiday_extrafields.sql b/htdocs/install/mysql/tables/llx_holiday_extrafields.sql index 8b6e3ef8dc9..6baf1789dc2 100644 --- a/htdocs/install/mysql/tables/llx_holiday_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_holiday_extrafields.sql @@ -1,6 +1,9 @@ -- ======================================================================== -- Copyright (C) 2016 Laurent Destailleur -- +-- +-- LICENSE ================================================================ +-- -- 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 @@ -12,7 +15,7 @@ -- 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 . +-- along with this program. If not, see . -- -- ======================================================================== diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 2431c884c62..da8c2ff693c 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -51,7 +51,7 @@ create table llx_product recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT localtax1_tx double(6,3) DEFAULT 0, localtax1_type varchar(10) NOT NULL DEFAULT '0', - localtax2_tx double(6,3) DEFAULT 0, + localtax2_tx double(6,3) DEFAULT 0, localtax2_type varchar(10) NOT NULL DEFAULT '0', fk_user_author integer DEFAULT NULL, -- user making creation fk_user_modif integer, -- user making last change @@ -59,6 +59,7 @@ create table llx_product tobuy tinyint DEFAULT 1, -- Product you buy onportal tinyint DEFAULT 0, -- If it is a product you sell and you want to sell it on portal (module website must be on) tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management) + batch_mask varchar(32), -- If the product has batch feature, you may want to use a batch mask per product fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module) duration varchar(6), seuil_stock_alerte float DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_product_perentity.key.sql b/htdocs/install/mysql/tables/llx_product_perentity.key.sql new file mode 100644 index 00000000000..8e8ad48044c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_perentity.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2021 Open-Dsi +-- +-- 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 . +-- +-- =================================================================== + +ALTER TABLE llx_product_perentity ADD INDEX idx_product_perentity_fk_product (fk_product); + +ALTER TABLE llx_product_perentity ADD UNIQUE INDEX uk_product_perentity (fk_product, entity); diff --git a/htdocs/install/mysql/tables/llx_product_perentity.sql b/htdocs/install/mysql/tables/llx_product_perentity.sql new file mode 100644 index 00000000000..6e32e506ddf --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_perentity.sql @@ -0,0 +1,30 @@ +-- ======================================================================== +-- Copyright (C) 2021 Open-Dsi +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_product_perentity +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_product integer, + entity integer DEFAULT 1 NOT NULL, -- multi company id + accountancy_code_sell varchar(32), -- Selling accountancy code + accountancy_code_sell_intra varchar(32), -- Selling accountancy code for vat intracommunity + 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 +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_propal.key.sql b/htdocs/install/mysql/tables/llx_propal.key.sql index 89a0c54ad83..d0265e6fcdf 100644 --- a/htdocs/install/mysql/tables/llx_propal.key.sql +++ b/htdocs/install/mysql/tables/llx_propal.key.sql @@ -24,6 +24,7 @@ ALTER TABLE llx_propal ADD UNIQUE INDEX uk_propal_ref (ref, entity); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_soc (fk_soc); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_author (fk_user_author); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_valid (fk_user_valid); +ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_signature (fk_user_signature); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_user_cloture (fk_user_cloture); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_projet (fk_projet); ALTER TABLE llx_propal ADD INDEX idx_propal_fk_account(fk_account); @@ -33,6 +34,7 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_signature FOREIGN KEY (fk_user_signature) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_user_cloture FOREIGN KEY (fk_user_cloture) REFERENCES llx_user (rowid); ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); --ALTER TABLE llx_propal ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid); diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 004bb027d35..7c94086b3b9 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -37,11 +37,13 @@ create table llx_propal datep date, -- date de la propal fin_validite datetime, -- date de fin de validite date_valid datetime, -- date de validation + date_signature datetime, -- date signature date_cloture datetime, -- date de cloture fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change fk_user_valid integer, -- user validating - fk_user_cloture integer, -- user closing (signed or not) + fk_user_signature integer, -- user signing (signed or not) + fk_user_cloture integer, -- user closing fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed price real DEFAULT 0, -- (obsolete) remise_percent real DEFAULT 0, -- remise globale relative en pourcent (obsolete) diff --git a/htdocs/install/mysql/tables/llx_societe_perentity.key.sql b/htdocs/install/mysql/tables/llx_societe_perentity.key.sql new file mode 100644 index 00000000000..dd2970e16d2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_perentity.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2021 Open-Dsi +-- +-- 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 . +-- +-- =================================================================== + +ALTER TABLE llx_societe_perentity ADD INDEX idx_societe_perentity_fk_soc (fk_soc); + +ALTER TABLE llx_societe_perentity ADD UNIQUE INDEX uk_societe_perentity (fk_soc, entity); diff --git a/htdocs/install/mysql/tables/llx_societe_perentity.sql b/htdocs/install/mysql/tables/llx_societe_perentity.sql new file mode 100644 index 00000000000..408169476d9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_perentity.sql @@ -0,0 +1,28 @@ +-- ======================================================================== +-- Copyright (C) 2021 Open-Dsi +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_societe_perentity +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_soc integer, + entity integer DEFAULT 1 NOT NULL, -- multi company id +-- code_compta varchar(24), -- code compta client +-- code_compta_fournisseur varchar(24), -- code compta founisseur + accountancy_code_sell varchar(32), -- Selling accountancy code + accountancy_code_buy varchar(32) -- Buying accountancy code +)ENGINE=innodb; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index cd98cdfef2e..17339c1f605 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -52,6 +52,7 @@ CREATE OR REPLACE FUNCTION DAY(TIMESTAMP WITH TIME ZONE) RETURNS INTEGER AS $$ S CREATE OR REPLACE FUNCTION DAY(DATE) RETURNS INTEGER AS $$ SELECT EXTRACT(DAY FROM $1)::INTEGER; $$ LANGUAGE SQL IMMUTABLE; CREATE OR REPLACE FUNCTION dol_util_rebuild_sequences() RETURNS integer as $body$ DECLARE sequencedefs RECORD; c integer ; BEGIN FOR sequencedefs IN SELECT DISTINCT constraint_column_usage.table_name as tablename, constraint_column_usage.table_name as tablename, constraint_column_usage.column_name as columnname, replace(replace(columns.column_default,'''::regclass)',''),'nextval(''','') as sequencename from information_schema.constraint_column_usage, information_schema.columns, information_schema.sequences where constraint_column_usage.table_schema ='public' AND columns.table_schema = 'public' AND columns.table_name=constraint_column_usage.table_name AND constraint_column_usage.column_name IN ('rowid','id') AND constraint_column_usage.column_name = columns.column_name AND columns.column_default is not null AND replace(replace(columns.column_default,'''::regclass)',''),'nextval(''','')=sequence_name LOOP EXECUTE 'select max('||sequencedefs.columnname||') from ' || sequencedefs.tablename INTO c; IF c is null THEN c = 0; END IF; IF c is not null THEN c = c+ 1; END IF; EXECUTE 'alter sequence ' || sequencedefs.sequencename ||' restart with ' || c; END LOOP; RETURN 1; END; $body$ LANGUAGE plpgsql; +-- You can call the function with SELECT dol_util_rebuild_sequences(); CREATE OR REPLACE FUNCTION dol_util_triggerall(DoEnable boolean) RETURNS integer AS $BODY$ DECLARE mytables RECORD; BEGIN FOR mytables IN SELECT relname FROM pg_class WHERE relhastriggers IS TRUE AND relkind = 'r' AND NOT relname LIKE 'pg_%' LOOP IF DoEnable THEN EXECUTE 'ALTER TABLE ' || mytables.relname || ' ENABLE TRIGGER ALL'; ELSE EXECUTE 'ALTER TABLE ' || mytables.relname || ' DISABLE TRIGGER ALL'; END IF; END LOOP; RETURN 1; END; $BODY$ LANGUAGE plpgsql; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 80678abe24f..ed4fb8dab13 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,6 +95,9 @@ print 'Option repair_link_dispatch_lines_supplier_order_lines, (\'test\' or \'co print 'Option set_empty_time_spent_amount (\'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount', 'alpha') ?GETPOST('set_empty_time_spent_amount', 'alpha') : 'undefined').'
    '."\n"; // Structure print 'Option force_utf8_on_tables, for mysql/mariadb only (\'test\' or \'confirmed\') is '.(GETPOST('force_utf8_on_tables', 'alpha') ?GETPOST('force_utf8_on_tables', 'alpha') : 'undefined').'
    '."\n"; +print "Option force_utf8mb4_on_tables (EXPERIMENTAL!), for mysql/mariadb only ('test' or 'confirmed') is ".(GETPOST('force_utf8mb4_on_tables', 'alpha') ? GETPOST('force_utf8mb4_on_tables', 'alpha') : 'undefined')."
    \n"; +// Rebuild sequence +print 'Option rebuild_sequences, for postgresql only (\'test\' or \'confirmed\') is '.(GETPOST('rebuild_sequences', 'alpha') ?GETPOST('rebuild_sequences', 'alpha') : 'undefined').'
    '."\n"; print '
    '; print ''; @@ -172,7 +176,8 @@ $oneoptionset = 0; $oneoptionset = (GETPOST('standard', 'alpha') || GETPOST('restore_thirdparties_logos', 'alpha') || GETPOST('clean_linked_elements', 'alpha') || GETPOST('clean_menus', 'alpha') || GETPOST('clean_orphelin_dir', 'alpha') || GETPOST('clean_product_stock_batch', 'alpha') || GETPOST('set_empty_time_spent_amount', 'alpha') || GETPOST('rebuild_product_thumbs', 'alpha') || GETPOST('clean_perm_table', 'alpha') - || GETPOST('force_disable_of_modules_not_found', 'alpha') || GETPOST('force_utf8_on_tables', 'alpha')); + || GETPOST('force_disable_of_modules_not_found', 'alpha') || GETPOST('force_utf8_on_tables', 'alpha') + || GETPOST('rebuild_sequences', 'alpha')); if ($ok && $oneoptionset) { // Show wait message @@ -930,14 +935,14 @@ if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { } if ($methodtofix == 'updatestock') { // Method 2 - print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? $obj->reelbatch : '0').' for ps.rowid = '.$obj->psrowid; + print ' -> Update qty of product_stock with qty = '.($obj->reelbatch ? ((float) $obj->reelbatch) : '0').' for ps.rowid = '.((int) $obj->psrowid); if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error = 0; $db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_stock"; - $sql2 .= " SET reel = ".($obj->reelbatch ? $obj->reelbatch : '0')." WHERE rowid = ".$obj->psrowid; + $sql2 .= " SET reel = ".($obj->reelbatch ? ((float) $obj->reelbatch) : '0')." WHERE rowid = ".((int) $obj->psrowid); $resql2 = $db->query($sql2); if ($resql2) { // We update product_stock, so we must fill p.stock into product too. @@ -1024,7 +1029,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { if (GETPOST('set_empty_time_spent_amount') == 'confirmed') { $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; + $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".((int) $obj->user_id); $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -1175,7 +1180,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { foreach ($conf->modules as $key => $val) { $listofmods .= ($listofmods ? ',' : '')."'".$val."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module not in ('.$listofmods.') AND id > 100000'; + $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods).') AND id > 100000'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1253,6 +1258,78 @@ if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) { } } +// force utf8mb4 on tables EXPERIMENTAL ! +if ($ok && GETPOST('force_utf8mb4_on_tables', 'alpha')) { + print ''; + + if ($db->type == "mysql" || $db->type == "mysqli") { + $force_utf8mb4_on_tables = GETPOST('force_utf8mb4_on_tables', 'alpha'); + + $listoftables = $db->DDLListTables($db->database_name); + + // Disable foreign key checking for avoid errors + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } + + foreach ($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) { + continue; + } + + print ''; + flush(); + ob_flush(); + } + + // Enable foreign key checking + if ($force_utf8mb4_on_tables == 'confirmed') { + $sql = 'SET FOREIGN_KEY_CHECKS=1'; + print ''; + $resql = $db->query($sql); + } + } else { + print ''; + } +} + +// rebuild sequences for pgsql +if ($ok && GETPOST('rebuild_sequences', 'alpha')) { + print ''; + + if ($db->type == "pgsql") { + $rebuild_sequence = GETPOST('rebuild_sequences', 'alpha'); + + if ($rebuild_sequence == 'confirmed') { + $sql = "SELECT dol_util_rebuild_sequences();"; + print ''; + $resql = $db->query($sql); + } + } else { + print ''; + } +} + // if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { /* @@ -1296,8 +1373,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { } while ($obj_dispatch = $db->fetch_object($resql_dispatch)) { $sql_line = 'SELECT line.rowid, line.qty FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet AS line'; - $sql_line .= ' WHERE line.fk_commande = '.$obj_dispatch->fk_commande; - $sql_line .= ' AND line.fk_product = '.$obj_dispatch->fk_product; + $sql_line .= ' WHERE line.fk_commande = '.((int) $obj_dispatch->fk_commande); + $sql_line .= ' AND line.fk_product = '.((int) $obj_dispatch->fk_product); $resql_line = $db->query($sql_line); // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur, @@ -1325,8 +1402,8 @@ if ($ok && GETPOST('repair_link_dispatch_lines_supplier_order_lines')) { $qty_for_line = min($remaining_qty, $obj_line->qty); if ($first_iteration) { $sql_attach = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql_attach .= ' SET fk_commandefourndet = '.$obj_line->rowid.', qty = '.$qty_for_line; - $sql_attach .= ' WHERE rowid = '.$obj_dispatch->rowid; + $sql_attach .= ' SET fk_commandefourndet = '.((int) $obj_line->rowid).', qty = '.((float) $qty_for_line); + $sql_attach .= ' WHERE rowid = '.((int) $obj_dispatch->rowid); $first_iteration = false; } else { $sql_attach_values = array( diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index e841a352b40..86e970f8194 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -231,7 +231,6 @@ if (!$error) { $databasefortest = 'master'; } } - //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"]; $db = getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d613e4a18b0..23fa3d95a3c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -456,6 +456,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BOM'=>'menuonly', 'MAIN_MODULE_BANQUE'=>'menuonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', 'MAIN_MODULE_CRON'=>'newboxdefonly', @@ -470,6 +471,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', 'MAIN_MODULE_MARGIN'=>'menuonly', + 'MAIN_MODULE_MRP'=>'menuonly', 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', 'MAIN_MODULE_PRINTING'=>'newboxdefonly', @@ -678,7 +680,7 @@ function migrate_paiements($db, $langs, $conf) $res += $db->query($sql); - $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".$row[$i][0]; + $sql = "UPDATE ".MAIN_DB_PREFIX."paiement SET fk_facture = 0 WHERE rowid = ".((int) $row[$i][0]); $res += $db->query($sql); @@ -1342,7 +1344,7 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_sql .= ' WHERE fk_paiementfourn = '.((int) $select_obj->rowid).' AND fk_facturefourn = '.((int) $select_obj->fk_facture_fourn); $check_resql = $db->query($check_sql); if ($check_resql) { $check_num = $db->num_rows($check_resql); @@ -2161,7 +2163,7 @@ function migrate_detail_livraison($db, $langs, $conf) if ($resql2) { $sql = "SELECT total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql .= " WHERE rowid = ".$obj->fk_livraison; + $sql .= " WHERE rowid = ".((int) $obj->fk_livraison); $resql3 = $db->query($sql); if ($resql3) { @@ -2864,7 +2866,7 @@ function migrate_project_task_time($db, $langs, $conf) foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; $sql .= " duration_effective = ".$total_duration; - $sql .= " WHERE rowid = ".$taskid; + $sql .= " WHERE rowid = ".((int) $taskid); $resql = $db->query($sql); if (!$resql) { @@ -3235,7 +3237,7 @@ function migrate_mode_reglement($db, $langs, $conf) $sqlSelect = "SELECT id"; $sqlSelect .= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sqlSelect .= " WHERE id = ".$old_id; + $sqlSelect .= " WHERE id = ".((int) $old_id); $sqlSelect .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sqlSelect); @@ -3246,23 +3248,23 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); - $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET "; - $sqla .= "fk_paiement = ".$elements['new_id'][$key]; - $sqla .= " WHERE fk_paiement = ".$old_id; - $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$db->escape($elements['code'][$key])."')"; + $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET"; + $sqla .= " fk_paiement = ".((int) $elements['new_id'][$key]); + $sqla .= " WHERE fk_paiement = ".((int) $old_id); + $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".((int) $old_id)." AND code = '".$db->escape($elements['code'][$key])."')"; $resqla = $db->query($sqla); - $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; - $sql .= "id = ".$elements['new_id'][$key]; - $sql .= " WHERE id = ".$old_id; + $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET"; + $sql .= " id = ".((int) $elements['new_id'][$key]); + $sql .= " WHERE id = ".((int) $old_id); $sql .= " AND code = '".$db->escape($elements['code'][$key])."'"; $resql = $db->query($sql); if ($resqla && $resql) { foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; - $sql .= " WHERE fk_mode_reglement = ".$old_id; + $sql .= "fk_mode_reglement = ".((int) $elements['new_id'][$key]); + $sql .= " WHERE fk_mode_reglement = ".((int) $old_id); $resql = $db->query($sql); if (!$resql) { @@ -3786,16 +3788,16 @@ function migrate_remise_except_entity($db, $langs, $conf) $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; + $sqlSelect2 .= " WHERE f.rowid = ".((int) $fk_facture); } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; - $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; + $sqlSelect2 .= " WHERE fd.rowid = ".((int) $obj->fk_facture_line); $sqlSelect2 .= " AND fd.fk_facture = f.rowid"; } else { $sqlSelect2 = "SELECT s.entity"; $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect2 .= " WHERE s.rowid = ".$obj->fk_soc; + $sqlSelect2 .= " WHERE s.rowid = ".((int) $obj->fk_soc); } $resql2 = $db->query($sqlSelect2); @@ -4096,6 +4098,11 @@ function migrate_delete_old_dir($db, $langs, $conf) DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', ); + // On linux, we can also removed old directory with a different case than new directory. + if (!empty($_SERVER["WINDIR"])) { + $filetodeletearray[] = DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet'; + } + foreach ($filetodeletearray as $filetodelete) { //print ''.$filetodelete."
    \n"; if (file_exists($filetodelete)) { diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index cd4765161e9..9675d1f3860 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -286,7 +286,7 @@ class IntracommReport extends CommonObject global $mysoc, $conf; if ($type == 'expedition' || $exporttype == 'des') { - $sql = 'SELECT f.ref as refinvoice, f.total as total_ht'; + $sql = 'SELECT f.ref as refinvoice, f.total_ht'; $table = 'facture'; $table_extraf = 'facture_extrafields'; $tabledet = 'facturedet'; @@ -417,7 +417,7 @@ class IntracommReport extends CommonObject ( SELECT fk_product FROM '.MAIN_DB_PREFIX.'categorie_product - WHERE fk_categorie = '.$categ_fraisdeport->id.' + WHERE fk_categorie = '.((int) $categ_fraisdeport->id).' ) )'; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 3785961246e..2f967bc7c29 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -405,6 +405,26 @@ UseMenuToSetBindindManualy=Lines not yet bound, use menu %s to ## Import ImportAccountingEntries=Accounting entries +ImportAccountingEntriesFECFormat=Accounting entries - FEC format +FECFormatJournalCode=Code journal (JournalCode) +FECFormatJournalLabel=Label journal (JournalLib) +FECFormatEntryNum=Piece number (EcritureNum) +FECFormatEntryDate=Piece date (EcritureDate) +FECFormatGeneralAccountNumber=General account number (CompteNum) +FECFormatGeneralAccountLabel=General account label (CompteLib) +FECFormatSubledgerAccountNumber=Subledger account number (CompAuxNum) +FECFormatSubledgerAccountLabel=Subledger account number (CompAuxLib) +FECFormatPieceRef=Piece ref (PieceRef) +FECFormatPieceDate=Piece date creation (PieceDate) +FECFormatLabelOperation=Label operation (EcritureLib) +FECFormatDebit=Debit (Debit) +FECFormatCredit=Credit (Credit) +FECFormatReconcilableCode=Reconcilable code (EcritureLet) +FECFormatReconcilableDate=Reconcilable date (DateLet) +FECFormatValidateDate=Piece date validated (ValidDate) +FECFormatMulticurrencyAmount=Multicurrency amount (Montantdevise) +FECFormatMulticurrencyCode=Multicurrency code (Idevise) + DateExport=Date export WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manually in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. ExpenseReportJournal=Expense Report Journal diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6f7515a01ac..5d78f312917 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1184,7 +1184,8 @@ SetupDescription2=The following two sections are mandatory (the two first entrie SetupDescription3=%s -> %s

    Basic parameters used to customize the default behavior of your application (e.g for country-related features). SetupDescription4=%s -> %s

    This software is a suite of many modules/applications. The modules related to your needs must be enabled and configured. Menu entries will appears with the activation of these modules. SetupDescription5=Other Setup menu entries manage optional parameters. -LogEvents=Security audit events +AuditedSecurityEvents=Security events that are audited +NoSecurityEventsAreAduited=No security events are audited. You can enable them from menu %s Audit=Audit InfoDolibarr=About Dolibarr InfoBrowser=About Browser @@ -1977,7 +1978,7 @@ MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF MAIN_DOCUMENTS_LOGO_HEIGHT=Height for logo on 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') +EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous field was set to Yes.
    For example:
    CODEGRP1+CODEGRP2 SeveralLangugeVariatFound=Several language variants found RemoveSpecialChars=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) @@ -2060,6 +2061,7 @@ UseDebugBar=Use the debug bar DEBUGBAR_LOGS_LINES_NUMBER=Number of last log lines to keep in console WarningValueHigherSlowsDramaticalyOutput=Warning, higher values slows dramaticaly output ModuleActivated=Module %s is activated and slows the interface +ModuleSyslogActivatedButLevelNotTooVerbose=Module %s is activated and log level (%s) is correct (not too verbose) IfYouAreOnAProductionSetThis=If you are on a production environment, you should set this property to %s. AntivirusEnabledOnUpload=Antivirus enabled on uploaded files EXPORTS_SHARE_MODELS=Export models are share with everybody @@ -2085,6 +2087,8 @@ MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax +PDF_SHOW_PROJECT=Show project on document +ShowProjectLabel=Project Label PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled @@ -2111,4 +2115,4 @@ ConfFileIsReadableOrWritableByAnyUsers=The conf file is readable or writable by MailToSendEventOrganization=Event Organization AGENDA_EVENT_DEFAULT_STATUS=Default event status when creating a event from the form YouShouldDisablePHPFunctions=You should disable PHP functions -IfCLINotRequiredYouShouldDisablePHPFunctions=Except if you need to run system commands (for the module Scheduled job for example), you shoud 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 diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index f0f5dfd0a8e..8e2d828c12a 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -174,7 +174,7 @@ YourSEPAMandate=Your SEPA mandate FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Return it signed (scan of the signed document) or send it by mail to AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation CashControl=POS cash desk control -NewCashFence=New cash desk closing +NewCashFence=New cash desk opening or closing BankColorizeMovement=Colorize movements BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements BankColorizeMovementName1=Background color for debit movement diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a1e04809a36..ad1d7f138e5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -52,11 +52,12 @@ Invoices=Invoices InvoiceLine=Invoice line InvoiceCustomer=Customer invoice CustomerInvoice=Customer invoice -CustomersInvoices=Customers invoices +CustomersInvoices=Customer invoices SupplierInvoice=Vendor invoice -SuppliersInvoices=Vendors invoices +SuppliersInvoices=Vendor invoices +SupplierInvoiceLines=Vendor invoice lines SupplierBill=Vendor invoice -SupplierBills=suppliers invoices +SupplierBills=Vendor invoices Payment=Payment PaymentBack=Refund CustomerInvoicePaymentBack=Refund @@ -81,6 +82,8 @@ PaymentsAlreadyDone=Payments already done PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule PaymentMode=Payment Type +DefaultPaymentMode=Default Payment Type +DefaultBankAccount=Default Bank Account PaymentTypeDC=Debit/Credit Card PaymentTypePP=PayPal IdPaymentMode=Payment Type (id) @@ -373,6 +376,7 @@ DateLastGeneration=Date of latest generation DateLastGenerationShort=Date latest gen. MaxPeriodNumber=Max. number of invoice generation NbOfGenerationDone=Number of invoice generation already done +NbOfGenerationOfRecordDone=Number of record generation already done NbOfGenerationDoneShort=Number of generation done MaxGenerationReached=Maximum number of generations reached InvoiceAutoValidate=Validate invoices automatically diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 981b63500ac..4d7ee938c91 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -19,6 +19,7 @@ BoxLastContracts=Latest contracts BoxLastContacts=Latest contacts/addresses BoxLastMembers=Latest members BoxLastModifiedMembers=Latest modified members +BoxLastMembersSubscriptions=Latest member subscriptions BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 42180dde04f..89463a535b3 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -43,9 +43,10 @@ Individual=Private individual ToCreateContactWithSameName=Will automatically create a contact/address with same information as the third party under the third party. In most cases, even if your third party is a physical person, creating a third party alone is enough. ParentCompany=Parent company Subsidiaries=Subsidiaries -ReportByMonth=Report by month -ReportByCustomers=Report by customer -ReportByQuarter=Report by rate +ReportByMonth=Report per month +ReportByCustomers=Report per customer +ReportByThirdparties=Report per thirdparty +ReportByQuarter=Report per rate CivilityCode=Civility code RegisteredOffice=Registered office Lastname=Last name @@ -180,6 +181,12 @@ ProfId3FR=Prof Id 3 (NAF, old APE) ProfId4FR=Prof Id 4 (RCS/RM) ProfId5FR=Prof Id 5 (numéro EORI) ProfId6FR=- +ProfId1ShortFR=SIREN +ProfId2ShortFR=SIRET +ProfId3ShortFR=NAF +ProfId4ShortFR=RCS +ProfId5ShortFR=EORI +ProfId6ShortFR=- ProfId1GB=Registration Number ProfId2GB=- ProfId3GB=SIC diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 3f892e3b29c..7080810bfea 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -86,7 +86,7 @@ PaymentCustomerInvoice=Customer invoice payment PaymentSupplierInvoice=vendor invoice payment PaymentSocialContribution=Social/fiscal tax payment PaymentVat=VAT payment -AutomaticCreationPayment=Automatically record the payment of the salary +AutomaticCreationPayment=Automatically record the payment ListPayment=List of payments ListOfCustomerPayments=List of customer payments ListOfSupplierPayments=List of vendor payments @@ -175,6 +175,7 @@ RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT RulesCADue=- It includes the customer's due invoices whether they are paid or not.
    - It is based on the billing date of these invoices.
    RulesCAIn=- It includes all the effective payments of invoices received from customers.
    - It is based on the payment date of these invoices
    RulesCATotalSaleJournal=It includes all credit lines from the Sale journal. +RulesSalesTurnoverOfIncomeAccounts=It includes (credit - debit) of lines for product accounts in group INCOME RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts grouped by personalized groups @@ -280,6 +281,7 @@ PurchaseTurnoverCollected=Purchase turnover collected RulesPurchaseTurnoverDue=- It includes the supplier's due invoices whether they are paid or not.
    - It is based on the invoice date of these invoices.
    RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices done to suppliers.
    - It is based on the payment date of these invoices
    RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal. +RulesPurchaseTurnoverOfExpenseAccounts=It includes (debit - credit) of lines for product accounts in group EXPENSE ReportPurchaseTurnover=Purchase turnover invoiced ReportPurchaseTurnoverCollected=Purchase turnover collected IncludeVarpaysInResults = Include various payments in reports diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 71df60734fb..2bac434deb0 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -41,3 +41,7 @@ FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload ExtraFieldsEcmFiles=Extrafields Ecm Files ExtraFieldsEcmDirectories=Extrafields Ecm Directories ECMSetup=ECM Setup +GenerateImgWebp=Convert all images into webp +ConfirmGenerateImgWebp=If you confirm, you will generate all images in this folder and subfolder in webp format... +ConfirmImgWebpCreation=Confirm all images convertion +SucessConvertImgWebp=Images successfully converted diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index bb5e7c5e287..002aa63fa62 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -293,4 +293,6 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. -WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. \ No newline at end of file +WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. +ErrorActionCommPropertyUserowneridNotDefined=User's owner is required +ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 5444ed59e3d..c0ff5e8e281 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -32,8 +32,8 @@ EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth EventOrganizationSetup = Event Organization setup Settings = Settings EventOrganizationSetupPage = Event Organization setup page -EVENTORGANIZATION_TASK_LABEL = Task label created when validate -EVENTORGANIZATION_TASK_LABELTooltip = When validate a Conference or a booth, some tasks will be created in the project

    for example:
    Send Call for Conference
    Send Call for Booth
    Receive call for conferences
    Receive call for Booth
    Open subscriptions to events for attendees
    Send remind of event to speakers
    Send remind of event to Booth hoster
    Send remind of event to attendees +EVENTORGANIZATION_TASK_LABEL = Label of tasks to create automatically when project is validated +EVENTORGANIZATION_TASK_LABELTooltip = When you validate an organized event, some tasks can be automatically created in the project

    For example:
    Send Call for Conference
    Send Call for Booth
    Receive call for conferences
    Receive call for Booth
    Open subscriptions to events for attendees
    Send remind of event to speakers
    Send remind of event to Booth hoster
    Send remind of event to attendees EVENTORGANIZATION_CATEG_THIRDPARTY_CONF = Category to add to third-parties automatically created when someone suggests a conference EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH = Category to add to third-parties automatically created when they suggests a booth EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF = Template of email to send after receiving a suggestion of a conference. @@ -42,6 +42,8 @@ EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH = Template of email to send aft EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT = Template of email to send after a subscription to an event has been paid. EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER = Template of email of massaction to attendes EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES = Template of email of massaction to speakers +EVENTORGANIZATION_FILTERATTENDEES_CAT = Filter thirdpartie's select list in attendees creation card/form with category +EVENTORGANIZATION_FILTERATTENDEES_TYPE = Filter thirdpartie's select list in attendees creation card/form with customer type # # Object @@ -50,6 +52,9 @@ EventOrganizationConfOrBooth= Conference Or Booth ManageOrganizeEvent = Manage event organisation ConferenceOrBooth = Conference Or Booth ConferenceOrBoothTab = Conference Or Booth +AmountOfSubscriptionPaid = Amount of subscription paid +DateSubscription = Date of subscription +ConferenceOrBoothAttendee = Conference Or Booth Attendee # # Template Mail @@ -60,7 +65,7 @@ EventOrganizationEmailAskConf = Request for conference EventOrganizationEmailAskBooth = Request for booth EventOrganizationEmailSubsBooth = Subscription for booth EventOrganizationEmailSubsEvent = Subscription for an event -EventOrganizationMassEmailAttendees = Communication to attendes +EventOrganizationMassEmailAttendees = Communication to attendees EventOrganizationMassEmailSpeakers = Communication to speakers # @@ -72,10 +77,11 @@ AllowUnknownPeopleSuggestBooth=Allow unknown people to suggest booth AllowUnknownPeopleSuggestBoothHelp=Allow unknown people to suggest booth PriceOfRegistration=Price of registration PriceOfRegistrationHelp=Price of registration -PriceOfBooth=Price of subscription -PriceOfBoothHelp=Price of subscription +PriceOfBooth=Subscription price to stand a booth +PriceOfBoothHelp=Subscription price to stand a booth EventOrganizationICSLink=Link ICS for events - +ConferenceOrBoothInformation=Conference Or Booth informations +Attendees = Attendees # # Status # diff --git a/htdocs/langs/en_US/externalsite.lang b/htdocs/langs/en_US/externalsite.lang index da4853df0df..452100c65b3 100644 --- a/htdocs/langs/en_US/externalsite.lang +++ b/htdocs/langs/en_US/externalsite.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - externalsite ExternalSiteSetup=Setup link to external website -ExternalSiteURL=External Site URL +ExternalSiteURL=External Site URL of HTML iframe content ExternalSiteModuleNotComplete=Module ExternalSite was not configured properly. ExampleMyMenuEntry=My menu entry diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e27ec6d9c43..dc2a83f2015 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -278,6 +278,7 @@ DateModificationShort=Modif. date IPModification=Modification IP DateLastModification=Latest modification date DateValidation=Validation date +DateSigning=Signing date DateClosing=Closing date DateDue=Due date DateValue=Value date @@ -1060,6 +1061,7 @@ YouAreCurrentlyInSandboxMode=You are currently in the %s "sandbox" mode Inventory=Inventory AnalyticCode=Analytic code TMenuMRP=MRP +ShowCompanyInfos=Show company infos ShowMoreInfos=Show More Infos NoFilesUploadedYet=Please upload a document first SeePrivateNote=See private note diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 76ea8ad5c4d..ad5406409b4 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -22,7 +22,7 @@ ProductService=Product or Service AllProducts=All products and services ChooseProduct/Service=Choose product or service ForceBuyingPriceIfNull=Force buying/cost price to selling price if not defined -ForceBuyingPriceIfNullDetails=If buying/cost price not defined, and this option "ON", margin will be zero on line (buying/cost price = selling price), otherwise ("OFF"), marge will be equal to suggested default. +ForceBuyingPriceIfNullDetails=If buying/cost price not provided when we add a new line, and this option is "ON", the margin will be 0 on the new line (buying/cost price = selling price). If this option is "OFF" (recommended), margin will be equal to the value suggested by default (and may be 100% if no default value can be found). MARGIN_METHODE_FOR_DISCOUNT=Margin method for global discounts UseDiscountAsProduct=As a product UseDiscountAsService=As a service diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 31d0790b331..7f36f759bb1 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -169,6 +169,7 @@ DocForLabels=Generate address sheets SubscriptionPayment=Subscription payment LastSubscriptionDate=Date of latest subscription payment LastSubscriptionAmount=Amount of latest subscription +LastMemberType=Last Member type MembersStatisticsByCountries=Members statistics by country MembersStatisticsByState=Members statistics by state/province MembersStatisticsByTown=Members statistics by town diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 845dd12624d..19afb9d95ab 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -133,7 +133,9 @@ IncludeDocGeneration=I want to generate some documents from the object IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record. ShowOnCombobox=Show value into combobox KeyForTooltip=Key for tooltip -CSSClass=CSS Class +CSSClass=CSS for edit/create form +CSSViewClass=CSS for read form +CSSListClass=CSS for list NotEditable=Not editable ForeignKey=Foreign key TypeOfFieldsHelp=Type of fields:
    varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]] ('1' means we add a + button after the combo to create the record, 'filter' can be 'status=1 AND fk_user = __USER_ID AND entity IN (__SHARED_ENTITIES__)' for example) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index ad91e1eef63..87d196eb22f 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -16,6 +16,8 @@ ToOrder=Make order MakeOrder=Make order SupplierOrder=Purchase order SuppliersOrders=Purchase orders +SaleOrderLines=Sale order lines +PurchaseOrderLines=Puchase order lines SuppliersOrdersRunning=Current purchase orders CustomerOrder=Sales Order CustomersOrders=Sales Orders diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 7a895bb1ca5..5ae6c7727b3 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -114,6 +114,7 @@ DemoCompanyAll=Company with multiple activities (all main modules) CreatedBy=Created by %s ModifiedBy=Modified by %s ValidatedBy=Validated by %s +SignedBy=Signed by %s ClosedBy=Closed by %s CreatedById=User id who created ModifiedById=User id who made latest change diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 36adfd571fb..ad2051ca30a 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -25,4 +25,7 @@ ShowCurrentStockOfLot=Show current stock for couple product/lot ShowLogOfMovementIfLot=Show log of movements for couple product/lot StockDetailPerBatch=Stock detail per lot SerialNumberAlreadyInUse=Serial number %s is already used for product %s -TooManyQtyForSerialNumber=You can only have one product %s for serial number %S +TooManyQtyForSerialNumber=You can only have one product %s for serial number %s +BatchLotNumberingModules=Options for automatic generation of batch products managed by lots +BatchSerialNumberingModules=Options for automatic generation of batch products managed by serial numbers +QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned \ No newline at end of file diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 557df2f840f..edbc08236d3 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -59,6 +59,7 @@ ConfirmClonePropal=Are you sure you want to clone the commercial proposal %s< ConfirmReOpenProp=Are you sure you want to open back the commercial proposal %s? ProposalsAndProposalsLines=Commercial proposal and lines ProposalLine=Proposal line +ProposalLines=Proposal lines AvailabilityPeriod=Availability delay SetAvailability=Set availability delay AfterOrder=after order diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 4585841911b..eb238941eae 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -62,6 +62,7 @@ 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 RuleForWarehouse=Rule for warehouses +WarehouseAskWarehouseOnThirparty=Set a warehouse on third-party WarehouseAskWarehouseDuringPropal=Set a warehouse on Commercial proposals WarehouseAskWarehouseDuringOrder=Set a warehouse on Sale orders UserDefaultWarehouse=Set a warehouse on Users @@ -106,7 +107,7 @@ LieuWareHouse=Localisation warehouse WarehousesAndProducts=Warehouses and products WarehousesAndProductsBatchDetail=Warehouses and products (with detail per lot/serial) AverageUnitPricePMPShort=Weighted average price -AverageUnitPricePMPDesc=The input average unit price we had to pay to suppliers to get the product into our stock. +AverageUnitPricePMPDesc=The input average unit price we had to expense to get 1 unit of product into our stock. SellPriceMin=Selling Unit Price EstimatedStockValueSellShort=Value for sell EstimatedStockValueSell=Value for sell @@ -184,6 +185,7 @@ inventoryCreatePermission=Create new inventory inventoryReadPermission=View inventories inventoryWritePermission=Update inventories inventoryValidatePermission=Validate inventory +inventoryDeletePermission=Delete inventory inventoryTitle=Inventory inventoryListTitle=Inventories inventoryListEmpty=No inventory in progress @@ -239,7 +241,17 @@ StockAtDatePastDesc=You can view here the stock (real stock) at a given date in StockAtDateFutureDesc=You can view here the stock (virtual stock) at a given date in future CurrentStock=Current stock InventoryRealQtyHelp=Set value to 0 to reset qty
    Keep field empty, or remove line, to keep unchanged -UpdateByScaning=Update by scaning +UpdateByScaning=Fill real qty by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) -DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. \ No newline at end of file +DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. +ImportFromCSV=Import CSV list of movement +ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... +SelectAStockMovementFileToImport=select a stock movement file to import +InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
    Source Warehouse* | Target Warehouse* | Product* | Quantity* | Lot/serial number
    CSV character separator must be "%s" +LabelOfInventoryMovemement=Inventory %s +ReOpen=Reopen +ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock. +ObjectNotFound=%s not found +MakeMovementsAndClose=Generate movements and close +AutofillWithExpected=Fill real quantity with expected quantity \ No newline at end of file diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 03b03c75269..ca9ee174d29 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -1,6 +1,7 @@ # Dolibarr language file - Source file is en_US - vendors Suppliers=Vendors SuppliersInvoice=Vendor invoice +SupplierInvoices=Vendor invoices ShowSupplierInvoice=Show Vendor Invoice NewSupplier=New vendor History=History diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 93f55289351..50fa8c970ae 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -70,6 +70,8 @@ Deleted=Deleted # Dict Type=Type Severity=Severity +TicketGroupIsPublic=Group is public +TicketGroupIsPublicDesc=If a ticket group is public, it will be visible in the form when creating a ticket from the public interface # Email templates MailToSendTicketMessage=To send email from ticket message @@ -114,8 +116,8 @@ TicketsShowModuleLogo=Display the logo of the module in the public interface TicketsShowModuleLogoHelp=Enable this option to hide the logo module in the pages of the public interface TicketsShowCompanyLogo=Display the logo of the company in the public interface TicketsShowCompanyLogoHelp=Enable this option to hide the logo of the main company in the pages of the public interface -TicketsEmailAlsoSendToMainAddress=Also send notification to main email address -TicketsEmailAlsoSendToMainAddressHelp=Enable this option to send an email to "Notification email from" address (see setup below) +TicketsEmailAlsoSendToMainAddress=Also send a notification to the main email address +TicketsEmailAlsoSendToMainAddressHelp=Enable this option to also send an email to the address defined into setup "%s" (see tab "%s") TicketsLimitViewAssignedOnly=Restrict the display to tickets assigned to the current user (not effective for external users, always be limited to the third party they depend on) TicketsLimitViewAssignedOnlyHelp=Only tickets assigned to the current user will be visible. Does not apply to a user with tickets management rights. TicketsActivatePublicInterface=Activate public interface @@ -126,10 +128,10 @@ TicketNumberingModules=Tickets numbering module TicketsModelModule=Document templates for tickets TicketNotifyTiersAtCreation=Notify third party at creation TicketsDisableCustomerEmail=Always disable emails when a ticket is created from public interface -TicketsPublicNotificationNewMessage=Send email(s) when a new message is added +TicketsPublicNotificationNewMessage=Send email(s) when a new message/comment is added to a ticket TicketsPublicNotificationNewMessageHelp=Send email(s) when a new message is added from public interface (to assigned user or the notifications email to (update) and/or the notifications email to) TicketPublicNotificationNewMessageDefaultEmail=Notifications email to (update) -TicketPublicNotificationNewMessageDefaultEmailHelp=Send email new message notifications to this address if the ticket don't have a user assigned or the user don't have a email. +TicketPublicNotificationNewMessageDefaultEmailHelp=Send an email to this address for each new message notifications if the ticket doesn't have a user assigned to it or if the user doesn't have any known email. # # Index & list page # diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index d4326fc08c9..727773a9606 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -72,7 +72,7 @@ ExportDataset_user_1=Users and their properties DomainUser=Domain user %s Reactivate=Reactivate CreateInternalUserDesc=This form allows you to create an internal user in your company/organization. To create an external user (customer, vendor etc. ..), use the button 'Create Dolibarr User' from that third-party's contact card. -InternalExternalDesc=An internal user is a user that is part of your company/organization.
    An external user is a customer, vendor or other that must view only data related to himself (Creating an external user for a third-party can be done from the contact record of the third-party).

    In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display) +InternalExternalDesc=An internal user is a user that is part of your company/organization, or is a partner user outside of your organization that may need to see more data than data related to his company (the permission system will define what he can or can't see or do).
    An external user is a customer, vendor or other that must view ONLY data related to himself (Creating an external user for a third-party can be done from the contact record of the third-party).

    In both cases, you must grant permissions on the features that the user need. PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group. Inherited=Inherited UserWillBe=Created user will be diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index c23f4425dca..2cf823089e9 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -141,3 +141,11 @@ GenerateSitemaps=Generate website sitemap file ConfirmGenerateSitemaps=If you confirm, you will erase the existing sitemap file... ConfirmSitemapsCreation=Confirm sitemap generation SitemapGenerated=Sitemap Generated +ImportFavicon=Favicon +ErrorFaviconType=Favicon must be png +ErrorFaviconSize=Favicon must be of size 32x32 +FaviconTooltip=Upload an image which needs to be a png of 32x32 +GenerateImgWebp=Convert all images into webp +ConfirmGenerateImgWebp=If you confirm, you will generate all website's images in webp format... +ConfirmImgWebpCreation=Confirm all images convertion +SucessConvertImgWebp=Images successfully converted diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 639428eac1d..ef48fc0a82d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1786,6 +1786,7 @@ ApiSetup=Configuration du module API REST ApiDesc=En activant ce module, Dolibarr devient aussi serveur de services API de type REST ApiProductionMode=Activer le mode « production » (ceci activera l'utilisation du cache pour la gestion des services) ApiExporerIs=Vous pouvez explorer et tester les API par l'URL +SwaggerDescriptionFile=Swagger JSON description file of APIs OnlyActiveElementsAreExposed=Seuls les éléments en rapport avec un module actif sont présentés. ApiKey=Clé pour l'API WarningAPIExplorerDisabled=L'explorateur d'API est désactivé. L'explorateur d'API n'est pas nécessaire pour le fonctionnement des API. il s'agit d'un outil pour les développeurs pour en tester les services. Si cet outil vous est nécessaire, activez le module API REST dans la liste des modules. diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index b5588c21df3..342924e1680 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -464,6 +464,7 @@ PaymentByChequeOrderedToShort=Règlement TTC par chèque à l'ordre de SendTo=envoyé à PaymentByTransferOnThisBankAccount=Règlement par virement sur le compte bancaire suivant VATIsNotUsedForInvoice=* TVA non applicable art-293B du CGI +VATIsNotUsedForInvoiceAsso=* TVA non applicable art-261-7 du CGI LawApplicationPart1=Par application de la loi 80.335 du 12/05/80 LawApplicationPart2=les marchandises demeurent la propriété du LawApplicationPart3=vendeur jusqu'à complet encaissement de diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 86ba2247682..a8b13c7e914 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -278,6 +278,7 @@ DateModificationShort=Date modif. IPModification=Modification IP DateLastModification=Date de dernière modification DateValidation=Date validation +DateSigning=Date signature DateClosing=Date clôture DateDue=Date échéance DateValue=Date valeur diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index ea52dc21d7a..a541c347adb 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -162,6 +162,7 @@ DocForLabels=Génération d'étiquettes d'adresses SubscriptionPayment=Paiement cotisation LastSubscriptionDate=Date de dernière adhésion LastSubscriptionAmount=Montant dernière adhésion +LastMemberType=Ancien type de membre MembersStatisticsByCountries=Statistiques des membres par pays MembersStatisticsByState=Statistiques des membres par département/province/canton MembersStatisticsByTown=Statistiques des membres par ville diff --git a/htdocs/langs/fr_FR/modulebuilder.lang b/htdocs/langs/fr_FR/modulebuilder.lang index 15d87656f4b..d2bce2082cb 100644 --- a/htdocs/langs/fr_FR/modulebuilder.lang +++ b/htdocs/langs/fr_FR/modulebuilder.lang @@ -92,6 +92,7 @@ SearchAllDesc=Le champ doit-il être utilisé pour effectuer une recherche à pa SpecDefDesc=Entrez ici toute la documentation que vous souhaitez joindre au module et qui n'a pas encore été définis dans d'autres onglets. Vous pouvez utiliser .md ou, mieux, la syntaxe enrichie .asciidoc. LanguageDefDesc=Entrez dans ces fichiers, toutes les clés et la traduction pour chaque fichier de langue. MenusDefDesc=Définissez ici les menus fournis par votre module +ImportExportProfiles=You will find here the Export or Import profiles provided by your module DictionariesDefDesc=Définissez ici les dictionnaires fournis par le module PermissionsDefDesc=Définissez ici les nouvelles permissions fournies par votre module MenusDefDescTooltip=Les menus fournis par votre module / application sont définis dans le tableau $this->menus dans le fichier descripteur de module. Vous pouvez modifier manuellement ce fichier ou utiliser l'éditeur intégré.

    Remarque: une fois définis (et les modules réactivés), les menus sont également visibles dans l'éditeur de menus mis à la disposition des utilisateurs administrateurs sur %s. diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 3023cd7216e..a8078129464 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -114,6 +114,7 @@ DemoCompanyAll=Société avec de multiples activités (tous les modules principa CreatedBy=Créé par %s ModifiedBy=Modifié par %s ValidatedBy=Validé par %s +SignedBy=Signé par %s ClosedBy=Clôturé par %s CreatedById=Id utilisateur créateur ModifiedById=Id utilisateur du dernier changement diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 94ceb434bfd..eed5a063318 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -26,3 +26,5 @@ ShowLogOfMovementIfLot=Afficher l'historique des mouvements de couple produit / StockDetailPerBatch=Stock détaillé par lot SerialNumberAlreadyInUse=Le numéro de série %s est déjà utilisé pour le produit %s TooManyQtyForSerialNumber=Vous ne pouvez avoir qu'un produit %s avec le numéro de série %s +BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lot +BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série \ No newline at end of file diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index c29c3b26d82..2d2be548f3b 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -62,6 +62,7 @@ EnhancedValueOfWarehouses=Valorisation des stocks UserWarehouseAutoCreate=Créer automatiquement un stock/entrepôt propre à l'utilisateur lors de sa création AllowAddLimitStockByWarehouse=Gérez également les valeurs des stocks minimums et souhaités par paire (produit-entrepôt) en plus des valeurs de minimums et souhaités par produit RuleForWarehouse=Règle pour les entrepôts +WarehouseAskWarehouseOnThirparty=Définir un entrepôt sur les tiers WarehouseAskWarehouseDuringPropal=Définir un entrepôt sur les propositions WarehouseAskWarehouseDuringOrder=Définir un entrepôt sur les commandes UserDefaultWarehouse=Définir un entrepôt sur les utilisateurs diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 5c6260dec84..19763c0a924 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -37,11 +37,11 @@ if (!defined('NOREQUIREAJAX')) { require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; -$mens = GETPOST('mens'); -$capital = GETPOST('capital'); -$rate = GETPOST('rate'); -$echance = GETPOST('echeance'); -$nbterm = GETPOST('nbterm'); +$mens = price2num(GETPOST('mens')); +$capital = price2num(GETPOST('capital')); +$rate = price2num(GETPOST('rate')); +$echance = GETPOST('echeance', 'int'); +$nbterm = GETPOST('nbterm', 'int'); top_httphead(); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 9e9e1a0a992..c3c08b6cf2f 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -636,7 +636,7 @@ if ($id > 0) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; $sql .= ", ".MAIN_DB_PREFIX."loan as l"; - $sql .= " WHERE p.fk_loan = ".$id; + $sql .= " WHERE p.fk_loan = ".((int) $id); $sql .= " AND p.fk_loan = l.rowid"; $sql .= " AND l.entity IN ( ".getEntity('loan').")"; $sql .= " ORDER BY dp DESC"; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index bc819f747ca..54d4607ab70 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -447,7 +447,7 @@ class LoanSchedule extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " WHERE t.fk_loan = ".$loanid; + $sql .= " WHERE t.fk_loan = ".((int) $loanid); dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); @@ -535,7 +535,7 @@ class LoanSchedule extends CommonObject { $sql = "SELECT p.datep"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p "; - $sql .= " WHERE p.fk_loan = ".$loanid; + $sql .= " WHERE p.fk_loan = ".((int) $loanid); $sql .= " ORDER BY p.datep DESC "; $sql .= " LIMIT 1 "; @@ -563,7 +563,7 @@ class LoanSchedule extends CommonObject $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; - $sql .= " WHERE p.fk_loan = ".$loanid; + $sql .= " WHERE p.fk_loan = ".((int) $loanid); if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; } diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index c7f1940943b..cf0a8e87f63 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -594,12 +594,12 @@ class PaymentLoan extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->fk_bank = $id_bank; + $this->fk_bank = ((int) $id_bank); return 1; } else { $this->error = $this->db->error(); diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 9040d140149..fa1de74b0cc 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -252,7 +252,7 @@ if ($resql) { print '
    '; // Capital - print ''; + print ''; // Date start print ''; diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index cf4466bb0da..675401e34f9 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -58,7 +58,7 @@ if ($id > 0) { if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) { $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank; + $sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".((int) $payment->fk_bank); $db->query($sql); $fk_loan = $payment->fk_loan; @@ -66,7 +66,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del $result = $payment->delete($user); if ($result > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan); + header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".urlencode($fk_loan)); exit; } else { setEventMessages($payment->error, $payment->errors, 'errors'); diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index eec24d9b3e2..58783be181e 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -239,7 +239,7 @@ if ($action == 'create') { $sql = "SELECT SUM(amount_capital) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan"; - $sql .= " WHERE fk_loan = ".$chid; + $sql .= " WHERE fk_loan = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 94c90c226e1..61879dbeb87 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -12,8 +12,9 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Demarest Maxime - * Copyright (C) 2020 Charlene Benke + * Copyright (C) 2020 Charlene Benke * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021 Alexandre Spangaro * * 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 @@ -55,7 +56,7 @@ if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) { * only be guaranted by escaping data during output. * * @param string $val Value brut found int $_GET, $_POST or PHP_SELF - * @param string $type 1=GET, 0=POST, 2=PHP_SELF, 3=GET without sql reserved keywords (the less tolerant test) + * @param string $type 0=POST, 1=GET, 2=PHP_SELF, 3=GET without sql reserved keywords (the less tolerant test) * @return int >0 if there is an injection, 0 if none */ function testSqlAndScriptInject($val, $type) @@ -149,7 +150,7 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/"/i', $val); // We refused " in GET parameters value. } if ($type == 2) { - $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces. + $inj += preg_match('/[:;"\'<>\?\(\){}\$%]/', $val); // PHP_SELF is a file system (or url path without parameters). It can contains spaces. } return $inj; @@ -434,16 +435,16 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl // Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request) $arrayofactiontoforcetokencheck = array( 'activate', 'add', 'addtimespent', 'update', 'install', - 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_reject_check', + 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_purge', 'confirm_reject_check', 'delete', 'deletefilter', 'deleteoperation', 'deleteprof', 'deletepayment', 'disable', 'doprev', 'donext', 'dvprev', 'dvnext', - 'enable' + 'enable', 'setpricelevel' ); $sensitiveget = false; if (in_array(GETPOST('action', 'aZ09'), $arrayofactiontoforcetokencheck)) { $sensitiveget = true; } - if (preg_match('/^(disable_|enable_)/', GETPOST('action', 'aZ09'))) { + if (preg_match('/^(disable_|enable_|setremise)/', GETPOST('action', 'aZ09'))) { $sensitiveget = true; } @@ -455,13 +456,13 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl ) { if (!GETPOST('token', 'alpha')) { // If token is not provided or empty if (GETPOST('uploadform', 'int')) { - dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused. File size too large."); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large."); $langs->loadLangs(array("errors", "install")); print $langs->trans("ErrorFileSizeTooLarge").' '; print $langs->trans("ErrorGoBackAndCorrectParameters"); die; } else { - dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided.", LOG_WARNING); if (defined('CSRFCHECK_WITH_TOKEN')) { print "Access to a page that needs a token (constant CSRFCHECK_WITH_TOKEN is defined) is refused by CSRF protection in main.inc.php. Token not provided.\n"; } else { @@ -476,7 +477,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); // TODO Get the sessiontokenforthisurl into the array of session token if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { - dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused due to invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused due to invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); //if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."
    \n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings'); @@ -741,7 +742,7 @@ if (!defined('NOLOGIN')) { // End test login / passwords if (!$login || (in_array('ldap', $authmode) && empty($passwordtotest))) { // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success. // No data to test login, so we show the login page. - dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09')." - actionlogin=".GETPOST('actionlogin', 'aZ09')." - showing the login form and exit"); + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." - action=".GETPOST('action', 'aZ09')." - actionlogin=".GETPOST('actionlogin', 'aZ09')." - showing the login form and exit", LOG_INFO); if (defined('NOREDIRECTBYMAINTOLOGIN')) { return 'ERROR_NOT_LOGGED'; } else { @@ -1110,7 +1111,7 @@ if (!defined('NOLOGIN')) { $user->getrights(); } -dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').' NOTOKENRENEWAL='.(defined('NOTOKENRENEWAL') ?constant('NOTOKENRENEWAL') : '')); +dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').(defined('NOTOKENRENEWAL') ? ' NOTOKENRENEWAL='.constant('NOTOKENRENEWAL') : ''), LOG_NOTICE); //Another call for easy debugg //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' '.$_SERVER["HTTP_REFERER"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); @@ -1981,6 +1982,20 @@ function top_menu_user($hideloginname = 0, $urllogout = '') } $dropdownBody = ''; + $dropdownBody .= ' '.$langs->trans("ShowCompanyInfos").''; + $dropdownBody .= '
    '; + + if (!empty($conf->global->MAIN_INFO_SIREN)) $dropdownBody .= '
    '.$langs->transcountry("ProfId1Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIREN).''; + if (!empty($conf->global->MAIN_INFO_SIRET)) $dropdownBody .= '
    '.$langs->transcountry("ProfId2Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_SIRET).''; + if (!empty($conf->global->MAIN_INFO_APE)) $dropdownBody .= '
    '.$langs->transcountry("ProfId3Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_APE).''; + if (!empty($conf->global->MAIN_INFO_RCS)) $dropdownBody .= '
    '.$langs->transcountry("ProfId4Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_RCS).''; + if (!empty($conf->global->MAIN_INFO_PROFID5)) $dropdownBody .= '
    '.$langs->transcountry("ProfId5Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID5).''; + if (!empty($conf->global->MAIN_INFO_PROFID6)) $dropdownBody .= '
    '.$langs->transcountry("ProfId6Short", $mysoc->country_code).': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_PROFID6).''; + if (!empty($conf->global->MAIN_INFO_TVAINTRA)) $dropdownBody .= '
    '.$langs->trans("VATIntraShort").': '.showValueWithClipboardCPButton($conf->global->MAIN_INFO_TVAINTRA).''; + + $dropdownBody .= '
    '; + + $dropdownBody .= '
    '; $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; $dropdownBody .= '
    '; @@ -2073,8 +2088,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $btnUser = '
    '; print "\n"; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index f61d8d02e55..d12c827cc3e 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -209,12 +209,12 @@ $massactionbutton = ''; $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED); $sql = "SELECT"; -$sql .= " f.ref, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; -$sql .= " ,d.fk_product"; +$sql .= " f.ref, f.rowid as invoiceid,"; +$sql .= " d.rowid as invoicedetid, d.product_type, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description, d.qty, d.fk_product"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f "; -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowid"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; -$sql .= " WHERE f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; +$sql .= " WHERE f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")"; $sql .= " AND f.entity IN (".getEntity('invoice').") "; if (!empty($startdate)) { $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; @@ -279,12 +279,12 @@ if ($result) { print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "d.subprice", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], "d.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $i = 0; @@ -309,6 +309,12 @@ if ($result) { print $productstatic->getNomUrl(1); } } else { + if ($objp->product_type == $productstatic::TYPE_PRODUCT) { + print img_picto('', 'product'); + } + if ($objp->product_type == $productstatic::TYPE_SERVICE) { + print img_picto('', 'service'); + } print $objp->label; print ' '; print $objp->description; @@ -324,7 +330,7 @@ if ($result) { print $objp->qty; print ''; print ''; print ''; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 05d5aa1ca5c..67639acb745 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -216,7 +216,7 @@ $invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABAND $sql = "SELECT"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; if ($client) { - $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; } $sql .= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this) @@ -239,16 +239,16 @@ if ($socid > 0) { if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; +$sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")"; $sql .= ' AND s.entity IN ('.getEntity('societe').')'; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND (d.product_type = 0 OR d.product_type = 1)"; if (!empty($TSelectedProducts)) { - $sql .= ' AND d.fk_product IN ('.implode(',', $TSelectedProducts).')'; + $sql .= ' AND d.fk_product IN ('.$db->sanitize(implode(',', $TSelectedProducts)).')'; } if (!empty($TSelectedCats)) { - $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; + $sql .= ' AND cp.fk_categorie IN ('.$db->sanitize(implode(',', $TSelectedCats)).')'; } if (!empty($startdate)) { $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; @@ -257,11 +257,13 @@ if (!empty($enddate)) { $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; } $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { +// We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report. +// We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredicable. +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 2) { $sql .= " AND d.buy_price_ht <> 0"; } if ($client) { - $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; + $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut"; } else { $sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; } @@ -342,9 +344,9 @@ if ($result) { print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 0ac47243723..f18cc4ee503 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -179,7 +179,7 @@ if ($id > 0) { $sql .= " d.fk_product,"; } if ($id > 0) { - $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut as statut,"; } $sql .= " SUM(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) @@ -195,13 +195,13 @@ if (!empty($TSelectedCats)) { } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; -$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")"; +$sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")"; $sql .= " AND d.fk_facture = f.rowid"; if ($id > 0) { $sql .= " AND d.fk_product =".$id; } if (!empty($TSelectedCats)) { - $sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')'; + $sql .= ' AND cp.fk_categorie IN ('.$db->sanitize(implode(',', $TSelectedCats)).')'; } if (!empty($startdate)) { $sql .= " AND f.datef >= '".$db->idate($startdate)."'"; @@ -210,11 +210,13 @@ if (!empty($enddate)) { $sql .= " AND f.datef <= '".$db->idate($enddate)."'"; } $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { +// We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report. +// We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredicable. +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 2) { $sql .= " AND d.buy_price_ht <> 0"; } if ($id > 0) { - $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut"; + $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut"; } else { $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; } @@ -308,9 +310,9 @@ if ($result) { //print "\n"; } print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 031c49e4cd0..4c34e04c54c 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -76,18 +76,18 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $title = $langs->trans('ProductServiceCard'); - $helpurl = ''; + $help_url = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } - llxHeader('', $title, $helpurl); + llxHeader('', $title, $help_url); /* * En mode visu @@ -137,7 +137,7 @@ if ($id > 0 || !empty($ref)) { if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; - $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; @@ -164,10 +164,12 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND f.fk_soc = $socid"; } $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + // We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report. + // We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredicable. + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 2) { $sql .= " AND d.buy_price_ht <> 0"; } - $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user"; } diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 0103bd03aca..b7970a58c80 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -160,7 +160,7 @@ if ($socid > 0) { print '
    '; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; - $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.rowid as facid, f.ref, f.total_ht,"; $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive $sql .= " sum(d.qty * d.buy_price_ht * (d.situation_percent / 100)) as buying_price,"; // always positive @@ -174,10 +174,12 @@ if ($socid > 0) { $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND f.fk_soc = $socid"; $sql .= " AND d.buy_price_ht IS NOT NULL"; - if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) { + // We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report. + // We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredicable. + if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 2) { $sql .= " AND d.buy_price_ht <> 0"; } - $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total_ht, f.datef, f.paye, f.fk_statut, f.type"; $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); diff --git a/htdocs/modulebuilder/admin/index.html b/htdocs/modulebuilder/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/admin/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/admin/setup.php b/htdocs/modulebuilder/admin/setup.php index e9e3ea752f5..62eccc5be18 100644 --- a/htdocs/modulebuilder/admin/setup.php +++ b/htdocs/modulebuilder/admin/setup.php @@ -33,9 +33,11 @@ if (!$user->admin || empty($conf->modulebuilder->enabled)) { $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); + /* * Actions */ + if ($action == "update") { $res1 = dolibarr_set_const($db, 'MODULEBUILDER_SPECIFIC_README', GETPOST('MODULEBUILDER_SPECIFIC_README', 'restricthtml'), 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'MODULEBUILDER_ASCIIDOCTOR', GETPOST('MODULEBUILDER_ASCIIDOCTOR', 'nohtml'), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/modulebuilder/index.html b/htdocs/modulebuilder/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 101aa6db09c..572fff42369 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -746,7 +746,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', * 'position' is the sort order of field. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' * 'help' is a string visible as a tooltip on field * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record @@ -1212,7 +1212,7 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && } } -if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { +if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) && !empty($tabobj)) { $error = 0; $objectname = $tabobj; @@ -1245,7 +1245,8 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' 'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'), 'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'), - 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha') + 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha'), + 'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09') ); if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { @@ -1295,6 +1296,9 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) { $objectname = $tabobj; + $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; + $moduletype = $listofmodules[strtolower($module)]['moduletype']; + $srcdir = $dirread.'/'.strtolower($module); $destdir = $dirins.'/'.strtolower($module); dol_mkdir($destdir); @@ -1708,10 +1712,9 @@ $head[$h][2] = 'initmodule'; $h++; $linktoenabledisable = ''; -$modulestatusinfo = ''; if (is_array($listofmodules) && count($listofmodules) > 0) { - // Define $linktoenabledisable and $modulestatusinfo + // Define $linktoenabledisable $modulelowercase = strtolower($module); $const_name = 'MAIN_MODULE_'.strtoupper($module); @@ -1732,6 +1735,8 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { $linktoenabledisable .= img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); $linktoenabledisable .= ''; + $linktoenabledisable .= $form->textwithpicto('', $langs->trans("Warning").' : '.$langs->trans("ModuleIsLive"), -1, 'warning'); + $objMod = $moduleobj; $backtourlparam = ''; $backtourlparam .= ($backtourlparam ? '&' : '?').'module='.$module; // No urlencode here, done later @@ -1751,38 +1756,33 @@ if (is_array($listofmodules) && count($listofmodules) > 0) { } else { if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) { $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); - $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + $linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 8px"').''; } else { // Case standard admin page (not a page provided by the // module but a page provided by dolibarr) $urltouse = DOL_URL_ROOT.'/admin/'.$urlpage; - $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + $linktoenabledisable .= ' '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 8px"').''; } } } } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { - $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 8px"').''; } } else { $linktoenabledisable .= ''; - $linktoenabledisable .= img_picto($langs->trans("ModuleIsNotActive", $urltomodulesetup), 'switch_off', '', false, 0, 0, '', 'classfortooltip', 1); + $linktoenabledisable .= img_picto($langs->trans("ModuleIsNotActive", $urltomodulesetup), 'switch_off', 'style="padding-right: 8px"', false, 0, 0, '', 'classfortooltip', 1); $linktoenabledisable .= "\n"; } - if (!empty($conf->$modulelowercase->enabled)) { - $modulestatusinfo = $form->textwithpicto('', $langs->trans("Warning").' : '.$langs->trans("ModuleIsLive"), -1, 'warning'); - } - // Loop to show tab of each module foreach ($listofmodules as $tmpmodule => $tmpmodulearray) { $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); $head[$h][1] = $tmpmodulearray['modulenamewithcase']; $head[$h][2] = $tmpmodulearray['modulenamewithcase']; - /*if ($tmpmodule == $modulelowercase) { - $head[$h][1] .= ' '.$modulestatusinfo; - $head[$h][1] .= ' '.$linktoenabledisable; - }*/ + if ($tmpmodulearray['modulenamewithcase'] == $module) { + $head[$h][4] = ''.$linktoenabledisable.''; + } $h++; } @@ -1793,6 +1793,7 @@ $head[$h][1] = $langs->trans("DangerZone"); $head[$h][2] = 'deletemodule'; $h++; + print dol_get_fiche_head($head, $module, '', -1, '', 0, $infomodulesfound, '', 8); // Modules if ($module == 'initmodule') { @@ -1875,6 +1876,11 @@ if ($module == 'initmodule') { $head2[$h][2] = 'widgets'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=exportimport&module='.$module.($forceddirread ? '@'.$dirread : ''); + $head2[$h][1] = $langs->trans("Export").'-'.$langs->trans("Import"); + $head2[$h][2] = 'exportimport'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("CSS"); $head2[$h][2] = 'css'; @@ -1905,11 +1911,7 @@ if ($module == 'initmodule') { $head2[$h][2] = 'buildpackage'; $h++; - // Link to enable / disable - print '
    '.$modulestatusinfo; - print ' '.$linktoenabledisable.'
    '; - - print '
    '; + print ''; // Note module is inside $dirread @@ -2608,6 +2610,7 @@ if ($module == 'initmodule') { print '
    '; print ''; print ''; + print ''; print ''; print ''; //print ''; @@ -2639,6 +2642,7 @@ if ($module == 'initmodule') { print ''; print ''; print ''; + print ''; print ''; print ''; //print ''; @@ -2679,6 +2683,7 @@ if ($module == 'initmodule') { $propisameasure = $propval['isameasure']; $propcss = $propval['css']; $propcssview = $propval['cssview']; + $propcsslist = $propval['csslist']; $prophelp = $propval['help']; $propshowoncombobox = $propval['showoncombobox']; //$propdisabled=$propval['disabled']; @@ -2692,72 +2697,139 @@ if ($module == 'initmodule') { print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ + print ''; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - /*print '';*/ - print ''; - print ''; - print ''; } } else { @@ -3336,6 +3408,45 @@ if ($module == 'initmodule') { } } + if ($tab == 'exportimport') { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $exportlist = $moduleobj->export_label; + $importlist = $moduleobj->import_label; + + if ($action != 'editfile' || empty($file)) { + print ''.$langs->transnoentities('ImportExportProfiles').'
    '; + print '
    '; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + } else { + $fullpathoffile = dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); + print '
    '; + print '
    '; + print ''; + print '   '; + print ''; + print '
    '; + + print ''; + } + } + if ($tab == 'cli') { $clifiles = array(); $i = 0; diff --git a/htdocs/modulebuilder/template/admin/index.html b/htdocs/modulebuilder/template/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/admin/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 06b169863f5..97d04336ee6 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -80,6 +80,8 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), + //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), ); $error = 0; @@ -271,6 +273,30 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); + print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); + } elseif ($val['type'] == 'securekey') { + print ''; + if (!empty($conf->use_javascript_ajax)) { + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + print "\n".''; + } } else { print ''; } @@ -327,6 +353,16 @@ if ($action == 'edit') { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $val['type'])) { + if ($conf->global->{$constname}==2) { + print $langs->trans("Prospect"); + } elseif ($conf->global->{$constname}==3) { + print $langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$constname}==1) { + print $langs->trans("Customer"); + } elseif ($conf->global->{$constname}==0) { + print $langs->trans("NorProspectNorCustomer"); + } } else { print $conf->global->{$constname}; } diff --git a/htdocs/modulebuilder/template/class/index.html b/htdocs/modulebuilder/template/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/class/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6a17e500a69..2c96190e232 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -273,7 +273,11 @@ class MyObject extends CommonObject */ public function create(User $user, $notrigger = false) { - return $this->createCommon($user, $notrigger); + $resultcreate = $this->createCommon($user, $notrigger); + + //$resultvalidate = $this->validate($user, $notrigger); + + return $resultcreate; } /** @@ -579,9 +583,9 @@ class MyObject extends CommonObject $sql .= ", date_validation = '".$this->db->idate($now)."'"; } if (!empty($this->fields['fk_user_valid'])) { - $sql .= ", fk_user_valid = ".$user->id; + $sql .= ", fk_user_valid = ".((int) $user->id); } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::validate()", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index e4f662c9e99..d212e10998e 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -264,20 +264,20 @@ class modMyModule 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 . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->read) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->write) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label - $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][4] = 'myobject'; + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) $r++; /* END MODULEBUILDER PERMISSIONS */ @@ -290,6 +290,7 @@ class modMyModule extends DolibarrModules 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'ModuleMyModuleName', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mymodule', 'leftmenu'=>'', 'url'=>'/mymodule/mymoduleindex.php', @@ -306,6 +307,7 @@ class modMyModule extends DolibarrModules 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Top menu entry 'titre'=>'MyObject', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mymodule', 'leftmenu'=>'myobject', 'url'=>'/mymodule/mymoduleindex.php', diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 3d900bc06e7..ca3c925dd51 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -1018,10 +1018,11 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); if (!empty($object->project->ref)) { + $outputlangs->load("projects"); $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/modulebuilder/template/index.html b/htdocs/modulebuilder/template/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/template/js/index.html b/htdocs/modulebuilder/template/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/js/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/template/lib/index.html b/htdocs/modulebuilder/template/lib/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/lib/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 76131c70719..fe4cd496df0 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -132,7 +132,7 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object- // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //if (empty($conf->mymodule->enabled)) accessforbidden(); //if (empty($permissiontoread)) accessforbidden(); diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 6d6345d9b99..4817efe5e9b 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -107,7 +107,7 @@ if ($action == 'addcontact' && $permission) { } } elseif ($action == 'swapstatut' && $permission) { // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $permission) { // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/modulebuilder/template/sql/index.html b/htdocs/modulebuilder/template/sql/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/modulebuilder/template/sql/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/mrp/ajax/index.html b/htdocs/mrp/ajax/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/ajax/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 281ec0fb731..48f93976d29 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -98,6 +98,10 @@ class Mos extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->mrp->read) { + throw new RestException(401); + } + $obj_ret = array(); $tmpobject = new Mo($this->db); diff --git a/htdocs/mrp/class/index.html b/htdocs/mrp/class/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/class/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index f86a52f4aae..cbb7b5da305 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -77,7 +77,7 @@ if ($conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; while ($i < $num) { $obj = $db->fetch_object($resql); diff --git a/htdocs/mrp/js/index.html b/htdocs/mrp/js/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/js/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/mrp/tpl/index.html b/htdocs/mrp/tpl/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/mrp/tpl/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 7886bd35774..5067a6e91d5 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -591,7 +591,7 @@ class MultiCurrency extends CommonObject { global $db; - $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.$fk_facture; + $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.((int) $fk_facture); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index da7921fa7fe..8f5336450b8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -102,11 +102,18 @@ $arrayfields = array( $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +// Access control +// TODO Open this page to a given permission so a sale representative can modify change rates. Permission should be added into module multicurrency. +// One permission to read rates (history) and one to add/edit rates. +if (!$user->admin || empty($conf->multicurrency->enabled)) { + accessforbidden(); +} /* * Actions */ + if ($action == "create") { if (!empty($rateinput)) { $currencyRate_static = new CurrencyRate($db); @@ -225,6 +232,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } + /* * View */ @@ -233,8 +241,9 @@ $htmlother = new FormOther($db); $title = $langs->trans("CurrencyRate"); $page_name = "ListCurrencyRate"; +$help_url = ''; -llxHeader('', $title, $helpurl, ''); +llxHeader('', $title, $help_url, ''); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback); diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index badb3f60149..e11fb65184a 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -594,7 +594,7 @@ class Opensurveysondage extends CommonObject */ public function deleteComment($id_comment) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.((int) $id_comment).' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index ede66c3e022..6d12259a39f 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -53,7 +53,7 @@ $nblines = $object->fetch_lines(); // Return to the results if (GETPOST('retoursondage')) { - header('Location: results.php?id='.$_GET['id']); + header('Location: results.php?id='.GETPOST('id', 'int')); exit; } @@ -66,9 +66,9 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // bo $nouveauchoix = ''; for ($i = 0; $i < $nbcolonnes; $i++) { - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { + if (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { + } elseif (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; @@ -122,17 +122,16 @@ if ($testmodifier) { $nouveauchoix = ''; for ($i = 0; $i < $nbcolonnes; $i++) { - //var_dump($_POST["choix$i"]); - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { + if (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { + } elseif (GETPOSTISSET("choix$i") && GETPOST("choix$i") == '2') { $nouveauchoix .= "2"; } else { // sinon c'est 0 $nouveauchoix .= "0"; } } - $idtomodify = $_POST["idtomodify".$modifier]; + $idtomodify = GETPOST("idtomodify".$modifier); $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; @@ -169,7 +168,7 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format = } // Add column (with format date) -if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { +if (GETPOSTISSET("ajoutercolonne") && $object->format == "D") { // Security check if (!$user->rights->opensurvey->write) { accessforbidden(); @@ -177,27 +176,27 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D") { $nouveauxsujets = $object->sujet; - if (isset($_POST["nouveaujour"]) && $_POST["nouveaujour"] != "vide" && - isset($_POST["nouveaumois"]) && $_POST["nouveaumois"] != "vide" && - isset($_POST["nouvelleannee"]) && $_POST["nouvelleannee"] != "vide") { - $nouvelledate = dol_mktime(0, 0, 0, $_POST["nouveaumois"], $_POST["nouveaujour"], $_POST["nouvelleannee"]); + if (GETPOSTISSET("nouveaujour") && GETPOST("nouveaujour") != "vide" && + GETPOSTISSET("nouveaumois") && GETPOST("nouveaumois") != "vide" && + GETPOSTISSET("nouvelleannee") && GETPOST("nouvelleannee") != "vide") { + $nouvelledate = dol_mktime(0, 0, 0, GETPOST("nouveaumois"), GETPOST("nouveaujour"), GETPOST("nouvelleannee")); - if (isset($_POST["nouvelleheuredebut"]) && $_POST["nouvelleheuredebut"] != "vide") { + if (GETPOSTISSET("nouvelleheuredebut") && GETPOST("nouvelleheuredebut") != "vide") { $nouvelledate .= "@"; $nouvelledate .= GETPOST("nouvelleheuredebut"); $nouvelledate .= "h"; - if ($_POST["nouvelleminutedebut"] != "vide") { + if (GETPOST("nouvelleminutedebut") != "vide") { $nouvelledate .= GETPOST("nouvelleminutedebut"); } } - if (isset($_POST["nouvelleheurefin"]) && $_POST["nouvelleheurefin"] != "vide") { + if (GETPOSTISSET("nouvelleheurefin") && GETPOST("nouvelleheurefin") != "vide") { $nouvelledate .= "-"; $nouvelledate .= GETPOST("nouvelleheurefin"); $nouvelledate .= "h"; - if ($_POST["nouvelleminutefin"] != "vide") { + if (GETPOST("nouvelleminutefin") != "vide") { $nouvelledate .= GETPOST("nouvelleminutefin"); } } @@ -284,7 +283,7 @@ for ($i = 0; $i < $nblines; $i++) { if ($compteur == $i) { $sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs'; - $sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users); + $sql2 .= " WHERE id_users = ".((int) $obj->id_users); $resql2 = $db->query($sql2); } diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 7bba308ba9c..41ad839cb94 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -41,7 +41,7 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'setvalue' && $user->admin) { $db->begin(); - //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE",$_POST["PAYBOX_IBS_DEVISE"],'chaine',0,'',$conf->entity); + //$result=dolibarr_set_const($db, "PAYBOX_IBS_DEVISE", GETPOST("PAYBOX_IBS_DEVISE"),'chaine',0,'',$conf->entity); $result = dolibarr_set_const($db, "PAYBOX_CGI_URL_V1", GETPOST('PAYBOX_CGI_URL_V1', 'alpha'), 'chaine', 0, '', $conf->entity); if (!$result > 0) { $error++; diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index fada766f065..2166ada6138 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -86,7 +86,7 @@ if ($action == 'update') { if (!$db->query($sql)) { //If we could not create, then we try updating $sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules"; - $sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i; + $sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i); if (!$db->query($sql)) { setEventMessages($langs->trans('ErrorSavingChanges'), null, 'errors'); diff --git a/htdocs/product/admin/product_lot.php b/htdocs/product/admin/product_lot.php new file mode 100644 index 00000000000..d1b87bf0b14 --- /dev/null +++ b/htdocs/product/admin/product_lot.php @@ -0,0 +1,279 @@ + + * + * 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/product/admin/product_lot.php + * \ingroup produit + * \brief Setup page of product lot module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "products", "productbatch")); + +// Security check +if (!$user->admin || (empty($conf->productbatch->enabled))) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMaskLot') { + $maskconstbatch = GETPOST('maskconstLot', 'alpha'); + $maskbatch = GETPOST('maskLot', 'alpha'); + + if ($maskconstbatch) $res = dolibarr_set_const($db, $maskconstbatch, $maskbatch, 'chaine', 0, '', $conf->entity); + + if (!$res > 0) $error++; + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif ($action == 'updateMaskSN') { + $maskconstbatch = GETPOST('maskconstSN', 'alpha'); + $maskbatch = GETPOST('maskSN', 'alpha'); + + if ($maskconstbatch) $res = dolibarr_set_const($db, $maskconstbatch, $maskbatch, 'chaine', 0, '', $conf->entity); + + if (!$res > 0) $error++; + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} elseif ($action == 'setmodlot') { + dolibarr_set_const($db, "PRODUCTBATCH_LOT_ADDON", $value, 'chaine', 0, '', $conf->entity); +} elseif ($action == 'setmodsn') { + dolibarr_set_const($db, "PRODUCTBATCH_SN_ADDON", $value, 'chaine', 0, '', $conf->entity); +} + +/* + * View + */ + +$form = new Form($db); + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +llxHeader("", $langs->trans("ProductLotSetup")); + +$linkback = ''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ProductLotSetup"), $linkback, 'title_setup'); + +$head = product_lot_admin_prepare_head(); + +print dol_get_fiche_head($head, 'settings', $langs->trans("Batch"), -1, 'lot'); + +/* + * Lot Numbering models + */ + +print load_fiche_titre($langs->trans("BatchLotNumberingModules"), '', ''); + +print '

    *** Force page code and collation of tables into utf8mb4/utf8mb4_unicode_ci (for mysql/mariadb only)
    '; + print $table; + $sql1 = 'ALTER TABLE '.$table.' ROW_FORMAT=dynamic;'; + $sql2 = 'ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'; + print ''; + print ''; + if ($force_utf8mb4_on_tables == 'confirmed') { + $resql1 = $db->query($sql1); + if ($resql1) { + $resql2 = $db->query($sql2); + } else { + $resql2 = false; + } + print ' - Done ('.(($resql1 && $resql2) ? 'OK' : 'KO').')'; + } else { + print ' - Disabled'; + } + print '
    Not available with database type '.$db->type.'

    *** Force to rebuild sequences (for postgresql only)
    Not available with database type '.$db->type.'
    '.dol_trunc($obj->label, 42).''.price($obj->capital).''.price($obj->capital).''.dol_print_date($db->jdate($obj->datestart), 'day').'
    ".$group_array['htmlname']."'.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'
    '; - print price($objp->total_ht); + print ''.price($objp->total_ht).''; print ''.$companystatic->getNomUrl(1, 'margin').''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'".$product_static->getNomUrl(1)."'.$qty.''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.price(price2num($pv, 'MT')).''.price(price2num($pa, 'MT')).''.price(price2num($marge, 'MT')).''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$langs->trans("CSSClass").''.$langs->trans("CSSViewClass").''.$langs->trans("CSSListClass").''.$langs->trans("KeyForTooltip").''.$langs->trans("ShowOnCombobox").''.$langs->trans("Disabled").''; print dol_escape_htmltag($proplabel); print ''; - print ''.dol_escape_htmltag($proptype).''; - print ''; - if ($proparrayofkeyval) { - print ''; - print dol_escape_htmltag(json_encode($proparrayofkeyval)); + if ($action == 'editproperty' && $propname == $propertykey) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.dol_escape_htmltag($proptype).''; + print ''; + if ($proparrayofkeyval) { + print ''; + print dol_escape_htmltag(json_encode($proparrayofkeyval)); + print ''; + } + print ''; + print dol_escape_htmltag($propnotnull); + print ''; + print dol_escape_htmltag($propdefault); + print ''; + print $propindex ? '1' : ''; + print ''; + print $propforeignkey ? dol_escape_htmltag($propforeignkey) : ''; + print ''; + print dol_escape_htmltag($propposition); + print ''; + print $propenabled ? dol_escape_htmltag($propenabled) : ''; + print ''; + print $propvisible ? dol_escape_htmltag($propvisible) : '0'; + print ''; + print $propnoteditable ? dol_escape_htmltag($propnoteditable) : ''; + print ''; + print $propsearchall ? '1' : ''; + print ''; + print $propisameasure ? dol_escape_htmltag($propisameasure) : ''; + print ''; + print $propcss ? dol_escape_htmltag($propcss) : ''; + print ''; + print $propcssview ? dol_escape_htmltag($propcssview) : ''; + print ''; + print $propcsslist ? dol_escape_htmltag($propcsslist) : ''; + print ''; + print $prophelp ? dol_escape_htmltag($prophelp) : ''; + print ''; + print $propshowoncombobox ? dol_escape_htmltag($propshowoncombobox) : ''; + print ''; + print $propdisabled?$propdisabled:''; + print ''; + print ''; + print dol_escape_htmltag($propcomment); print ''; + print ''; + if ($propname != 'rowid') { + print ''.img_edit().''; + print ''.img_delete().''; + } + print ''; - print dol_escape_htmltag($propnotnull); - print ''; - print dol_escape_htmltag($propdefault); - print ''; - print $propindex ? '1' : ''; - print ''; - print $propforeignkey ? dol_escape_htmltag($propforeignkey) : ''; - print ''; - print dol_escape_htmltag($propposition); - print ''; - print $propenabled ? dol_escape_htmltag($propenabled) : ''; - print ''; - print $propvisible ? dol_escape_htmltag($propvisible) : '0'; - print ''; - print $propnoteditable ? dol_escape_htmltag($propnoteditable) : ''; - print ''; - print $propsearchall ? '1' : ''; - print ''; - print $propisameasure ? dol_escape_htmltag($propisameasure) : ''; - print ''; - print $propcss ? dol_escape_htmltag($propcss) : ''; - print ''; - print $propcssview ? dol_escape_htmltag($propcssview) : ''; - print ''; - print $prophelp ? dol_escape_htmltag($prophelp) : ''; - print ''; - print $propshowoncombobox ? dol_escape_htmltag($propshowoncombobox) : ''; - print ''; - print $propdisabled?$propdisabled:''; - print ''; - print ''; - print dol_escape_htmltag($propcomment); - print ''; - print ''; - if ($propname != 'rowid') { - print ''.img_delete().''; - } - print '
    '; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/product_batch/"); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 8) == 'mod_lot_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) { + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $batch = new Productlot($db); + $batch->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
    '; + $nextval = $module->getNextValue($mysoc, $batch); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
    '; + } else { + $htmltooltip .= $langs->trans($module->error).'
    '; + } + } + + print '
    '; + + print "\n"; + } + } + } + closedir($handle); + } + } +} + +print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.$module->name."\n"; + print $module->info(); + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
    '.$langs->trans($tmp).'
    '; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
    '; + if ($conf->global->PRODUCTBATCH_LOT_ADDON == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

    \n"; + + +/* + * Serials Numbering models + */ + +print load_fiche_titre($langs->trans("BatchSerialNumberingModules"), '', ''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/product_batch/"); + + if (is_dir($dir)) { + $handle = opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 7) == 'mod_sn_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) { + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $batch = new Productlot($db); + $batch->initAsSpecimen(); + + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
    '; + $nextval = $module->getNextValue($mysoc, $batch); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
    '; + } else { + $htmltooltip .= $langs->trans($module->error).'
    '; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } +} + +print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.$module->name."\n"; + print $module->info(); + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
    '.$langs->trans($tmp).'
    '; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
    '; + if ($conf->global->PRODUCTBATCH_SN_ADDON == $file) { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

    \n"; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/admin/product_lot_extrafields.php b/htdocs/product/admin/product_lot_extrafields.php index fc14b4c142c..38af3a41f8d 100644 --- a/htdocs/product/admin/product_lot_extrafields.php +++ b/htdocs/product/admin/product_lot_extrafields.php @@ -77,7 +77,7 @@ print load_fiche_titre($title, $linkback, 'title_setup'); $head = product_lot_admin_prepare_head(); -print dol_get_fiche_head($head, 'attributes', $textobject, -1, 'stock'); +print dol_get_fiche_head($head, 'attributes', $textobject, -1, 'lot'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index bf25675865f..a03bdb22477 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -52,7 +52,6 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $id = $user->socid; } -$result = restrictedArea($user, 'produit|service', $id, 'product&product'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -74,6 +73,8 @@ if (!$sortorder) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendathirdparty')); +$result = restrictedArea($user, 'produit|service', $id, 'product&product'); + /* * Actions diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 9dacb4e547d..901e2b387e3 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -62,14 +62,15 @@ $alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int $warehouseStatus = GETPOST('warehousestatus', 'alpha'); $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); +// Security check +restrictedArea($user, 'produit|service', 0, 'product&product'); + /* * View */ // print ''."\n"; - -dol_syslog(join(',', $_GET)); // print_r($_GET); if (!empty($action) && $action == 'fetch' && !empty($id)) { @@ -218,10 +219,13 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { return; } + // Filter on the product to search can be: + // Into an array with key $htmlname123 (we take first one found). Which page use this ? + // Into a var with name $htmlname can be 'prodid', 'productid', ... $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (!empty($match[0]) ? $match[0] : ''); + $idprod = (empty($match[0]) ? '' : $match[0]); // Take first key found into GET array with matching $htmlname123 if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); @@ -231,7 +235,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // When used from jQuery, the search term is added as GET param "term". $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); - $form = new Form($db); + if (!is_object($form)) { + $form = new Form($db); + } if (empty($mode) || $mode == 1) { // mode=1: customer $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 352256f5c42..094ce8670a9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -405,8 +405,8 @@ if (empty($reshook)) { if (!empty($conf->global->PRODUIT_MULTIPRICES)) { for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if (GETPOSTISSET("price_".$i)) { - $object->multiprices["$i"] = price2num($_POST["price_".$i], 'MU'); - $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; + $object->multiprices["$i"] = price2num(GETPOST("price_".$i), 'MU'); + $object->multiprices_base_type["$i"] = GETPOST("multiprices_base_type_".$i); } else { $object->multiprices["$i"] = ""; } @@ -940,20 +940,6 @@ if (empty($reshook)) { * View */ -$title = $langs->trans('ProductServiceCard'); -$helpurl = ''; -$shortlabel = dol_trunc($object->label, 16); -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; -} -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; -} - -llxHeader('', $title, $helpurl); - $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); @@ -962,6 +948,21 @@ if (!empty($conf->accounting->enabled)) { $formaccounting = new FormAccounting($db); } + +$title = $langs->trans('ProductServiceCard'); +$help_url = ''; +$shortlabel = dol_trunc($object->label, 16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; +} + +llxHeader('', $title, $help_url); + // Load object modBarCodeProduct $res = 0; if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { @@ -984,7 +985,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // When used with CANVAS // ----------------------------------------- if (empty($object->error) && $id) { - $object = new Product($db); $result = $object->fetch($id); if ($result <= 0) { dol_print_error('', $object->error); @@ -1135,6 +1135,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($type != 1 && !empty($conf->stock->enabled)) { // Default warehouse print '
    '.$langs->trans("DefaultWarehouse").''; + print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'pictofixedwidth'); print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1); print ' '; print ''; @@ -1464,6 +1465,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { /* * Product card */ + // Fiche en mode edition if ($action == 'edit' && $usercancreate) { //WYSIWYG Editor diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c38437fb2f0..6b26421d0f8 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -172,6 +172,10 @@ class Products extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(403); + } + $obj_ret = array(); $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; @@ -570,8 +574,8 @@ class Products extends DolibarrApi /** * Get prices per customer for a product * - * @param int $id ID of product - * @param string $thirdparty_id Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i} + * @param int $id ID of product + * @param string $thirdparty_id Thirdparty id to filter orders of (example '1') {@pattern /^[0-9,]*$/i} * * @return mixed * @@ -589,6 +593,11 @@ class Products extends DolibarrApi throw new RestException(400, 'API not available: this mode of pricing is not enabled by setup'); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0 && $socid != $thirdparty_id) { + throw new RestException(401, 'Getting prices for all customers or for the customer ID '.$thirdparty_id.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->product->fetch($id); if (!$result) { throw new RestException(404, 'Product not found'); @@ -696,6 +705,11 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0 && $socid != $fourn_id) { + throw new RestException(401, 'Adding purchase price for the supplier ID '.$fourn_id.' is not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->productsupplier->add_fournisseur(DolibarrApiAccess::$user, $fourn_id, $ref_fourn, $qty); if ($result < 0) { throw new RestException(500, "Error adding supplier to product : ".$this->db->lasterror()); @@ -770,9 +784,19 @@ class Products extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->produit->lire) { + throw new RestException(401); + } + $obj_ret = array(); + // Force id of company for external users $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + if ($socid > 0) { + if ($supplier != $socid || empty($supplier)) { + throw new RestException(401, 'As an external user, you can request only for your supplier id = '.$socid); + } + } $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql .= " FROM ".MAIN_DB_PREFIX."product as t"; @@ -784,12 +808,15 @@ class Products extends DolibarrApi $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; if ($supplier > 0) { - $sql .= " AND s.fk_soc = ".$this->db->escape($supplier); + $sql .= " AND s.fk_soc = ".((int) $supplier); + } + if ($socid > 0) { // if external user + $sql .= " AND s.fk_soc = ".((int) $socid); } $sql .= " AND s.fk_product = t.rowid"; // Select products of given category if ($category > 0) { - $sql .= " AND c.fk_categorie = ".$this->db->escape($category); + $sql .= " AND c.fk_categorie = ".((int) $category); $sql .= " AND c.fk_product = t.rowid"; } if ($mode == 1) { @@ -874,6 +901,8 @@ class Products extends DolibarrApi throw new RestException(403); } + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + $result = $this->product->fetch($id, $ref, $ref_ext, $barcode); if (!$result) { throw new RestException(404, 'Product not found'); @@ -887,7 +916,7 @@ class Products extends DolibarrApi if ($result) { $product_fourn = new ProductFournisseur($this->db); - $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0); + $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0, ($socid > 0 ? $socid : 0)); } foreach ($product_fourn_list as $tmpobj) { @@ -907,7 +936,9 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:color)" * @return array * - * @throws RestException + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 503 * * @url GET attributes */ @@ -972,7 +1003,6 @@ class Products extends DolibarrApi * @param int $id ID of Attribute * @return array * - * @throws RestException * @throws RestException 401 * @throws RestException 404 * @@ -1016,8 +1046,8 @@ class Products extends DolibarrApi * @param string $ref Reference of Attribute * @return array * - * @throws RestException 500 * @throws RestException 401 + * @throws RestException 404 * * @url GET attributes/ref/{ref} */ @@ -1268,7 +1298,10 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")"; + $ref = trim($ref); + + $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value"; + $sql .= " WHERE ref LIKE '".$this->db->escape($ref)."' AND fk_product_attribute = ".((int) $id)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); @@ -1308,7 +1341,10 @@ class Products extends DolibarrApi throw new RestException(401); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")"; + $ref = trim($ref); + + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_value"; + $sql .= " WHERE ref LIKE '".$this->db->escape($ref)."' AND fk_product_attribute = ".((int) $id)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); if (!$query) { @@ -1379,11 +1415,13 @@ class Products extends DolibarrApi throw new RestException(401); } + $ref = trim($ref); + $return = array(); $sql = 'SELECT '; $sql .= 'v.fk_product_attribute, v.rowid, v.ref, v.value FROM '.MAIN_DB_PREFIX.'product_attribute_value as v'; - $sql .= " WHERE v.fk_product_attribute IN (SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".$this->db->escape(trim($ref))."')"; + $sql .= " WHERE v.fk_product_attribute IN (SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".$this->db->escape($ref)."')"; $resql = $this->db->query($sql); @@ -1424,7 +1462,7 @@ class Products extends DolibarrApi } $objectval = new ProductAttributeValue($this->db); - $objectval->fk_product_attribute = $id; + $objectval->fk_product_attribute = ((int) $id); $objectval->ref = $ref; $objectval->value = $value; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 56efd8565d1..718acef6970 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -116,13 +116,13 @@ class FormProduct } $sql .= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql .= " AND e.statut IN (".$this->db->sanitize($this->db->escape(implode(',', $warehouseStatus))).")"; + $sql .= " AND e.statut IN (".$this->db->sanitize(implode(',', $warehouseStatus)).")"; } else { $sql .= " AND e.statut = 1"; } if (!empty($exclude)) { - $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; + $sql .= ' AND e.rowid NOT IN('.$this->db->sanitize(implode(',', $exclude)).')'; } // minimum stock @@ -646,7 +646,7 @@ class FormProduct $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; if (!empty($productIdList)) { - $sql .= " WHERE ps.fk_product IN (".$productIdList.")"; + $sql .= " WHERE ps.fk_product IN (".$this->db->sanitize($productIdList).")"; } $sql .= " ORDER BY e.ref, pb.batch"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f195fa0c5e7..16bbc508ac9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2013-2016 Marcos García - * Copyright (C) 2011-2020 Alexandre Spangaro + * Copyright (C) 2011-2021 Open-DSI * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand * Copyright (C) 2014 Ion agorria @@ -660,12 +660,14 @@ class Product extends CommonObject $sql .= ", price_base_type"; $sql .= ", tobuy"; $sql .= ", tosell"; - $sql .= ", accountancy_code_buy"; - $sql .= ", accountancy_code_buy_intra"; - $sql .= ", accountancy_code_buy_export"; - $sql .= ", accountancy_code_sell"; - $sql .= ", accountancy_code_sell_intra"; - $sql .= ", accountancy_code_sell_export"; + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_buy_intra"; + $sql .= ", accountancy_code_buy_export"; + $sql .= ", accountancy_code_sell"; + $sql .= ", accountancy_code_sell_intra"; + $sql .= ", accountancy_code_sell_export"; + } $sql .= ", canvas"; $sql .= ", finished"; $sql .= ", tobatch"; @@ -685,12 +687,14 @@ class Product extends CommonObject $sql .= ", '".$this->db->escape($this->price_base_type)."'"; $sql .= ", ".$this->status; $sql .= ", ".$this->status_buy; - $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_intra)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_buy_export)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; + } $sql .= ", '".$this->db->escape($this->canvas)."'"; $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); @@ -718,6 +722,34 @@ class Product extends CommonObject $error++; $this->error = $this->db->lasterror(); } + + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; + $sql .= " fk_product"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_buy_intra"; + $sql .= ", accountancy_code_buy_export"; + $sql .= ", accountancy_code_sell"; + $sql .= ", accountancy_code_sell_intra"; + $sql .= ", accountancy_code_sell_export"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToInsertAccountancyForEntity'; + } + } } else { $error++; $this->error = 'ErrorFailedToGetInsertedId'; @@ -1051,12 +1083,14 @@ class Product extends CommonObject $sql .= ", fk_state = ".($this->state_id > 0 ? (int) $this->state_id : 'null'); $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; - $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; - $sql .= ", accountancy_code_buy_intra = '".$this->db->escape($this->accountancy_code_buy_intra)."'"; - $sql .= ", accountancy_code_buy_export = '".$this->db->escape($this->accountancy_code_buy_export)."'"; - $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; - $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; - $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", accountancy_code_buy_intra = '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; + $sql .= ", accountancy_code_buy_export = '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; + $sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; + $sql .= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; + } $sql .= ", desiredstock = ".((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float) $this->desiredstock : "null"); $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); $sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); @@ -1083,6 +1117,36 @@ class Product extends CommonObject $action = 'update'; + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; + $sql .= " fk_product"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_buy_intra"; + $sql .= ", accountancy_code_buy_export"; + $sql .= ", accountancy_code_sell"; + $sql .= ", accountancy_code_sell_intra"; + $sql .= ", accountancy_code_sell_export"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy_export) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToUpdateAccountancyForEntity'; + } + } + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -1756,9 +1820,9 @@ class Product extends CommonObject $sql .= ", pfp.packaging"; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE pfp.rowid = ".$prodfournprice; + $sql .= " WHERE pfp.rowid = ".((int) $prodfournprice); if ($qty > 0) { - $sql .= " AND pfp.quantity <= ".$qty; + $sql .= " AND pfp.quantity <= ".((float) $qty); } $sql .= " ORDER BY pfp.quantity DESC"; @@ -1810,15 +1874,15 @@ class Product extends CommonObject $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql .= " pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .= " WHERE pfp.fk_product = ".$product_id; + $sql .= " WHERE pfp.fk_product = ".((int) $product_id); if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$this->db->escape($fourn_ref)."'"; } if ($fk_soc > 0) { - $sql .= " AND pfp.fk_soc = ".$fk_soc; + $sql .= " AND pfp.fk_soc = ".((int) $fk_soc); } if ($qty > 0) { - $sql .= " AND pfp.quantity <= ".$qty; + $sql .= " AND pfp.quantity <= ".((float) $qty); } $sql .= " ORDER BY pfp.quantity DESC"; $sql .= " LIMIT 1"; @@ -2096,26 +2160,32 @@ class Product extends CommonObject return -1; } - $sql = "SELECT rowid, ref, ref_ext, label, description, url, note_public, note as note_private, customcode, fk_country, fk_state, price, price_ttc,"; - $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; - $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; - $sql .= " length, length_units, width, width_units, height, height_units,"; - $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; - $sql .= " accountancy_code_buy, accountancy_code_buy_intra, accountancy_code_buy_export,"; - $sql .= " accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; - $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; - $sql .= " fk_price_expression, price_autogen, model_pdf"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - if ($id) { - $sql .= " WHERE rowid = ".(int) $id; + $sql = "SELECT p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note as note_private, p.customcode, p.fk_country, p.fk_state, p.price, p.price_ttc,"; + $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; + $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; + $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; + $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,"; + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } else { - $sql .= " WHERE entity IN (".getEntity($this->element).")"; + $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export, pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; + } + $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, 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)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + } + if ($id) { + $sql .= " WHERE p.rowid = ".((int) $id); + } else { + $sql .= " WHERE p.entity IN (".getEntity($this->element).")"; if ($ref) { - $sql .= " AND ref = '".$this->db->escape($ref)."'"; + $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; } elseif ($ref_ext) { - $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; + $sql .= " AND p.ref_ext = '".$this->db->escape($ref_ext)."'"; } elseif ($barcode) { - $sql .= " AND barcode = '".$this->db->escape($barcode)."'"; + $sql .= " AND p.barcode = '".$this->db->escape($barcode)."'"; } } @@ -2290,7 +2360,7 @@ class Product extends CommonObject $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql .= " WHERE fk_product = ".$this->id; + $sql .= " WHERE fk_product = ".((int) $this->id); $sql .= " ORDER BY date_price DESC, rowid DESC"; $sql .= " LIMIT 1"; $resql = $this->db->query($sql); @@ -2304,7 +2374,7 @@ class Product extends CommonObject if ($this->prices_by_qty[0] == 1) { $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; + $sql .= " WHERE fk_product_price = ".((int) $this->prices_by_qty_id[0]); $sql .= " ORDER BY quantity ASC"; $resultat = array(); $resql = $this->db->query($sql); @@ -2750,7 +2820,7 @@ class Product extends CommonObject $sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid "; $sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'"; $sql .= " JOIN ".MAIN_DB_PREFIX."commande c ON el.fk_source = c.rowid "; - $sql .= " WHERE c.fk_statut IN (".$filtrestatut.") AND c.facture = 0 AND fd.fk_product = ".$this->id; + $sql .= " WHERE c.fk_statut IN (".$this->db->sanitize($filtrestatut).") AND c.facture = 0 AND fd.fk_product = ".((int) $this->id); dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); $resql = $this->db->query($sql); @@ -3543,7 +3613,7 @@ class Product extends CommonObject $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql .= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".((int) $socid); } $sql .= $morefilter; $sql .= " GROUP BY date_format(p.date_valid,'%Y%m')"; @@ -3792,7 +3862,7 @@ class Product extends CommonObject // Check not already father of id_pere (to avoid father -> child -> father links) $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; - $sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; + $sql .= ' WHERE fk_product_pere = '.((int) $id_fils).' AND fk_product_fils = '.((int) $id_pere); if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -3805,7 +3875,7 @@ class Product extends CommonObject return -1; } else { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; - $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')'; + $sql .= ' VALUES ('.((int) $id_pere).', '.((int) $id_fils).', '.((float) $qty).', '.((int) $incdec).')'; if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -3876,8 +3946,8 @@ class Product extends CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$fk_parent; - $sql .= " AND fk_product_fils = ".$fk_child; + $sql .= " WHERE fk_product_pere = ".((int) $fk_parent); + $sql .= " AND fk_product_fils = ".((int) $fk_child); dol_syslog(get_class($this).'::del_sousproduit', LOG_DEBUG); if (!$this->db->query($sql)) { @@ -3970,14 +4040,14 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_soc = ".$id_fourn; + $sql .= " WHERE fk_soc = ".((int) $id_fourn); if ($ref_fourn) { $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; } else { $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } - $sql .= " AND quantity = ".$quantity; - $sql .= " AND fk_product = ".$this->id; + $sql .= " AND quantity = ".((float) $quantity); + $sql .= " AND fk_product = ".((int) $this->id); $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; $resql = $this->db->query($sql); @@ -4128,7 +4198,7 @@ class Product extends CommonObject $sql .= ", multicurrency_price"; $sql .= ", multicurrency_price_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; - $sql .= " WHERE fk_product = ".$fromId; + $sql .= " WHERE fk_product = ".((int) $fromId); $sql .= " ORDER BY date_price DESC"; if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) { $sql .= " LIMIT ".$conf->global->PRODUIT_MULTIPRICES_LIMIT; @@ -4160,7 +4230,7 @@ class Product extends CommonObject $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$fromId; + $sql .= " WHERE fk_product_pere = ".((int) $fromId); dol_syslog(get_class($this).'::clone_association', LOG_DEBUG); if (!$this->db->query($sql)) { @@ -4192,7 +4262,7 @@ class Product extends CommonObject . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" . " FROM ".MAIN_DB_PREFIX."product_fournisseur" - . " WHERE fk_product = ".$fromId; + . " WHERE fk_product = ".((int) $fromId); if ( ! $this->db->query($sql ) ) { @@ -4203,9 +4273,9 @@ class Product extends CommonObject // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; $sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)"; - $sql .= " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, price, quantity, fk_user"; + $sql .= " SELECT '".$this->db->idate($now)."', ".((int) $toId).", fk_soc, price, quantity, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " WHERE fk_product = ".$fromId; + $sql .= " WHERE fk_product = ".((int) $fromId); dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG); $resql = $this->db->query($sql); @@ -4980,7 +5050,7 @@ class Product extends CommonObject $sql .= " AND w.rowid = ps.fk_entrepot"; $sql .= " AND ps.fk_product = ".$this->id; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { - $sql .= " AND w.statut IN (".$this->db->sanitize($this->db->escape(implode(',', $warehouseStatus))).")"; + $sql .= " AND w.statut IN (".$this->db->sanitize(implode(',', $warehouseStatus)).")"; } dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 046aed05a10..9b0d29b4cdd 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -814,7 +814,7 @@ class Productcustomerprice extends CommonObject // Find all susidiaries $sql = "SELECT s.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.parent = ".$this->fk_soc; + $sql .= " WHERE s.parent = ".((int) $this->fk_soc); $sql .= " AND s.entity IN (".getEntity('societe').")"; dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG); diff --git a/htdocs/product/class/productfournisseurprice.class.php b/htdocs/product/class/productfournisseurprice.class.php new file mode 100644 index 00000000000..709afcb6d20 --- /dev/null +++ b/htdocs/product/class/productfournisseurprice.class.php @@ -0,0 +1,843 @@ + + * Copyright (C) 2021 Alexis LAURIER + * + * 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 class/productfournisseurprice.class.php + * \ingroup product + * \brief This file is a CRUD class file for ProductFournisseurPrice (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + +/** + * Class for ProductFournisseurPrice + */ +class ProductFournisseurPrice extends CommonObject +{ + /** + * @var string ID to identify managed object. + */ + public $element = 'productfournisseurprice'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'product_fournisseur_price'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + + /** + * @var string String with name of icon for productfournisseurprice. Must be the part after the 'object_' into object_productfournisseurprice.png + */ + public $picto = 'productfournisseurprice@buypricehistory'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>-1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>25, 'notnull'=>1, 'visible'=>-1,), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Fkproduct', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>35, 'notnull'=>0, 'visible'=>-1,), + 'ref_fourn' => array('type'=>'varchar(255)', 'label'=>'Reffourn', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,), + 'desc_fourn' => array('type'=>'text', 'label'=>'Descfourn', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,), + 'fk_availability' => array('type'=>'integer', 'label'=>'Fkavailability', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,), + 'price' => array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,), + 'quantity' => array('type'=>'double', 'label'=>'Quantity', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1,), + 'remise_percent' => array('type'=>'double', 'label'=>'Remisepercent', 'enabled'=>'1', 'position'=>65, 'notnull'=>1, 'visible'=>-1,), + 'remise' => array('type'=>'double', 'label'=>'Remise', 'enabled'=>'1', 'position'=>70, 'notnull'=>1, 'visible'=>-1,), + 'unitprice' => array('type'=>'double(24,8)', 'label'=>'Unitprice', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,), + 'charges' => array('type'=>'double(24,8)', 'label'=>'Charges', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1,), + 'default_vat_code' => array('type'=>'varchar(10)', 'label'=>'Defaultvatcode', 'enabled'=>'1', 'position'=>85, 'notnull'=>0, 'visible'=>-1,), + 'tva_tx' => array('type'=>'double(6,3)', 'label'=>'Tvatx', 'enabled'=>'1', 'position'=>90, 'notnull'=>1, 'visible'=>-1,), + 'info_bits' => array('type'=>'integer', 'label'=>'Infobits', 'enabled'=>'1', 'position'=>95, 'notnull'=>1, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuser', 'enabled'=>'1', 'position'=>100, 'notnull'=>0, 'visible'=>-1,), + 'fk_supplier_price_expression' => array('type'=>'integer', 'label'=>'Fksupplierpriceexpression', 'enabled'=>'1', 'position'=>105, 'notnull'=>0, 'visible'=>-1,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>900, 'notnull'=>0, 'visible'=>-2,), + 'delivery_time_days' => array('type'=>'integer', 'label'=>'Deliverytimedays', 'enabled'=>'1', 'position'=>115, 'notnull'=>0, 'visible'=>-1,), + 'supplier_reputation' => array('type'=>'varchar(10)', 'label'=>'Supplierreputation', 'enabled'=>'1', 'position'=>120, 'notnull'=>0, 'visible'=>-1,), + 'fk_multicurrency' => array('type'=>'integer', 'label'=>'Fkmulticurrency', 'enabled'=>'1', 'position'=>125, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_code' => array('type'=>'varchar(255)', 'label'=>'Multicurrencycode', 'enabled'=>'1', 'position'=>130, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_tx' => array('type'=>'double(24,8)', 'label'=>'Multicurrencytx', 'enabled'=>'1', 'position'=>135, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_price' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyprice', 'enabled'=>'1', 'position'=>140, 'notnull'=>0, 'visible'=>-1,), + 'multicurrency_unitprice' => array('type'=>'double(24,8)', 'label'=>'Multicurrencyunitprice', 'enabled'=>'1', 'position'=>145, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax1tx', 'enabled'=>'1', 'position'=>150, 'notnull'=>0, 'visible'=>-1,), + 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), + 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), + 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'barcode' => array('type'=>'varchar(180)', 'label'=>'Barcode', 'enabled'=>'1', 'position'=>170, 'notnull'=>0, 'visible'=>-1,), + 'fk_barcode_type' => array('type'=>'integer', 'label'=>'Fkbarcodetype', 'enabled'=>'1', 'position'=>175, 'notnull'=>0, 'visible'=>-1,), + 'packaging' => array('type'=>'varchar(64)', 'label'=>'Packaging', 'enabled'=>'1', 'position'=>180, 'notnull'=>0, 'visible'=>-1,), + ); + public $rowid; + public $entity; + public $datec; + public $tms; + public $fk_product; + public $fk_soc; + public $ref_fourn; + public $desc_fourn; + public $fk_availability; + public $price; + public $quantity; + public $remise_percent; + public $remise; + public $unitprice; + public $charges; + public $default_vat_code; + public $tva_tx; + public $info_bits; + public $fk_user; + public $fk_supplier_price_expression; + public $import_key; + public $delivery_time_days; + public $supplier_reputation; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_price; + public $multicurrency_unitprice; + public $localtax1_tx; + public $localtax1_type; + public $localtax2_tx; + public $localtax2_type; + public $barcode; + public $fk_barcode_type; + public $packaging; + // END MODULEBUILDER PROPERTIES + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + if (property_exists($object, 'label')) $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + if (property_exists($object, 'status')) { $object->status = self::STATUS_DRAFT; } + if (property_exists($object, 'date_creation')) { $object->date_creation = dol_now(); } + if (property_exists($object, 'date_modification')) { $object->date_modification = null; } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id) + { + return $this->fetchCommon($id); + } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; + else $sql .= ' WHERE 1 = 1'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'"; + if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('PRODUCTFOURNISSEURPRICE_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'productfournisseurprice/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'productfournisseurprice/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$oldref; + $dirdest = $conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->buypricehistory->dir_output.'/productfournisseurprice/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PRODUCTFOURNISSEURPRICE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PRODUCTFOURNISSEURPRICE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PRODUCTFOURNISSEURPRICE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("ProductFournisseurPrice").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
    '; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + + $url = dol_buildpath('/buypricehistory/productfournisseurprice_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowProductFournisseurPrice"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + + $linkstart = '
    '; + $linkend = ''; + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
    No photo
    '; + } else { + $result .= '
    No photo
    '; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) $result .= $this->ref; + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('productfournisseurpricedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("buypricehistory@buypricehistory"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.((int) $id); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("buypricehistory@buypricehistory"); + + if (empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) { + $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON = 'mod_productfournisseurprice_standard'; + } + + if (!empty($conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON)) { + $mybool = false; + + $file = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON.".php"; + $classname = $conf->global->BUYPRICEHISTORY_PRODUCTFOURNISSEURPRICE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/buypricehistory/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("buypricehistory@buypricehistory"); + + if (!dol_strlen($modele)) { + $modele = 'standard_productfournisseurprice'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->PRODUCTFOURNISSEURPRICE_ADDON_PDF)) { + $modele = $conf->global->PRODUCTFOURNISSEURPRICE_ADDON_PDF; + } + } + + $modelpath = "core/modules/buypricehistory/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } +} diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index f7cf48df5e0..a1d92cc492a 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -239,7 +239,7 @@ class Propalmergepdfproduct extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; - $sql .= " WHERE t.fk_product = ".$product_id; + $sql .= " WHERE t.fk_product = ".((int) $product_id); if ($conf->global->MAIN_MULTILANGS && !empty($lang)) { $sql .= " AND t.lang = '".$this->db->escape($lang)."'"; } diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 9a1fa1adf69..442232686d3 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -167,18 +167,18 @@ if ($action == 'search') { } $title = $langs->trans('ProductServiceCard'); -$helpurl = ''; +$help_url = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; } -llxHeader('', $title, $helpurl); +llxHeader('', $title, $help_url); $head = product_prepare_head($object); $titre = $langs->trans("CardProduct".$object->type); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index c218d753d88..55cf32b7b56 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -52,7 +52,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productdocuments')); @@ -98,6 +97,8 @@ $modulepart = 'produit'; $permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index 546c2050990..db0c427c334 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -327,7 +327,7 @@ class PriceExpression if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index 29505ff8573..5286b932ca7 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -250,7 +250,7 @@ class PriceGlobalVariable if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index f43d6bc731d..172c004a2d7 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -275,7 +275,7 @@ class PriceGlobalVariableUpdater if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(__METHOD__); $resql = $this->db->query($sql); @@ -487,7 +487,7 @@ class PriceGlobalVariableUpdater if ($this->type == 0) { // Call JSON request include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - $tmpresult = getURLContent($url); + $tmpresult = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 0); $code = $tmpresult['http_code']; $result = $tmpresult['content']; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 371713f0250..0d5ea9647f5 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -62,9 +62,9 @@ $extrafields = new ExtraFields($db); // If socid provided by ajax company selector if (!empty($_REQUEST['search_fourn_id'])) { - $_GET['id_fourn'] = $_GET['search_fourn_id']; - $_POST['id_fourn'] = $_POST['search_fourn_id']; - $_REQUEST['id_fourn'] = $_REQUEST['search_fourn_id']; + $_GET['id_fourn'] = GETPOST('search_fourn_id', 'int'); + $_POST['id_fourn'] = GETPOST('search_fourn_id', 'int'); + $_REQUEST['id_fourn'] = GETPOST('search_fourn_id', 'int'); } // Security check @@ -73,7 +73,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (empty($user->rights->fournisseur->lire)) { accessforbidden(); @@ -114,6 +113,8 @@ if (!$sortorder) { $sortorder = "ASC"; } +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions @@ -217,7 +218,7 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Supplier")), null, 'errors'); } - if (price2num($_POST["price"]) < 0 || $_POST["price"] == '') { + if (price2num(GETPOST("price")) < 0 || GETPOST("price") == '') { if ($price_expression === '') { // Return error of missing price only if price_expression not set $error++; $langs->load("errors"); @@ -290,7 +291,7 @@ if (empty($reshook)) { foreach ($extrafield_values as $key => $value) { $sql .= str_replace('options_', '', $key).' = "'.$value.'", '; } - $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.$object->product_fourn_price_id; + $sql = substr($sql, 0, strlen($sql) - 2).' WHERE fk_object = '.((int) $object->product_fourn_price_id); } // Execute the sql command from above @@ -793,7 +794,7 @@ END; $sql .= ", ".$key; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields"; - $sql .= " WHERE fk_object = ".$rowid; + $sql .= " WHERE fk_object = ".((int) $rowid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1145,7 +1146,7 @@ END; $sql .= ", ".$key; } $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields"; - $sql .= " WHERE fk_object = ".$productfourn->product_fourn_price_id; + $sql .= " WHERE fk_object = ".((int) $productfourn->product_fourn_price_id); $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) != 1) { diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 9cdbe85cf4b..7d5f59c1ed9 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -41,6 +41,14 @@ if ($type == '' && !$user->rights->service->lire) { $type = '0'; // Force global page on product page only } +// Load translation files required by the page +$langs->loadLangs(array('products', 'stocks')); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('productindex')); + +$product_static = new Product($db); + // Security check if ($type == '0') { $result = restrictedArea($user, 'produit'); @@ -50,14 +58,6 @@ if ($type == '0') { $result = restrictedArea($user, 'produit|service|expedition'); } -// Load translation files required by the page -$langs->loadLangs(array('products', 'stocks')); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('productindex')); - -$product_static = new Product($db); - /* * View diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 92ad4c2176b..dda16746398 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -407,6 +407,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans("SetToDraft").''; } } + // Back to validate + if ($object->status == $object::STATUS_RECORDED) { + if ($permissiontoadd) { + print ''.$langs->trans("ReOpen").''; + } + } // Modify if ($object->status == $object::STATUS_DRAFT) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index ce585c51a10..e872d7e353a 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -52,7 +52,7 @@ class Inventory extends CommonObject /** * @var int Does object support extrafields ? 0=No, 1=Yes */ - public $isextrafieldmanaged = 1; + public $isextrafieldmanaged = 0; /** * @var string String with name of icon for inventory @@ -254,6 +254,7 @@ class Inventory extends CommonObject */ public function validate(User $user, $notrigger = false) { + global $conf; $this->db->begin(); $result = 0; @@ -328,6 +329,7 @@ class Inventory extends CommonObject } else { $this->db->rollback(); } + return $result; } /** @@ -357,6 +359,51 @@ class Inventory extends CommonObject } else { $this->db->rollback(); } + return $result; + } + + /** + * Set to Recorded + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function setRecorded(User $user, $notrigger = false) + { + $this->db->begin(); + + $result = $this->setStatut($this::STATUS_RECORDED, null, '', 'INVENTORY_RECORDED'); + + if ($result > 0) { + $this->db->commit(); + } else { + $this->db->rollback(); + return -1; + } + return $result; + } + + /** + * Set to Canceled + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function setCanceled(User $user, $notrigger = false) + { + $this->db->begin(); + + $result = $this->setStatut($this::STATUS_CANCELED, null, '', 'INVENTORY_CANCELED'); + + if ($result > 0) { + $this->db->commit(); + } else { + $this->db->rollback(); + return -1; + } + return $result; } /** @@ -566,9 +613,11 @@ class Inventory extends CommonObject $labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans('Started').')'; $labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); + $labelStatus[self::STATUS_RECORDED] = $langs->trans('Closed'); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Started'); $labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled'); + $labelStatusShort[self::STATUS_RECORDED] = $langs->trans('Closed'); return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', 'status'.$status, $mode); } @@ -628,6 +677,7 @@ class Inventory extends CommonObject public function initAsSpecimen() { $this->initAsSpecimenCommon(); + $this->title = ''; } } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index dea3b46c946..bc927a06c50 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -27,6 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; // Load translation files required by the page $langs->loadLangs(array("stocks", "other", "productbatch")); @@ -98,6 +99,90 @@ $now = dol_now(); * Actions */ +if ($action == 'cancel_record' && $permissiontoadd) { + $object->setCanceled($user); +} + +if ($action == 'update' && $user->rights->stock->mouvement->creer) { + $stockmovment = new MouvementStock($db); + $stockmovment->origin = $object; + + $db->begin(); + + $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; + $sql .= ' WHERE id.fk_inventory = '.$object->id; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $totalarray = array(); + while ($i < $num) { + $line = $db->fetch_object($resql); + $qty_stock = $line->qty_stock; + $qty_view = $line->qty_view; // The quantity viewed by inventorier, the qty we target + + if (!is_null($qty_view)) { + $stock_movement_qty = price2num($qty_view - $qty_stock, 'MS'); + if ($stock_movement_qty != 0) { + if ($stock_movement_qty < 0) { + $movement_type = 1; + } else { + $movement_type = 0; + } + + $datemovement = ''; + + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->id), 'INV'.$object->id, $datemovement, '', '', $line->batch); + if ($idstockmove < 0) { + $error++; + setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); + break; + } + } + } + $i++; + } + + if (!$error) { + $object->setRecorded($user); + } + } else { + setEventMessages($db->lasterror, null, 'errors'); + $error++; + } + + if (! $error) { + $db->commit(); + } else { + $db->rollbak(); + } +} + +if ($action =='updateinventorylines' && $permissiontoadd) { + $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; + $sql .= ' WHERE id.fk_inventory = '.$object->id; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $totalarray = array(); + while ($i < $num) { + $line = $db->fetch_object($resql); + $lineid = $line->rowid; + $inventoryline = new InventoryLine($db); + $inventoryline->fetch($lineid); + $inventoryline->qty_view = GETPOST("id_".$inventoryline->id); + $inventoryline->update($user); + $i++; + } + } +} + $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -180,22 +265,9 @@ if (empty($reshook)) { $form = new Form($db); $formproduct = new FormProduct($db); -llxHeader('', $langs->trans('Inventory'), ''); +$help_url = ''; -// Example : Adding jquery code -print ''; +llxHeader('', $langs->trans('Inventory'), $help_url); // Part to show record @@ -223,6 +295,18 @@ if ($object->id > 0) { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } + // Confirmation to close + if ($action == 'record') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $langs->trans('ConfirmFinish'), 'update', '', 0, 1); + $action = 'view'; + } + + // Confirmation to close + if ($action == 'confirm_cancel') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $langs->trans('ConfirmCancel'), 'cancel_record', '', 0, 1); + $action = 'view'; + } + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -238,7 +322,7 @@ if ($object->id > 0) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; /* @@ -306,25 +390,17 @@ if ($object->id > 0) { print dol_get_fiche_end(); - // Buttons for actions - if ($action == 'record') { - print '
    '; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } - print '
    '; - print ''.$langs->trans("InventoryDesc").'
    '; - print ''; - print '   '; - print ''; - print '
    '; - print '
    '; - print '
    '; - } else { + + // Buttons for actions + if ($action != 'record') { print '
    '."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -341,63 +417,98 @@ if ($object->id > 0) { } } - if ($object->status == Inventory::STATUS_VALIDATED) { + // Save + if ($object->status == $object::STATUS_VALIDATED) { + if ($object->status == Inventory::STATUS_VALIDATED) { + if ($permissiontoadd) { + print ''.$langs->trans("MakeMovementsAndClose").''."\n"; + } else { + print ''.$langs->trans('MakeMovementsAndClose').''."\n"; + } + } + if ($permissiontoadd) { - /* - if (!empty($conf->barcode->enabled)) { - print ''.$langs->trans("UpdateByScaningProductBarcode").''; - } - if (!empty($conf->productbatch->enabled)) { - print ''.$langs->trans('UpdateByScaningLot').''; - }*/ - if (!empty($conf->barcode->enabled) || !empty($conf->productbatch->enabled)) { - print ''.$langs->trans("UpdateByScaning").''; - } - } else { - print ''.$langs->trans("Save").''."\n"; + print ''.$langs->trans("Cancel").''."\n"; } } - - if ($object->status == Inventory::STATUS_VALIDATED) { - if ($permissiontoadd) { - print ''.$langs->trans("Finish").''."\n"; - } else { - print ''.$langs->trans('Finish').''."\n"; - } - } - - /*if ($object->status == Inventory::STATUS_VALIDATED) - { - if ($permissiontoadd) - { - print ''.$langs->trans("RecordVerb").''."\n"; - } - else - { - print ''.$langs->trans('RecordVerb').''."\n"; - } - }*/ } print '
    '."\n"; } + + + if ($object->status == Inventory::STATUS_VALIDATED) { + print '
    '; + if ($permissiontoadd) { + /* + if (!empty($conf->barcode->enabled)) { + print ''.$langs->trans("UpdateByScaningProductBarcode").''; + } + if (!empty($conf->productbatch->enabled)) { + print ''.$langs->trans('UpdateByScaningLot').''; + }*/ + if (!empty($conf->barcode->enabled) || !empty($conf->productbatch->enabled)) { + print ''.img_picto('', 'barcode', 'class="paddingrightonly"').$langs->trans("UpdateByScaning").''; + } + } else { + print ''.$langs->trans("Save").''."\n"; + } + if ($permissiontoadd && $conf->use_javascript_ajax) { + print ''.img_picto('', 'autofill', 'class="paddingrightonly"').$langs->trans('AutofillWithExpected').''; + + print ''; + } + print '
    '; + print '
    '; + print '
    '; + } + + + // Popup for mass barcode scanning if ($action == 'updatebyscaning') { - print '
    '; + print '
    '; + print ''."\n"; + print '
    '; + print '
    Barcode scanner tool...

    '; - print 'TODO'; + print ' Autodetect if we scan a product barcode or a lot/serial barcode
    '; + print ' Scan a product barcode
    '; + print ' Scan a product lot or serial number
    '; + print $langs->trans("QtyToAddAfterBarcodeScan").'
    '; + print ''; + + /*print '
    '.$langs->trans("or").'
    '; + + print '
    '; + + print '     Qty
    '; + */ + print '
    '; + print '
    '; + print '
    '; + + print ''.$langs->trans("FeatureNotYetAvailable").''; + + // TODO Add javascript so each scan will add qty into the inventory page + an ajax save. + + print '
    '; print '
    '; + print '
    '; } - print '
    '; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - print '
    '; //print '
    '; print '
    '; @@ -419,10 +530,12 @@ if ($object->id > 0) { print '
    '; print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''; - print '
    '; + print '
    '; - print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, 1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); + print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); print ''; @@ -440,7 +553,7 @@ if ($object->id > 0) { } print ''; - print ''; + print ''; //print ''; print ''; - print 'TODO'; + print ''; + print $obj->qty_stock; print ''; - print 'rowid).'">'; - print ''; - print ''.img_delete().''; - print ''; + print ''.img_delete().''; + print '
    '; - // Save - if ($object->status == $object::STATUS_VALIDATED) { - print '
    '; - print ''; - print '
    '; - } - print '
    '; + print '
    '; + print '
    '; print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 32d36d2d6f6..dc035187f30 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2020 Alexandre Spangaro + * Copyright (C) 2020-2021 Open-DSI * * 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 @@ -191,6 +191,8 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) { $isInEEC = isInEEC($mysoc); +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + // Definition of fields for lists $arrayfields = array( 'p.ref'=>array('label'=>"Ref", 'checked'=>1), @@ -226,12 +228,12 @@ $arrayfields = array( 'p.tobatch'=>array('label'=>"ManageLotSerial", 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60), 'p.fk_country'=>array('label'=>"Country", 'checked'=>0, 'position'=>100), 'p.fk_state'=>array('label'=>"State", 'checked'=>0, 'position'=>101), - 'p.accountancy_code_sell'=>array('label'=>"ProductAccountancySellCode", 'checked'=>0, 'position'=>400), - 'p.accountancy_code_sell_intra'=>array('label'=>"ProductAccountancySellIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), - 'p.accountancy_code_sell_export'=>array('label'=>"ProductAccountancySellExportCode", 'checked'=>0, 'position'=>402), - 'p.accountancy_code_buy'=>array('label'=>"ProductAccountancyBuyCode", 'checked'=>0, 'position'=>403), - 'p.accountancy_code_buy_intra'=>array('label'=>"ProductAccountancyBuyIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>404), - 'p.accountancy_code_buy_export'=>array('label'=>"ProductAccountancyBuyExportCode", 'checked'=>0, 'position'=>405), + $alias_product_perentity . '.accountancy_code_sell'=>array('label'=>"ProductAccountancySellCode", 'checked'=>0, 'position'=>400), + $alias_product_perentity . '.accountancy_code_sell_intra'=>array('label'=>"ProductAccountancySellIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), + $alias_product_perentity . '.accountancy_code_sell_export'=>array('label'=>"ProductAccountancySellExportCode", 'checked'=>0, 'position'=>402), + $alias_product_perentity . '.accountancy_code_buy'=>array('label'=>"ProductAccountancyBuyCode", 'checked'=>0, 'position'=>403), + $alias_product_perentity . '.accountancy_code_buy_intra'=>array('label'=>"ProductAccountancyBuyIntraCode", 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>404), + $alias_product_perentity . '.accountancy_code_buy_export'=>array('label'=>"ProductAccountancyBuyExportCode", 'checked'=>0, 'position'=>405), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Sell").')', 'checked'=>1, 'position'=>1000), @@ -358,8 +360,12 @@ if ($search_type != '' && $search_type != '-1') { $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,'; -$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,'; +$sql .= ' p.tobatch,'; +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +} else { + $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; +} $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -380,6 +386,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); +} if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; } @@ -464,7 +473,7 @@ if ($searchCategoryProductOperator == 1) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".$searchCategoryProduct.")"; + $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; } } if (!empty($searchCategoryProductSqlList)) { @@ -475,31 +484,31 @@ if ($fourn_id > 0) { $sql .= " AND pfp.fk_soc = ".((int) $fourn_id); } if ($search_country) { - $sql .= " AND p.fk_country = ".$search_country; + $sql .= " AND p.fk_country = ".((int) $search_country); } if ($search_state) { - $sql .= " AND p.fk_state = ".$search_state; + $sql .= " AND p.fk_state = ".((int) $search_state); } if ($search_finished >= 0 && $search_finished !== '') { - $sql .= " AND p.finished = ".$search_finished; + $sql .= " AND p.finished = ".((int) $search_finished); } if ($search_accountancy_code_sell) { - $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', $search_accountancy_code_sell); } if ($search_accountancy_code_sell_intra) { - $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); } if ($search_accountancy_code_sell_export) { - $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); } if ($search_accountancy_code_buy) { - $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', $search_accountancy_code_buy); } if ($search_accountancy_code_buy_intra) { - $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); } if ($search_accountancy_code_buy_export) { - $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); } // Add where from extra fields @@ -510,8 +519,12 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // No $sql .= $hookmanager->resPrint; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; $sql .= " p.fk_product_type, p.duration, p.finished, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; -$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,'; -$sql .= ' p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.pmp, p.cost_price, p.stock,'; +$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; +if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +} else { + $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; +} $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ', p.fk_unit, cu.label'; @@ -627,7 +640,7 @@ if ($resql) { $param = "&search_vatrate=".urlencode($search_vatrate); } if ($fourn_id > 0) { - $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); + $param .= "&fourn_id=".urlencode($fourn_id); } //if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); if ($show_childproducts) { @@ -756,7 +769,7 @@ if ($resql) { $moreforfilter = ''; if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); @@ -991,23 +1004,23 @@ if ($resql) { print ''.$formcompany->select_state($search_state, $search_country).''; } // Accountancy code sell - if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { print ''; } - if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { print ''; } - if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { print ''; } // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { print ''; } - if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { print ''; } - if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { print ''; } // Extra fields @@ -1154,23 +1167,23 @@ if ($resql) { if (!empty($arrayfields['p.fk_state']['checked'])) { print_liste_field_titre($arrayfields['p.fk_state']['label'], $_SERVER["PHP_SELF"], "p.fk_state", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { - print_liste_field_titre($arrayfields['p.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { + print_liste_field_titre($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], $alias_product_perentity . ".accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1491,9 +1504,9 @@ if ($resql) { print ''; if ($obj->tosell) { if ($obj->price_base_type == 'TTC') { - print price($obj->price_ttc).' '.$langs->trans("TTC"); + print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; } else { - print price($obj->price).' '.$langs->trans("HT"); + print ''.price($obj->price).' '.$langs->trans("HT").''; } } print ''; @@ -1517,7 +1530,7 @@ if ($resql) { // then reuse the cache array if we need prices for other price levels $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $sqlp .= " WHERE fk_product = ".$obj->rowid; + $sqlp .= " WHERE fk_product = ".((int) $obj->rowid); $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; $resultp = $db->query($sqlp); if ($resultp) { @@ -1546,9 +1559,9 @@ if ($resql) { print ''; if (!empty($productpricescache[$obj->rowid])) { if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { - print price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC"); + print ''.price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC").''; } else { - print price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT"); + print ''.price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT").''; } } print ''; @@ -1568,9 +1581,9 @@ if ($resql) { if ($product_fourn->product_fourn_price_id > 0) { if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); + print ''.$form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext).''; } else { - print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + print ''.price($product_fourn->fourn_unitprice).' '.$langs->trans("HT").''; } } } @@ -1606,14 +1619,14 @@ if ($resql) { // WAP if (!empty($arrayfields['p.pmp']['checked'])) { print ''; - print price($product_static->pmp, 1, $langs); + print ''.price($product_static->pmp, 1, $langs).""; print ''; } // Cost price if (!empty($arrayfields['p.cost_price']['checked'])) { print ''; //print $obj->cost_price; - print price($obj->cost_price).' '.$langs->trans("HT"); + print ''.price($obj->cost_price).' '.$langs->trans("HT").''; print ''; } @@ -1695,38 +1708,38 @@ if ($resql) { } } // Accountancy code sell - if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { print ''.$obj->accountancy_code_sell.''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { print ''.$obj->accountancy_code_sell_intra.''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { print ''.$obj->accountancy_code_sell_export.''; if (!$i) { $totalarray['nbfield']++; } } // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { print ''.$obj->accountancy_code_buy.''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { print ''.$obj->accountancy_code_buy_intra.''; if (!$i) { $totalarray['nbfield']++; } } - if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { + if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { print ''.$obj->accountancy_code_buy_export.''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 348d5956588..add915181a2 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -43,7 +43,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $object = new Product($db); if ($id > 0 || !empty($ref)) { @@ -52,6 +51,8 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->produit->creer; // Used by the include of actions_setnotes.inc.php +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 001635be24b..f23b6eae92d 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -42,7 +42,6 @@ $mode = GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : ''; if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -61,9 +60,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - $staticproduct = new Product($db); +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); + /* * View @@ -140,7 +140,7 @@ $sql .= ", ".MAIN_DB_PREFIX."product as p"; $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= " AND p.rowid = pd.fk_product"; if ($type !== '') { - $sql .= " AND fk_product_type = ".$type; + $sql .= " AND fk_product_type = ".((int) $type); } $sql .= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index ee86d43c09f..a08eaa8558b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -68,7 +68,6 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if ($id > 0 || !empty($ref)) { $object = new Product($db); @@ -83,6 +82,8 @@ if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productpricecard', 'globalcard')); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + /* * Actions @@ -429,12 +430,12 @@ if (empty($reshook)) { // Ajout / mise à jour if ($rowid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."product_price_by_qty SET"; - $sql .= " price='".$db->escape($price)."',"; - $sql .= " unitprice=".$unitPrice.","; - $sql .= " quantity=".$quantity.","; - $sql .= " remise_percent=".$remise_percent.","; - $sql .= " remise=".$remise; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " price=".((float) $price)."',"; + $sql .= " unitprice=".((float) $unitPrice).","; + $sql .= " quantity=".((float) $quantity).","; + $sql .= " remise_percent=".((float) $remise_percent).","; + $sql .= " remise=".((float) $remise); + $sql .= " WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -442,7 +443,7 @@ if (empty($reshook)) { } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values ("; - $sql .= $priceid.','.$price.','.$unitPrice.','.$quantity.','.$remise_percent.','.$remise.')'; + $sql .= ((int) $priceid).','.((float) $price).','.((float) $unitPrice).','.((float) $quantity).','.((float) $remise_percent).','.((float) $remise).')'; $result = $db->query($sql); if (!$result) { @@ -460,7 +461,7 @@ if (empty($reshook)) { $rowid = GETPOST('rowid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); $result = $db->query($sql); } else { @@ -472,7 +473,7 @@ if (empty($reshook)) { $priceid = GETPOST('priceid', 'int'); if (!empty($rowid)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".$priceid; + $sql .= " WHERE fk_product_price = ".((int) $priceid); $result = $db->query($sql); } else { @@ -1413,11 +1414,11 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p,"; $sql .= " ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE fk_product = ".$object->id; + $sql .= " WHERE fk_product = ".((int) $object->id); $sql .= " AND p.entity IN (".getEntity('productprice').")"; $sql .= " AND p.fk_user_author = u.rowid"; if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) { - $sql .= " AND p.price_level = ".$soc->price_level; + $sql .= " AND p.price_level = ".((int) $soc->price_level); } $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index e0d1d7447a0..342acb49b6e 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -35,13 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); - - $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); @@ -99,6 +92,10 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productreassortlist')); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); /* @@ -177,19 +174,19 @@ if ($snom) { $sql .= natural_search('p.label', $snom); } if (!empty($tosell)) { - $sql .= " AND p.tosell = ".$tosell; + $sql .= " AND p.tosell = ".((int) $tosell); } if (!empty($tobuy)) { - $sql .= " AND p.tobuy = ".$tobuy; + $sql .= " AND p.tobuy = ".((int) $tobuy); } if (!empty($canvas)) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } -if ($catid) { - $sql .= " AND cp.fk_categorie = ".$catid; +if ($catid > 0) { + $sql .= " AND cp.fk_categorie = ".((int) $catid); } if ($fourn_id > 0) { - $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; + $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter if ($search_categ) { @@ -307,7 +304,7 @@ if ($resql) { $moreforfilter = ''; if (!empty($conf->categorie->enabled)) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); $moreforfilter .= '
    '; } @@ -493,7 +490,10 @@ if ($resql) { if (!empty($conf->global->PRODUCT_USE_UNITS)) { print ''.$objp->unit_short.''; } - print ''.$langs->trans("Movements").''; + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("Movements").''; + print ''; print ''.$product->LibStatut($objp->statut, 5, 0).''; print ''.$product->LibStatut($objp->tobuy, 5, 1).''; // Fields from hook diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 5983d5e6b4e..38b16cea44a 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -37,13 +37,6 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'productbatch')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); - - $action = GETPOST('action', 'aZ09'); $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); @@ -89,6 +82,11 @@ if (!empty($canvas)) { $objcanvas->getCanvas('product', 'list', $canvas); } +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service', 0, 'product&product'); /* @@ -165,19 +163,19 @@ if ($snom) { $sql .= natural_search("p.label", $snom); } if (!empty($tosell)) { - $sql .= " AND p.tosell = ".$tosell; + $sql .= " AND p.tosell = ".((int) $tosell); } if (!empty($tobuy)) { - $sql .= " AND p.tobuy = ".$tobuy; + $sql .= " AND p.tobuy = ".((int) $tobuy); } if (!empty($canvas)) { $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; } -if ($catid) { - $sql .= " AND cp.fk_categorie = ".$catid; +if ($catid > 0) { + $sql .= " AND cp.fk_categorie = ".((int) $catid); } if ($fourn_id > 0) { - $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; + $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter if ($search_categ) { @@ -309,7 +307,7 @@ if ($resql) { $moreforfilter = ''; if (!empty($conf->categorie->enabled)) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); $moreforfilter .= '
    '; } @@ -482,7 +480,10 @@ if ($resql) { //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; print $objp->stock_physique; print ''; - print ''.$langs->trans("Movements").''; + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("Movements").''; + print ''; print ''.$product_static->LibStatut($objp->statut, 5, 0).''; print ''.$product_static->LibStatut($objp->tobuy, 5, 1).''; print ''; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index a47bc79c84a..2dae292884e 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -184,9 +184,8 @@ if ($result || empty($id)) { // Tag if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; - //$moreforfilter.='
    '; + $moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'paddingright'); $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); - //$moreforfilter.='
    '; print $moreforfilter; print ''; } @@ -205,7 +204,7 @@ if ($result || empty($id)) { $arrayyears[$currentyear] = $currentyear; } arsort($arrayyears); - print $form->selectarray('search_year', $arrayyears, $search_year, 1); + print $form->selectarray('search_year', $arrayyears, $search_year, 1, 0, 0, '', 0, 0, 0, '', 'width75'); print ''; print ''; print '
    '; @@ -337,7 +336,7 @@ if ($result || empty($id)) { $categ = new Categorie($db); $categ->fetch($search_categ); $listofprodids = $categ->getObjectsInCateg('product', 1); - $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; + $morefilters = ' AND d.fk_product IN ('.$db->sanitize((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; } if ($search_categ == -2) { $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index cb5087c63f2..fe8016f362a 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -153,16 +153,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 16dd040887d..bc8346e39b1 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -153,16 +153,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + $sql .= ' AND MONTH(c.date_commande) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + $sql .= ' AND YEAR(c.date_commande) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 93778a19047..e419593208c 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 271a834570b..fa7d4fae24f 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -170,16 +170,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_facture = f.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + $sql .= ' AND MONTH(f.datef) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + $sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index a42615fdaa9..018f1c28f02 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -153,16 +153,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_facture_fourn = f.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + $sql .= ' AND MONTH(f.datef) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + $sql .= ' AND YEAR(f.datef) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } $sql .= " ORDER BY $sortfield $sortorder "; diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 479dbdd1a17..1cabfd9ef85 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -140,7 +140,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product =".$product->id; if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " GROUP BY c.rowid, c.ref, c.date_valid, c.status"; //$sql .= ", s.nom, s.rowid, s.code_client"; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 7d08f3ab9c3..7dfc8b6d1db 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -154,16 +154,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_propal = p.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index e18dc17867f..86689786b2d 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -154,16 +154,16 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND d.fk_supplier_proposal = p.rowid"; $sql .= " AND d.fk_product =".$product->id; if (!empty($search_month)) { - $sql .= ' AND MONTH(p.datep) IN ('.$search_month.')'; + $sql .= ' AND MONTH(p.datep) IN ('.$db->sanitize($search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(p.datep) IN ('.$search_year.')'; + $sql .= ' AND YEAR(p.datep) IN ('.$db->sanitize($search_year).')'; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 294c31d49ba..7f2f8f58bb5 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -449,8 +449,10 @@ if ($action == 'create') { } print ''.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate, 'dayhour').' '; - print '('.$langs->trans("FullList").')'; + print dol_print_date($lastmovementdate, 'dayhour'); + print '     '; + print img_picto($langs->trans('LastMovement'), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("FullList").''; } else { print $langs->trans("None"); } @@ -515,11 +517,11 @@ if ($action == 'create') { print ""; print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); - print_liste_field_titre("Units", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); } - print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); @@ -628,13 +630,15 @@ if ($action == 'create') { if ($user->rights->stock->mouvement->creer) { print ''; - print img_picto($langs->trans("StockMovement"), 'uparrow.png', 'class="hideonsmartphone"').' '.$langs->trans("StockMovement"); + print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"'); + print $langs->trans("TransferStock"); print ""; } if ($user->rights->stock->creer) { print ''; - print $langs->trans("StockCorrection"); + print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"'); + print $langs->trans("CorrectStock"); print ""; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 9d601dc9687..214a12ead14 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -436,7 +436,7 @@ class Entrepot extends CommonObject $sql .= " model_pdf, import_key"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) { - $sql .= " WHERE rowid = '".$id."'"; + $sql .= " WHERE rowid = ".((int) $id); } else { $sql .= " WHERE entity = ".$conf->entity; if ($ref) { @@ -547,7 +547,7 @@ class Entrepot extends CommonObject $sql = "SELECT rowid, ref as label"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " WHERE entity IN (".getEntity('stock').")"; - $sql .= " AND statut = ".$status; + $sql .= " AND statut = ".((int) $status); $result = $this->db->query($sql); $i = 0; @@ -782,7 +782,7 @@ class Entrepot extends CommonObject $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $i = 0; while ($parentid > 0 && $i < $protection) { - $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid; + $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.((int) $parentid); $resql = $this->db->query($sql); if ($resql) { $objarbo = $this->db->fetch_object($resql); @@ -817,7 +817,7 @@ class Entrepot extends CommonObject $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot - WHERE fk_parent = '.$id; + WHERE fk_parent = '.((int) $id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8b2d729c29c..d8dad67bee2 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -488,7 +488,7 @@ class MouvementStock extends CommonObject if (!$error) { $sql = "SELECT rowid, reel FROM ".MAIN_DB_PREFIX."product_stock"; - $sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; // This is a unique key + $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); // This is a unique key dol_syslog(get_class($this)."::_create check if a record already exists in product_stock", LOG_DEBUG); $resql = $this->db->query($sql); @@ -544,12 +544,12 @@ class MouvementStock extends CommonObject { if ($alreadyarecord > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".$qty; - $sql .= " WHERE fk_entrepot = ".$entrepot_id." AND fk_product = ".$fk_product; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_stock SET reel = reel + ".((float) $qty); + $sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_stock"; $sql .= " (reel, fk_entrepot, fk_product) VALUES "; - $sql .= " (".$qty.", ".$entrepot_id.", ".$fk_product.")"; + $sql .= " (".((float) $qty).", ".((int) $entrepot_id).", ".((int) $fk_product).")"; } dol_syslog(get_class($this)."::_create update stock value", LOG_DEBUG); @@ -602,11 +602,11 @@ class MouvementStock extends CommonObject $newpmp = price2num($newpmp, 'MU'); // $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; - // $sql.= " WHERE rowid = ".$fk_product; + // $sql.= " WHERE rowid = ".((int) $fk_product); // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql - $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.","; + $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".((float) $newpmp).","; $sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; - $sql .= " WHERE rowid = ".$fk_product; + $sql .= " WHERE rowid = ".((int) $fk_product); dol_syslog(get_class($this)."::_create update AWP", LOG_DEBUG); $resql = $this->db->query($sql); @@ -763,7 +763,7 @@ class MouvementStock extends CommonObject $sql = "SELECT fk_product_pere, fk_product_fils, qty"; $sql .= " FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$idProduct; + $sql .= " WHERE fk_product_pere = ".((int) $idProduct); $sql .= " AND incdec = 1"; dol_syslog(get_class($this)."::_createSubProduct for parent product ".$idProduct, LOG_DEBUG); @@ -875,7 +875,7 @@ class MouvementStock extends CommonObject $nbSP=0; $resql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."product_association"; - $resql.= " WHERE fk_product_pere = ".$id; + $resql.= " WHERE fk_product_pere = ".((int) $id); if ($this->db->query($resql)) { $obj=$this->db->fetch_object($resql); @@ -896,7 +896,7 @@ class MouvementStock extends CommonObject $nb = 0; $sql = 'SELECT SUM(value) as nb from '.MAIN_DB_PREFIX.'stock_mouvement'; - $sql .= ' WHERE fk_product = '.$productidselected; + $sql .= ' WHERE fk_product = '.((int) $productidselected); $sql .= " AND datem < '".$this->db->idate($datebefore)."'"; dol_syslog(get_class($this).__METHOD__.'', LOG_DEBUG); @@ -1284,7 +1284,7 @@ class MouvementStock extends CommonObject $sql = "SELECT sum(pb.qty) as cpt"; $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."product_stock as ps ON ps.rowid = pb.fk_product_stock"; - $sql .= " WHERE ps.fk_product = " . $fk_product; + $sql .= " WHERE ps.fk_product = " . ((int) $fk_product); $sql .= " AND pb.batch = '" . $this->db->escape($batch) . "'"; $result = $this->db->query($sql); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9b6c0a38a1c..f05d6ebc168 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -275,7 +275,7 @@ class Productlot extends CommonObject $sql .= " t.import_key"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($product_id > 0 && $batch != '') { - $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".$product_id; + $sql .= " WHERE t.batch = '".$this->db->escape($batch)."' AND t.fk_product = ".((int) $product_id); } else { $sql .= ' WHERE t.rowid = '.((int) $id); } diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 88fc636e07e..aea8c3e1f14 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -196,7 +196,7 @@ class ProductStockEntrepot extends CommonObject if (!empty($id)) { $sql .= ' WHERE t.rowid = '.((int) $id); } else { - $sql .= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; + $sql .= ' WHERE t.fk_product = '.((int) $fk_product).' AND t.fk_entrepot = '.((int) $fk_entrepot); } $resql = $this->db->query($sql); diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index 34380efbe7a..a2a15a34e53 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -28,7 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'companies')); -$mesg = ''; + +$id = GETPOST('id', 'int'); // Security check $result = restrictedArea($user, 'stock'); @@ -43,18 +44,13 @@ $form = new Form($db); $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("WarehouseCard"), $help_url); -if ($_GET["id"]) { - if ($mesg) { - print $mesg; - } - +if ($id > 0) { $entrepot = new Entrepot($db); - $result = $entrepot->fetch($_GET["id"]); + $result = $entrepot->fetch($id); if ($result < 0) { dol_print_error($db); } - $head = stock_prepare_head($entrepot); print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock'); diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index d0415ccad78..1faa67ad860 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -39,7 +39,7 @@ function dolDispatchToDo($order_id) // Count nb of quantity dispatched per product $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $sql .= ' WHERE fk_commande = '.$order_id; + $sql .= ' WHERE fk_commande = '.((int) $order_id); $sql .= ' GROUP BY fk_product'; $sql .= ' ORDER by fk_product'; $resql = $db->query($sql); @@ -51,7 +51,7 @@ function dolDispatchToDo($order_id) // Count nb of quantity to dispatch per product $sql = 'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet'; - $sql .= ' WHERE fk_commande = '.$order_id; + $sql .= ' WHERE fk_commande = '.((int) $order_id); $sql .= ' AND fk_product > 0'; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= ' AND product_type = 0'; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 1aafe3c6ae2..c8054683e52 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -280,14 +280,14 @@ if ($result) { $line = $total = $totalsell = $totalStock = 0; while ($line < $totalnboflines) { $objp = $db->fetch_object($result); - $total += price2num($objp->estimatedvalue, 'MU'); - $totalsell += price2num($objp->sellvalue, 'MU'); + $total += $objp->estimatedvalue; + $totalsell += $objp->sellvalue; $totalStock += $objp->stockqty; $line++; } - $totalarray['val']['stockqty'] = $totalStock; - $totalarray['val']['estimatedvalue'] = $total; - $totalarray['val']['estimatedstockvaluesell'] = $totalsell; + $totalarray['val']['stockqty'] = price2num($totalStock, 'MS'); + $totalarray['val']['estimatedvalue'] = price2num($total, 'MT'); + $totalarray['val']['estimatedstockvaluesell'] = price2num($totalsell, 'MT'); } $sql .= $db->order($sortfield, $sortorder); @@ -633,7 +633,7 @@ if ($num) { if (!empty($arrayfields["estimatedvalue"]['checked'])) { print ''; if (price2num($obj->estimatedvalue, 'MT')) { - print price(price2num($obj->estimatedvalue, 'MT'), 1); + print ''.price(price2num($obj->estimatedvalue, 'MT'), 1).''; } else { print ''; } @@ -650,7 +650,9 @@ if ($num) { if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { print ''; if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print price(price2num($obj->sellvalue, 'MT'), 1); + if ($obj->sellvalue) { + print ''.price(price2num($obj->sellvalue, 'MT'), 1).''; + } } else { $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 830e8aa56e9..f2432ea25af 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2021 Laurent Destaileur * Copyright (C) 2014 Regis Houssin * * This program is free software: you can redistribute it and/or modify @@ -30,6 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/import/import_csv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; + +$confirm = GETPOST('confirm', 'alpha'); +$filetoimport = GETPOST('filetoimport'); // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); @@ -80,7 +86,7 @@ if (!empty($_SESSION['massstockmove'])) { * Actions */ -if ($action == 'addline') { +if ($action == 'addline' && !empty($user->rights->stock->mouvement->creer)) { if (!($id_product > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); @@ -142,7 +148,7 @@ if ($action == 'addline') { } } -if ($action == 'delline' && $idline != '') { +if ($action == 'delline' && $idline != '' && !empty($user->rights->stock->mouvement->creer)) { if (!empty($listofdata[$idline])) { unset($listofdata[$idline]); } @@ -153,7 +159,7 @@ if ($action == 'delline' && $idline != '') { } } -if ($action == 'createmovements') { +if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->creer)) { $error = 0; if (!GETPOST("label")) { @@ -288,6 +294,148 @@ if ($action == 'createmovements') { } } +if ($action == 'importCSV' && !empty($user->rights->stock->mouvement->creer)) { + dol_mkdir($conf->stock->dir_temp); + $nowyearmonth = dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + + $fullpath = $conf->stock->dir_temp."/".$user->id.'-csvfiletotimport.csv'; + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $fullpath, 1) > 0) { + dol_syslog("File ".$fullpath." was added for import"); + } else { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } + + if (!$error) { + $importcsv = new ImportCsv($db, 'massstocklist'); + //print $importcsv->separator; + + $nblinesrecord = $importcsv->import_get_nb_of_lines($fullpath)-1; + $importcsv->import_open_file($fullpath); + $labelsrecord = $importcsv->import_read_record(); + + if ($nblinesrecord < 1) { + setEventMessages($langs->trans("BadNumberOfLinesMustHaveAtLeastOneLinePlusTitle"), null, 'errors'); + } else { + $i=0; + $data = array(); + $productstatic = new Product($db); + $warehousestatics = new Entrepot($db); + $warehousestatict = new Entrepot($db); + while (($i < $nblinesrecord) && !$error) { + $data[] = $importcsv->import_read_record(); + if (count($data[$i]) == 1) { + // Only 1 empty line + unset($data[$i]); + $i++; + continue; + } + //var_dump($data); + $tmp_id_sw = $data[$i][0]['val']; + $tmp_id_tw = $data[$i][1]['val']; + $tmp_id_product = $data[$i][2]['val']; + $tmp_qty = $data[$i][3]['val']; + $tmp_batch = $data[$i][4]['val']; + + if (!is_numeric($tmp_id_product)) { + $result = fetchref($productstatic, $tmp_id_product); + $tmp_id_product = $result; + $data[$i][2]['val'] = $result; + } + if (!($tmp_id_product > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + + if (!is_numeric($tmp_id_sw)) { + $result = fetchref($warehousestatics, $tmp_id_sw); + $tmp_id_sw = $result; + $data[$i][0]['val'] = $result; + } + if (!($tmp_id_sw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + + if (!is_numeric($tmp_id_tw)) { + $result = fetchref($warehousestatict, $tmp_id_tw); + $tmp_id_tw = $result; + $data[$i][1]['val'] = $result; + } + if (!($tmp_id_tw > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); + } + + if ($tmp_id_sw > 0 && $tmp_id_tw == $tmp_id_sw) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors'); + } + if (!$tmp_qty) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); + } + + // Check a batch number is provided if product need it + if (!$error) { + $producttmp = new Product($db); + $producttmp->fetch($tmp_id_product); + if ($producttmp->hasbatch()) { + if (empty($tmp_batch)) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null, 'errors'); + } + } + } + + $i++; + } + + if (!$error) { + foreach ($data as $key => $value) { + if (count(array_keys($listofdata)) > 0) { + $id = max(array_keys($listofdata)) + 1; + } else { + $id = 1; + } + $tmp_id_sw = $data[$key][0]['val']; + $tmp_id_tw = $data[$key][1]['val']; + $tmp_id_product = $data[$key][2]['val']; + $tmp_qty = $data[$key][3]['val']; + $tmp_batch = $data[$key][4]['val']; + $listofdata[$key] = array('id'=>$key, 'id_sw'=>$tmp_id_sw, 'id_tw'=>$tmp_id_tw, 'id_product'=>$tmp_id_product, 'qty'=>$tmp_qty, 'batch'=>$tmp_batch); + } + } + } + } + + $_SESSION['massstockmove'] = json_encode($listofdata); +} + +if ($action == 'confirm_deletefile' && $confirm == 'yes') { + $langs->load("other"); + + $param = '&datatoimport='.urlencode($datatoimport).'&format='.urlencode($format); + if ($excludefirstline) { + $param .= '&excludefirstline='.urlencode($excludefirstline); + } + if ($endatlinenb) { + $param .= '&endatlinenb='.urlencode($endatlinenb); + } + + $file = $conf->stock->dir_temp.'/'.GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret = dol_delete_file($file); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; +} /* @@ -315,7 +463,79 @@ $buttonrecord = $langs->trans("RecordMovement"); $titletoaddnoent = $langs->transnoentitiesnoconv("Select"); $buttonrecordnoent = $langs->transnoentitiesnoconv("RecordMovement"); print ''.$langs->trans("SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).'
    '; -print '
    '."\n"; + +print '
    '; + +// Form to upload a file +print '
    '; +print ''; +print ''; +print ''; +print ''; +print $langs->trans("or").' '; +$importcsv = new ImportCsv($db, 'massstocklist'); +print $form->textwithpicto($langs->trans('SelectAStockMovementFileToImport'), $langs->transnoentitiesnoconv("InfoTemplateImport", $importcsv->separator)); +print ''; + +print '     '; +$out = (empty($conf->global->MAIN_UPLOAD_DOC) ? ' disabled' : ''); +print ''; +$out = ''; +if (!empty($conf->global->MAIN_UPLOAD_DOC)) { + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) { + $maxphp = $maxphp * 1; + } + if (preg_match('/m$/i', $maxphp)) { + $maxphp = $maxphp * 1024; + } + if (preg_match('/g$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp)) { + $maxphp = $maxphp * 1024 * 1024 * 1024; + } + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1; + } + if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024; + } + if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024; + } + if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; + } + // Now $max and $maxphp and $maxphp2 are in Kb + $maxmin = $max; + $maxphptoshow = $maxphptoshowparam = ''; + if ($maxphp > 0) { + $maxmin = min($max, $maxphp); + $maxphptoshow = $maxphp; + $maxphptoshowparam = 'upload_max_filesize'; + } + if ($maxphp2 > 0) { + $maxmin = min($max, $maxphp2); + if ($maxphp2 < $maxphp) { + $maxphptoshow = $maxphp2; + $maxphptoshowparam = 'post_max_size'; + } + } + + $langs->load('other'); + $out .= ' '; + $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1); +} else { + $out .= ' ('.$langs->trans("UploadDisabled").')'; +} +print $out; + +print '
    '; + +print '

    '; // Form to add a line print '
    '; @@ -325,7 +545,6 @@ print ''; print '
    '; print ''; -//print '
    '; $param = ''; @@ -340,18 +559,17 @@ print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $pa print getTitleFieldOfList('', 0); print ''; - print '
    '; // From warehouse print ''; // To warehouse print ''; // Product -print ''; // Batch number if ($conf->productbatch->enabled) { print ''; } @@ -377,31 +597,44 @@ print ''; - print ''; - print ''; - print ''; - if ($conf->productbatch->enabled) { - print ''; + if ($productstatic->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + } + if ($warehousestatics->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); + } + if ($warehousestatics->id <= 0) { + $error++; + setEventMessages($langs->trans("ObjectNotFound", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); } - print ''; - print ''; - print ''; + if (!$error) { + print ''; + print ''; + print ''; + print ''; + if ($conf->productbatch->enabled) { + print ''; + } + print ''; + print ''; + print ''; + } } print '
    '; -print $formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); print ''; -print $formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); +print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200'); print ''; +print ''; $filtertype = 0; if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $filtertype = ''; @@ -362,11 +580,13 @@ if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) { $limit = $conf->global->PRODUIT_LIMIT_SIZE; } -$form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1); +print img_picto($langs->trans("Product"), 'product', 'class="paddingright"'); +print $form->select_produits($id_product, 'productid', $filtertype, $limit, 0, -1, 2, '', 1, array(), 0, '1', 0, 'minwidth200imp maxwidth300', 1, '', null, 1); print ''; + print img_picto($langs->trans("LotSerial"), 'lot', 'class="paddingright"'); print ''; print ''; - foreach ($listofdata as $key => $val) { $productstatic->fetch($val['id_product']); $warehousestatics->fetch($val['id_sw']); $warehousestatict->fetch($val['id_tw']); - print '
    '; - print $warehousestatics->getNomUrl(1); - print ''; - print $warehousestatict->getNomUrl(1); - print ''; - print $productstatic->getNomUrl(1).' - '.$productstatic->label; - print ''; - print $val['batch']; - print ''.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '; + print $warehousestatics->getNomUrl(1); + print ''; + print $warehousestatict->getNomUrl(1); + print ''; + print $productstatic->getNomUrl(1).' - '.$productstatic->label; + print ''; + print $val['batch']; + print ''.$val['qty'].''.img_delete($langs->trans("Remove")).'
    '; @@ -409,33 +642,67 @@ print '
    '; print '
    '; - print '
    '; +// Form to validate all movements +if (count($listofdata)) { + print '
    '; + print ''; + print ''; -print ''; -print ''; -print ''; + // Button to record mass movement + $codemove = (GETPOSTISSET("codemove") ? GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); + $labelmovement = GETPOST("label") ? GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); -// Button to record mass movement -$codemove = (GETPOSTISSET("codemove") ? GETPOST("codemove", 'alpha') : dol_print_date(dol_now(), '%Y%m%d%H%M%S')); -$labelmovement = GETPOST("label") ? GETPOST('label') : $langs->trans("StockTransfer").' '.dol_print_date($now, '%Y-%m-%d %H:%M'); + print '
    '; + print ''.$langs->trans("InventoryCode").': '; + print '   '; + print ''; + print $langs->trans("MovementLabel").': '; + print '
    '; + print '
    '; -print '
    '; -print ''.$langs->trans("InventoryCode").': '; -print '   '; -print ''; -print $langs->trans("MovementLabel").': '; -print '
    '; -print '
    '; + print '
    '; -print '
    '; + print '
    '; + print '
    '; -print '
    '; -print '
    '; + print '
    '; +} -print ''; +if ($action == 'delete') { + print $form->formconfirm($_SERVER["PHP_SELF"].'?urlfile='.urlencode(GETPOST('urlfile')).'&step=3'.$param, $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); +} // End of page llxFooter(); $db->close(); + +/** + * Verify if $haystack startswith $needle + * + * @param string $haystack string to test + * @param string $needle string to find + * @return bool false if Ko true else + */ +function startsWith($haystack, $needle) +{ + $length = strlen($needle); + return substr($haystack, 0, $length) === $needle; +} + +/** + * Fetch object with ref + * + * @param Object $static_object static object to fetch + * @param string $tmp_ref ref of the object to fetch + * @return int <0 if Ko or Id of object + */ +function fetchref($static_object, $tmp_ref) +{ + if (startsWith($tmp_ref, 'ref:')) { + $tmp_ref = str_replace('ref:', '', $tmp_ref); + } + $static_object->fetch('', $tmp_ref); + return $static_object->id; +} diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 6dc3c665e15..3221c23aa8d 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -179,7 +179,7 @@ if ($action == "correct_stock") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'correction'; } - if (!is_numeric($_POST["nbpiece"])) { + if (!is_numeric(GETPOST("nbpiece"))) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $action = 'correction'; @@ -456,7 +456,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) { - $sql .= " AND m.rowid = ".$msid; + $sql .= " AND m.rowid = ".((int) $msid); } $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; @@ -464,7 +464,7 @@ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= " AND p.fk_product_type = 0"; } if ($id > 0) { - $sql .= " AND e.rowid ='".$id."'"; + $sql .= " AND e.rowid = ".((int) $id); } $sql .= dolSqlDateFilter('m.datem', 0, $month, $year); if ($idproduct > 0) { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 62cbe7f8620..50982e0e084 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -247,7 +247,7 @@ if ($action == "correct_stock") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action = 'correction'; } - if (!is_numeric($_POST["nbpiece"])) { + if (!is_numeric(GETPOST("nbpiece"))) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $action = 'correction'; @@ -503,7 +503,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) { - $sql .= " AND m.rowid = ".$msid; + $sql .= " AND m.rowid = ".((int) $msid); } $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; @@ -511,7 +511,7 @@ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= " AND p.fk_product_type = 0"; } if ($id > 0) { - $sql .= " AND e.rowid ='".$id."'"; + $sql .= " AND e.rowid = ".((int) $id); } if (!empty($search_date_start)) { $sql .= " AND m.datem >= '" . $db->idate($search_date_start) . "'"; @@ -836,9 +836,9 @@ if ($resql) { } if ($id > 0) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } // Add code for pre mass action (confirmation or email presend form) @@ -886,6 +886,7 @@ if ($resql) { print ''; } if (! empty($arrayfields['m.datem']['checked'])) { + // Date 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'), 'tzuserrel'); @@ -1014,7 +1015,7 @@ if ($resql) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['m.datem']['checked'])) { - print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); @@ -1125,11 +1126,14 @@ if ($resql) { print ''; // Id movement if (!empty($arrayfields['m.rowid']['checked'])) { - print ''.$objp->mid.''; // This is primary not movement id + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print $objp->mid; + print ''; // This is primary not movement id } if (!empty($arrayfields['m.datem']['checked'])) { // Date - print ''.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').''; + print ''.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').''; } if (!empty($arrayfields['p.ref']['checked'])) { // Product ref diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index e45f48d9ef8..f6d77bdb6c0 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -564,7 +564,9 @@ if ($id > 0 || $ref) { print ''; // AWP - print ''.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).''; + print ''; + print $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")); + print ''; print ''; if ($object->pmp > 0) { print price($object->pmp).' '.$langs->trans("HT"); @@ -765,8 +767,11 @@ if ($id > 0 || $ref) { print ''.$langs->trans("LastMovement").''; if ($lastmovementdate) { print dol_print_date($lastmovementdate, 'dayhour').' '; - print '    '.$langs->trans("FullList").''; + print '     '; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("FullList").''; } else { + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); print ''.$langs->trans("None").''; } print ""; @@ -811,20 +816,19 @@ if (empty($reshook)) { if ($user->rights->stock->mouvement->creer) { if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print ''.$langs->trans("CorrectStock").''; + print ''.$langs->trans("TransferStock").''; } else { - print ''.$langs->trans("CorrectStock").''; + print ''.$langs->trans("TransferStock").''; } } else { print ''.$langs->trans("CorrectStock").''; } - //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { if (!$variants || !empty($conf->global->VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT)) { - print ''.$langs->trans("TransferStock").''; + print ''.$langs->trans("CorrectStock").''; } else { - print ''.$langs->trans("TransferStock").''; + print ''.$langs->trans("CorrectStock").''; } } else { print ''.$langs->trans("CorrectStock").''; @@ -850,28 +854,32 @@ if (!$variants) { print ''.$langs->trans("EstimatedStockValueShort").''; print ''.$langs->trans("SellPriceMin").''; print ''.$langs->trans("EstimatedStockValueSellShort").''; + print ''; + print ''; print ''; if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { $colspan = 3; - print ''; - print ''.$langs->trans("batch_number").''; + print ''; + print ''.$langs->trans("batch_number").''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { $colspan--; - print ''.$langs->trans("EatByDate").''; + print ''.$langs->trans("EatByDate").''; } if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { $colspan--; - print ''.$langs->trans("SellByDate").''; + print ''.$langs->trans("SellByDate").''; } print ''; print ''; print ''; print ''; print ''; + print ''; + print ''; print ''; } - $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; + $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut as status, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; @@ -901,7 +909,8 @@ if (!$variants) { $entrepotstatic->label = $obj->ref; $entrepotstatic->lieu = $obj->lieu; $entrepotstatic->fk_parent = $obj->fk_parent; - $entrepotstatic->statut = $obj->statut; + $entrepotstatic->statut = $obj->status; + $entrepotstatic->status = $obj->status; $stock_real = price2num($obj->reel, 'MS'); print ''; @@ -922,10 +931,13 @@ if (!$variants) { // Value sell print ''; if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print price(price2num($object->price * $obj->reel, 'MT'), 1).''; + print price(price2num($object->price * $obj->reel, 'MT'), 1); } else { print $langs->trans("Variable"); } + print ''; + print ''; + print ''; print ''; $total += $obj->reel; if (price2num($object->pmp)) { @@ -967,16 +979,14 @@ if (!$variants) { print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } else { - print "\n".''; - print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"').' '; - print 'id.'">'.$langs->trans("TransferStock").''; - // Disabled, because edition of stock content must use the "Correct stock menu". - // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... - //print 'id.'#'.$pdluo->id.'">'; - //print img_edit().''; - print ''; + print "\n".''; + print ''; + print ''; print $product_lot_static->getNomUrl(1); print ''; $colspan = 3; @@ -990,6 +1000,30 @@ if (!$variants) { } print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; print ''; + print ''; + if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) { + print 'id.'">'; + print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"'); + print $langs->trans("TransferStock"); + print ''; + // Disabled, because edition of stock content must use the "Correct stock menu". + // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... + //print 'id.'#'.$pdluo->id.'">'; + //print img_edit().''; + } + print ''; + print ''; + if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) { + print 'id.'">'; + print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"'); + print $langs->trans("CorrectStock"); + print ''; + // Disabled, because edition of stock content must use the "Correct stock menu". + // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... + //print 'id.'#'.$pdluo->id.'">'; + //print img_edit().''; + } + print ''; print ''; } } @@ -1025,6 +1059,8 @@ if (!$variants) { print $langs->trans("Variable"); } print ''; + print ''; + print ''; print ""; print ""; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 904fa9b7e94..393fbc73ae2 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -205,7 +205,7 @@ if ($action == 'order' && GETPOST('valid')) { $order = new CommandeFournisseur($db); // Check if an order for the supplier exists $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; - $sql .= " WHERE fk_soc = ".$suppliersid[$i]; + $sql .= " WHERE fk_soc = ".((int) $suppliersid[$i]); $sql .= " AND source = 42 AND fk_statut = 0"; $sql .= " AND entity IN (".getEntity('commande_fournisseur').")"; $sql .= " ORDER BY date_creation DESC"; @@ -756,7 +756,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if (!empty($conf->global->MAIN_MULTILANGS)) { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; - $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' WHERE fk_product = '.((int) $objp->rowid); $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 5a3b0cb0a9c..d9a9be0cd70 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -133,7 +133,7 @@ if ($date && $dateIsValid) { // Avoid heavy sql if mandatory date is not defined $sql .= " WHERE w.entity IN (".getEntity('stock').")"; $sql .= " AND w.rowid = ps.fk_entrepot"; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { - $sql .= " AND w.statut IN (".$db->sanitize($db->escape(implode(',', $warehouseStatus))).")"; + $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } if ($productid > 0) { $sql .= " AND ps.fk_product = ".$productid; @@ -183,7 +183,7 @@ if ($date && $dateIsValid) { $sql .= " WHERE w.entity IN (".getEntity('stock').")"; $sql .= " AND w.rowid = sm.fk_entrepot"; if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { - $sql .= " AND w.statut IN (".$db->sanitize($db->escape(implode(',', $warehouseStatus))).")"; + $sql .= " AND w.statut IN (".$db->sanitize(implode(',', $warehouseStatus)).")"; } if ($mode == 'future') { $sql .= " AND sm.datem <= '".$db->idate($dateendofday)."'"; @@ -191,10 +191,10 @@ if ($date && $dateIsValid) { $sql .= " AND sm.datem >= '".$db->idate($date)."'"; } if ($productid > 0) { - $sql .= " AND sm.fk_product = ".$productid; + $sql .= " AND sm.fk_product = ".((int) $productid); } if ($fk_warehouse > 0) { - $sql .= " AND sm.fk_entrepot = ".$fk_warehouse; + $sql .= " AND sm.fk_entrepot = ".((int) $fk_warehouse); } $sql .= " GROUP BY sm.fk_product, sm.fk_entrepot"; $resql = $db->query($sql); @@ -487,7 +487,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { { $sql = 'SELECT label,description'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product_lang'; - $sql .= ' WHERE fk_product = '.$objp->rowid; + $sql .= ' WHERE fk_product = '.((int) $objp->rowid); $sql .= ' AND lang = "'.$langs->getDefaultLang().'"'; $sql .= ' LIMIT 1'; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index e98244e5eed..dcd19be4ad6 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -72,7 +72,10 @@ print ''; if ($object->element == 'product') { print ''.$langs->trans("WarehouseSource").''; print ''; - print img_picto('', 'stock').$formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); + print img_picto('', 'stock'); + $selected = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))); + $warehousestatus = 'warehouseopen,warehouseinternal'; + print $formproduct->selectWarehouses($selected, 'id_entrepot', $warehousestatus, 1); print ''; } if ($object->element == 'stock') { diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index c49ca736bbb..fe2188de904 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -454,7 +454,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // project i have permission on } if ($mine) { // this may duplicate record if we are contact twice - $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; + $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id; } if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 1309ae4455e..5b238d96b92 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -50,7 +50,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); $hookmanager->initHooks(array('timesheetperdaycard')); @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", "int") ?GETPOST("year", "int") : (GETPOST("addtimeyear", "int") ?GETPOST("addtimeyear", "int") : date("Y"))); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", "int") ?GETPOST("month", "int") : (GETPOST("addtimemonth", "int") ?GETPOST("addtimemonth", "int") : date("m"))); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$search_categ = GETPOST("search_categ", 'alpha'); +//$search_categ = GETPOST("search_categ", 'alpha'); $search_usertoprocessid = GETPOST('search_usertoprocessid', 'int'); $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); @@ -117,6 +113,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $arrayfields = array(); $arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15); /*$arrayfields=array( // Project 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), @@ -153,7 +150,7 @@ if ($reshook < 0) { // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $action = ''; - $search_categ = ''; + //$search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -403,12 +400,13 @@ llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); $param = ''; $param .= ($mode ? '&mode='.urlencode($mode) : ''); $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : ''); -$param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); +$param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : ''); $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : ''); $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : ''); $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : ''); -/*$search_array_options=$search_array_options_project; +/* +$search_array_options = $search_array_options_project; $search_options_pattern='search_options_'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ @@ -422,9 +420,7 @@ $nav = '".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day")." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; @@ -504,18 +500,18 @@ $includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); +$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
    '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } @@ -561,14 +557,16 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; -print ''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -print ''; +if (!empty($arrayfields['t.progress']['checked'])) { + print ''; +} +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} print ''; print ''; print ''; @@ -592,19 +590,20 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; } if (!empty($arrayfields['t.progress']['checked'])) { print ''.$langs->trans("ProgressDeclared").''; } -/*print ''.$langs->trans("TimeSpent").''; -if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; -else print ''.$langs->trans("TimeSpentByUser").'';*/ -print ''.$langs->trans("TimeSpent").'
    '; -print 'Photo'; -print ''.$langs->trans("Everybody").''; -print ''; -print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''.$langs->trans("TimeSpent").'
    '; + print ''; + print 'Photo'; + print ''.$langs->trans("Everybody").''; + print ''; + print ''; + print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; +} print ''.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to @@ -656,13 +655,17 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan = 4 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); +$colspan = 2 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; print ''; print $langs->trans("Total"); print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; @@ -721,6 +724,10 @@ if (count($tasksarray) > 0) { print ''; print $langs->trans("OtherFilteredTasks"); print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; print ''; $timeonothertasks = ($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); @@ -743,6 +750,10 @@ if (count($tasksarray) > 0) { print ''; print $langs->trans("Total"); print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index d023dcc69d3..43cdfa863f5 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -48,7 +48,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); // Security check $socid = 0; @@ -57,10 +57,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear') ?GETPOST('reyear', 'int') : (GETPOST("year") ?GETPOST("year", "int") : date("Y")); $month = GETPOST('remonth') ?GETPOST('remonth', 'int') : (GETPOST("month") ?GETPOST("month", "int") : date("m")); @@ -68,7 +64,7 @@ $day = GETPOST('reday') ?GETPOST('reday', 'int') : (GETPOST("day") ?GETPOST("day $day = (int) $day; $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); -$search_categ = GETPOST("search_categ", 'alpha'); +//$search_categ = GETPOST("search_categ", 'alpha'); $search_usertoprocessid = GETPOST('search_usertoprocessid', 'int'); $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); @@ -119,7 +115,7 @@ if ($reshook < 0) { // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $action = ''; - $search_categ = ''; + //$search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -349,9 +345,7 @@ $param .= ($search_task_label ? '&search_task_label='.$search_task_label : ''); $nav = ''.img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav.="   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav.=' '; $nav .= ' '; $picto = 'clock'; @@ -428,18 +422,18 @@ $includeonly = 'hierachyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
    '; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } @@ -491,9 +485,11 @@ print ''.$langs->trans("ProgressDeclared"). /*print ''.$langs->trans("TimeSpent").''; if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ -print ''.$langs->trans("TimeSpent").'
    '; +print ''.$langs->trans("TimeSpent").'
    '; +print ''; print 'Photo'; print ''.$langs->trans("Everybody").''; +print ''; print ''; print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 028bb97726c..c413b5e0533 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -50,7 +50,7 @@ if ($mode == 'mine') { $mine = 1; } -$projectid = isset($_GET["id"]) ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); +$projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int"); $hookmanager->initHooks(array('timesheetperweekcard')); @@ -61,10 +61,6 @@ $socid = 0; $result = restrictedArea($user, 'projet', $projectid); $now = dol_now(); -$nowtmp = dol_getdate($now); -$nowday = $nowtmp['mday']; -$nowmonth = $nowtmp['mon']; -$nowyear = $nowtmp['year']; $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y")); $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m")); @@ -73,7 +69,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = (int) $day; -$search_categ = GETPOST("search_categ", 'alpha'); +//$search_categ = GETPOST("search_categ", 'alpha'); $search_usertoprocessid = GETPOST('search_usertoprocessid', 'int'); $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); @@ -129,8 +125,9 @@ $arrayfields = array(); 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), );*/ -$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>0); -$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>0); +$arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>5); +$arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>10); +$arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15); /*foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field @@ -165,7 +162,7 @@ if ($reshook < 0) { // Purge criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $action = ''; - $search_categ = ''; + //$search_categ = ''; $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; @@ -184,7 +181,9 @@ if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') | } if (GETPOST('submitdateselect')) { - $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) { + $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + } $action = ''; } @@ -441,9 +440,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $nav = ''.img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; $nav .= ''.img_next($langs->trans("Next"))."\n"; -//$nav .= "   (".$langs->trans("Today").")"; $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' '; -//$nav .= ' '; $nav .= ' '; $picto = 'clock'; @@ -559,18 +556,18 @@ $includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright"').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= ''; if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) { $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright"').''; $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company').''; + $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright"').''; $moreforfilter .= '
    '; } @@ -618,14 +615,16 @@ $search_options_pattern = 'search_task_options_'; $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; -print ''; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { print ''; } -print ''; +if (!empty($arrayfields['t.progress']['checked'])) { + print ''; +} +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; +} for ($idw = 0; $idw < 7; $idw++) { print ''; } @@ -649,20 +648,20 @@ $extrafieldsobjectkey = 'projet_task'; $extrafieldsobjectprefix = 'efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; } if (!empty($arrayfields['t.progress']['checked'])) { print ''.$langs->trans("ProgressDeclared").''; } -/*print ''.$langs->trans("TimeSpent").''; - if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; - else print ''.$langs->trans("TimeSpentByUser").'';*/ -print ''.$langs->trans("TimeSpent").'
    '; -print 'Photo'; -print ''.$langs->trans("Everybody").''; -print ''; -print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; - +if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''.$langs->trans("TimeSpent").'
    '; + print ''; + print 'Photo'; + print ''.$langs->trans("Everybody").''; + print ''; + print ''; + print ''.$langs->trans("TimeSpent").($usertoprocess->firstname ? '
    '.$usertoprocess->getNomUrl(-2).''.dol_trunc($usertoprocess->firstname, 10).'' : '').''; +} for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); @@ -691,7 +690,7 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$colspan = 3 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); +$colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2); if ($conf->use_javascript_ajax) { print ''; @@ -699,7 +698,10 @@ if ($conf->use_javascript_ajax) { print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; - + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -778,6 +780,10 @@ if (count($tasksarray) > 0) { print ''; print $langs->trans("OtherFilteredTasks"); print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. @@ -799,11 +805,15 @@ if (count($tasksarray) > 0) { } if ($conf->use_javascript_ajax) { - print ' - '; - print $langs->trans("Total"); - print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; - print ''; + print ''; + print ''; + print $langs->trans("Total"); + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print ''; + if (!empty($arrayfields['timeconsumed']['checked'])) { + print ''; + print ''; + } for ($idw = 0; $idw < 7; $idw++) { $cssweekend = ''; @@ -824,8 +834,8 @@ if (count($tasksarray) > 0) { print '
     
    '; } - print '
     
    - '; + print '
     
    '; + print ''; } } else { print ''.$langs->trans("NoAssignedTasks").''; diff --git a/htdocs/projet/ajax/index.html b/htdocs/projet/ajax/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/projet/ajax/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 74d9236d26d..5264fa02596 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -49,15 +49,18 @@ require '../../main.inc.php'; $htmlname = GETPOST('htmlname', 'aZ09'); $socid = GETPOST('socid', 'int'); +$mode = GETPOST('mode', 'aZ09'); $discard_closed = GETPOST('discardclosed', 'int'); +// Security check +restrictedArea($user, 'projet', 0, 'projet&project'); + /* * View */ dol_syslog("Call ajax projet/ajax/projects.php"); -//dol_syslog(join(',', $_GET)); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -68,7 +71,7 @@ if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { } // Mode to get list of projects -if (!GETPOST('mode', 'aZ09') || GETPOST('mode', 'aZ09') != 'gettasks') { +if (empty($mode) || $mode != 'gettasks') { // When used from jQuery, the search term is added as GET param "term". $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : ''); @@ -77,7 +80,7 @@ if (!GETPOST('mode', 'aZ09') || GETPOST('mode', 'aZ09') != 'gettasks') { } // Mode to get list of tasks -if (GETPOST('mode', 'aZ09') == 'gettasks') { +if ($mode == 'gettasks') { $formproject = new FormProjets($db); $formproject->selectTasks((!empty($$socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), ''); return; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 5d0f197568c..e39869c409f 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -52,7 +52,7 @@ $status = GETPOST('status', 'int'); $opp_status = GETPOST('opp_status', 'int'); $opp_percent = price2num(GETPOST('opp_percent', 'alpha')); -if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !$_POST["cancel"])) { +if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && !GETPOST("cancel"))) { accessforbidden(); } @@ -78,17 +78,17 @@ if ($id > 0 || !empty($ref)) { } } -// Security check -$socid = GETPOST('socid', 'int'); -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); - // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int')); +// Security check +$socid = GETPOST('socid', 'int'); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +restrictedArea($user, 'projet', $object->id, 'projet&project'); + /* * Actions @@ -224,12 +224,10 @@ if (empty($reshook)) { if (empty($ref)) { $error++; - //$_GET["id"]=$_POST["id"]; // We return on the project card setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (empty($_POST["title"])) { + if (!GETPOST("title")) { $error++; - //$_GET["id"]=$_POST["id"]; // We return on the project card setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ProjectLabel")), null, 'errors'); } @@ -512,7 +510,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Ref - $suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref); + $suggestedref = (GETPOST("ref") ? GETPOST("ref") : $defaultref); print ''.$langs->trans("Ref").''; print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); print ''; @@ -842,7 +840,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print '
    '; } if (!empty($conf->eventorganization->enabled)) { - print ' '; + print 'usage_organize_event ? ' checked="checked"' : '')) . '"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } @@ -978,7 +976,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index c650512c5dd..6a08aa7a4bd 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -103,6 +103,10 @@ class Projects extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -131,14 +135,14 @@ class Projects extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Select projects of given category if ($category > 0) { diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 518b3576e34..cd6df68d590 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -109,6 +109,10 @@ class Tasks extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->projet->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -135,14 +139,14 @@ class Tasks extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Add sql filters if ($sqlfilters) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 137757eae1a..50ac450e136 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -104,9 +104,52 @@ class Project extends CommonObject */ public $user_close_id; public $public; //!< Tell if this is a public or private project + + /** + * @var float budget Amount + */ public $budget_amount; + + /** + * @var integer Can use projects to follow opportunities + */ + public $usage_opportunity; + + /** + * @var integer Can follow tasks on project and enter time spent on it + */ + public $usage_task; + + /** + * @var integer Use to bill task spend time + */ public $usage_bill_time; // Is the time spent on project must be invoiced or not + /** + * @var integer Event organization: Use Event Organization + */ + public $usage_organize_event; + + /** + * @var integer Event organization: Allow unknown people to suggest new conferences + */ + public $accept_conference_suggestions; + + /** + * @var integer Event organization: Allow unknown people to suggest new booth + */ + public $accept_booth_suggestions; + + /** + * @var float Event organization: registration price + */ + public $price_registration; + + /** + * @var float Event organization: booth price + */ + public $price_booth; + public $statuts_short; public $statuts_long; @@ -463,7 +506,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions = ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null"); $sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -653,19 +696,19 @@ class Project extends CommonObject $ids = $this->id; if ($type == 'agenda') { - $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project IN (".$ids.") AND entity IN (".getEntity('agenda').")"; + $sql = "SELECT id as rowid FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity('agenda').")"; } elseif ($type == 'expensereport') { - $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$ids.")"; + $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'project_task') { - $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$ids.")"; + $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$ids.")"; + $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$ids.") AND ms.type_mouvement = 1"; + $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$ids.")"; + $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$this->db->sanitize($ids).")"; } else { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")"; } if ($dates > 0 && $type == 'loan') { @@ -771,7 +814,7 @@ class Project extends CommonObject 'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project' ); foreach ($listoftables as $key => $value) { - $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { $this->errors[] = $this->db->lasterror(); @@ -783,7 +826,7 @@ class Project extends CommonObject // Remove linked categories. if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_project"; - $sql .= " WHERE fk_project = ".$this->id; + $sql .= " WHERE fk_project = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { @@ -808,7 +851,7 @@ class Project extends CommonObject foreach ($elements as $table) { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE fk_project = ".$this->id; + $sql .= " WHERE fk_project = ".((int) $this->id); $result = $this->db->query($sql); if (!$result) { @@ -900,17 +943,17 @@ class Project extends CommonObject if ($type == 'agenda') { $sql = "SELECT COUNT(id) as nb FROM ".MAIN_DB_PREFIX."actioncomm WHERE fk_project = ".$this->id." AND entity IN (".getEntity('agenda').")"; } elseif ($type == 'expensereport') { - $sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".$this->id; + $sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".((int) $this->id); } elseif ($type == 'project_task') { $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet = ".$this->id; } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".$this->id; + $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".((int) $this->id); } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT COUNT(ms.rowid) as nb FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".$this->id." AND ms.type_mouvement = 1"; + $sql = 'SELECT COUNT(ms.rowid) as nb FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = 'SELECT COUNT(l.rowid) as nb FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".$this->id; + $sql = 'SELECT COUNT(l.rowid) as nb FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".((int) $this->id); } else { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." = ".$this->id." AND entity IN (".getEntity($type).")"; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." = ".((int) $this->id)." AND entity IN (".getEntity($type).")"; } $result = $this->db->query($sql); @@ -1033,7 +1076,7 @@ class Project extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; - $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; + $sql .= " SET fk_statut = ".self::STATUS_CLOSED.", fk_user_close = ".((int) $user->id).", date_close = '".$this->db->idate($now)."'"; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND fk_statut = ".self::STATUS_VALIDATED; @@ -1386,13 +1429,13 @@ class Project extends CommonObject if ($mode == 0) { $sql .= " AND ( p.public = 1"; - $sql .= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; + $sql .= " OR ( ec.fk_c_type_contact IN (".$this->db->sanitize(join(',', array_keys($listofprojectcontacttype))).")"; $sql .= " AND ec.fk_socpeople = ".$user->id.")"; $sql .= " )"; } elseif ($mode == 1) { $sql .= " AND ec.element_id = p.rowid"; $sql .= " AND ("; - $sql .= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; + $sql .= " ( ec.fk_c_type_contact IN (".$this->db->sanitize(join(',', array_keys($listofprojectcontacttype))).")"; $sql .= " AND ec.fk_socpeople = ".$user->id.")"; $sql .= " )"; } elseif ($mode == 2) { @@ -1974,7 +2017,7 @@ class Project extends CommonObject $sql .= " WHERE p.fk_statut = 1"; $sql .= " AND p.entity IN (".getEntity('project').')'; if (!empty($projectsListId)) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -2055,7 +2098,7 @@ class Project extends CommonObject $sql .= " p.entity IN (".getEntity('project').")"; if (!$user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1); - $sql .= "AND p.rowid IN (".$projectsListId.")"; + $sql .= "AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; } $resql = $this->db->query($sql); diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 3ec82edf366..42c5ae2135f 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -180,11 +180,11 @@ class ProjectStats extends Stats } if (!empty($this->status)) { - $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; + $sqlwhere[] = " t.fk_opp_status IN (".$this->db->sanitize($this->status).")"; } if (!$user->rights->projet->all->lire) { - $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sqlwhere[] = " t.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } if (count($sqlwhere) > 0) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 9a72124199c..0f84313b75a 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -402,18 +402,20 @@ class Task extends CommonObject if (!$error && !empty($conf->global->PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE)) { // Close the parent project if it is open (validated) and its tasks are 100% completed $project = new Project($this->db); - if ($project->fetch($this->fk_project) > 0 && $project->statut == Project::STATUS_VALIDATED) { - $project->getLinesArray(null); // this method does not return <= 0 if fails - $projectCompleted = array_reduce( - $project->lines, - function ($allTasksCompleted, $task) { - return $allTasksCompleted && $task->progress >= 100; - }, + if ($project->fetch($this->fk_project) > 0) { + if ($project->statut == Project::STATUS_VALIDATED) { + $project->getLinesArray(null); // this method does not return <= 0 if fails + $projectCompleted = array_reduce( + $project->lines, + function ($allTasksCompleted, $task) { + return $allTasksCompleted && $task->progress >= 100; + }, 1 - ); - if ($projectCompleted) { - if ($project->setClose($user) <= 0) { - $error++; + ); + if ($projectCompleted) { + if ($project->setClose($user) <= 0) { + $error++; + } } } } else { @@ -868,13 +870,13 @@ class Task extends CommonObject $sql .= " AND p.fk_soc = ".$socid; } if ($projectid) { - $sql .= " AND p.rowid in (".$projectid.")"; + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectid).")"; } if ($filteronproj) { $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); } if ($filteronprojstatus && $filteronprojstatus != '-1') { - $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; + $sql .= " AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).")"; } if ($morewherefilter) { $sql .= $morewherefilter; @@ -1062,10 +1064,10 @@ class Task extends CommonObject $sql .= " AND ctc.source = 'internal'"; if ($projectid) { if ($userp) { - $sql .= " AND pt.rowid in (".$projectid.")"; + $sql .= " AND pt.rowid IN (".$this->db->sanitize($projectid).")"; } if ($usert) { - $sql .= " AND pt.fk_projet in (".$projectid.")"; + $sql .= " AND pt.fk_projet IN (".$this->db->sanitize($projectid).")"; } } if ($taskid) { @@ -1073,7 +1075,7 @@ class Task extends CommonObject $sql .= " ERROR SHOULD NOT HAPPENS"; } if ($usert) { - $sql .= " AND pt.rowid = ".$taskid; + $sql .= " AND pt.rowid = ".((int) $taskid); } } //print $sql; @@ -1197,11 +1199,11 @@ class Task extends CommonObject if ($ret > 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; if (isset($this->progress)) { - $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + $sql .= ", progress = ".((float) $this->progress); // Do not overwrite value if not provided } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -1210,8 +1212,8 @@ class Task extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user - $sql .= " WHERE rowid = ".$tasktime_id; + $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".((int) $this->timespent_fk_user).")"; // set average hour rate of user + $sql .= " WHERE rowid = ".((int) $tasktime_id); dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -1266,10 +1268,10 @@ class Task extends CommonObject $sql .= $morewherefilter; } if ($id > 0) { - $sql .= " AND t.fk_task = ".$id; + $sql .= " AND t.fk_task = ".((int) $id); } if ($userid > 0) { - $sql .= " AND t.fk_user = ".$userid; + $sql .= " AND t.fk_user = ".((int) $userid); } dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); @@ -1317,9 +1319,9 @@ class Task extends CommonObject $sql .= " SUM(t.task_duration) as nbseconds,"; $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE t.fk_task = ".$id; + $sql .= " WHERE t.fk_task = ".((int) $id); if (is_object($fuser) && $fuser->id > 0) { - $sql .= " AND fk_user = ".$fuser->id; + $sql .= " AND fk_user = ".((int) $fuser->id); } if ($dates > 0) { $datefieldname = "task_datehour"; @@ -1552,8 +1554,8 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); if (!$this->db->query($sql)) { @@ -2002,12 +2004,12 @@ class Task extends CommonObject $sql .= " AND t.fk_projet = p.rowid"; $sql .= " AND (t.progress IS NULL OR t.progress < 100)"; // tasks to do if (!$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; @@ -2076,7 +2078,7 @@ class Task extends CommonObject $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; $sql .= " AND t.fk_projet = p.rowid"; // tasks to do if ($mine || !$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index d18950ec482..8a5234b956f 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -154,9 +154,8 @@ class TaskStats extends Stats if (!empty($this->yearmonth)) { $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; } - - if (!empty($this->status)) { - $sqlwhere[] = " t.priority IN (".$this->priority.")"; + if (!empty($this->priority)) { + $sqlwhere[] = " t.priority IN (".$this->db->sanitize($this->priority, 1).")"; } if (count($sqlwhere) > 0) { diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index ac00e0adfad..f4b7d8226d0 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -44,8 +44,6 @@ $objectref = GETPOST("taskref", 'alpha'); // task ref $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $withproject = GETPOST('withproject', 'int'); -$project_ref = GETPOST('project_ref', 'alpha'); -$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); // Security check $socid = 0; @@ -112,7 +110,7 @@ $morehtmlref .= ''; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 8fc018ab8ab..92f4e4e3b15 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -223,7 +223,7 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) { // Delete a contact if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) { $object->fetch($id); - $result = $object->delete_contact(GETPOST("lineid")); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: contact.php?id=".$object->id); @@ -300,7 +300,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 795e10f2739..d7bcd722988 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -141,7 +141,7 @@ if ($object->id > 0) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f72b1eba7d2..a71d8c4a602 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -222,7 +222,7 @@ $morehtmlref .= ''; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " te.rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " te.rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index b4dbc21e894..c5e5b20fb88 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -123,7 +123,7 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index cf8cc1dd34d..b6b4470dd15 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -23,10 +23,10 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.fk_statut = 1"; // Opend projects only if ($mine || empty($user->rights->projet->all->lire)) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; } - if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid > 0) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } $sql .= " GROUP BY p.fk_opp_status, cls.code"; $resql = $db->query($sql); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 600a246cf94..f42a0553893 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -134,7 +134,7 @@ print_barre_liste($form->textwithpicto($title, $tooltiphelp), 0, $_SERVER["PHP_S // Get list of ponderated percent and colors for each status -include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; +include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; $listofoppstatus = array(); $listofopplabel = array(); $listofoppcode = array(); $colorseries = array(); $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; @@ -238,7 +238,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; if ($mine || empty($user->rights->projet->all->lire)) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // If we have this test true, it also means projectset is not 2 } if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -338,10 +338,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " WHERE p.entity IN (".getEntity('project').")"; $sql .= " AND p.fk_statut = 1"; if ($mine || empty($user->rights->projet->all->lire)) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // If we have this test true, it also means projectset is not 2 } -if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($socid > 0) { + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur, s.logo, s.email, s.entity, s.canvas, s.status"; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index d99da02caa6..b8c6ae046cf 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -136,7 +136,7 @@ $morehtmlref .= ''; // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e6b381a6650..6ab17b6feee 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -370,11 +370,11 @@ if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array); } if (!$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users } // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid > 0) { - $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) + $sql .= " AND (p.fk_soc = ".((int) $socid).")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) } if ($search_ref) { $sql .= natural_search('p.ref', $search_ref); @@ -414,7 +414,7 @@ if ($search_opp_status) { $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; } if ($search_opp_status == 'notopenedopp') { - $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; + $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))"; } if ($search_opp_status == 'none') { $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; @@ -426,12 +426,12 @@ if ($search_public != '') { // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if ($socid > 0) $sql.= " AND s.rowid = ".$socid; if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // No check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; if ($search_project_user > 0) { - $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; + $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; } if ($search_opp_amount != '') { $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); @@ -678,32 +678,32 @@ if ($search_all) { $moreforfilter = ''; -// Filter on categories -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); -} - // If the user can view user other than himself $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; +$tmptitle = $langs->trans('ProjectsWithThisUserAsContact'); //$includeonly = 'hierarchyme'; $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } +// Filter on categories +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $formcategory = new FormCategory($db); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array); +} + if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; @@ -1107,7 +1107,7 @@ while ($i < min($num, $limit)) { print ''; //if ($obj->opp_status_code) if (strcmp($obj->opp_amount, '')) { - print price($obj->opp_amount, 1, $langs, 1, -1, -1, ''); + print ''.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').''; $totalarray['val']['p.opp_amount'] += $obj->opp_amount; } print ''; @@ -1136,7 +1136,7 @@ while ($i < min($num, $limit)) { } print ''; if ($obj->opp_weighted_amount) { - print price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, ''); + print ''.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').''; $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; } print ''; @@ -1151,7 +1151,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.budget_amount']['checked'])) { print ''; if ($obj->budget_amount != '') { - print price($obj->budget_amount, 1, $langs, 1, -1, -1); + print ''.price($obj->budget_amount, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.budget_amount'] += $obj->budget_amount; } print ''; @@ -1232,7 +1232,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.price_registration']['checked'])) { print ''; if ($obj->price_registration != '') { - print price($obj->price_registration, 1, $langs, 1, -1, -1); + print ''.price($obj->price_registration, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.price_registration'] += $obj->price_registration; } print ''; @@ -1243,11 +1243,11 @@ while ($i < min($num, $limit)) { $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; } } - // PriceOfBooth + // Price of booth if (!empty($arrayfields['p.price_booth']['checked'])) { print ''; if ($obj->price_booth != '') { - print price($obj->price_booth, 1, $langs, 1, -1, -1); + print ''.price($obj->price_booth, 1, $langs, 1, -1, -1).''; $totalarray['val']['p.price_booth'] += $obj->price_booth; } print ''; @@ -1266,7 +1266,7 @@ while ($i < min($num, $limit)) { print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['p.datec']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (!$i) { @@ -1275,7 +1275,7 @@ while ($i < min($num, $limit)) { } // Date modification if (!empty($arrayfields['p.tms']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if (!$i) { diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index a1ef737ddc7..8b65156570a 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -101,7 +101,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 07724753f2d..df4a94b6dfd 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -297,7 +297,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) { $taskid = $task->create($user); if ($taskid > 0) { - $result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal'); + $result = $task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal'); } else { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); @@ -450,7 +450,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 8ce97133493..aaa8bd0cd89 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -135,7 +135,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -284,14 +284,14 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", "int").'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { - $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); } $morehtmlref = ''; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 7916c236fb3..3aa5c3b8830 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -104,7 +104,7 @@ if ($action == 'addcontact' && $user->rights->projet->creer) { // bascule du statut d'un contact if ($action == 'swapstatut' && $user->rights->projet->creer) { if ($object->fetch($id, $ref)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } @@ -113,7 +113,7 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) { // Efface un contact if ($action == 'deleteline' && $user->rights->projet->creer) { $object->fetch($id, $ref); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id.($withproject ? '&withproject=1' : '')); @@ -197,7 +197,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -320,7 +320,7 @@ if ($id > 0 || !empty($ref)) { if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { $object->next_prev_filter = " fk_projet = ".$projectstatic->id; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index afa63f7eee4..967cc0438da 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -154,7 +154,7 @@ if ($object->id > 0) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -278,7 +278,7 @@ if ($object->id > 0) { if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { $object->next_prev_filter = " fk_projet = ".$projectstatic->id; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 57f9ec2b24f..7156d94ef21 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -128,26 +128,26 @@ if (empty($user->socid)) { } $arrayfields = array( - 't.fk_task_parent'=>array('label'=>$langs->trans("RefTaskParent"), 'checked'=>0, 'position'=>70), - 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), - 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), - 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>80), - 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), - 't.datee'=>array('label'=>$langs->trans("Deadline"), 'checked'=>1, 'position'=>101), - 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), - 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0), - 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1), - 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102), - 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), - 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), - 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), - 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>106), - 't.tobill'=>array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>110), - 't.billed'=>array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>111), - 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 't.fk_task_parent'=>array('label'=>"RefTaskParent", 'checked'=>0, 'position'=>70), + 't.ref'=>array('label'=>"RefTask", 'checked'=>1, 'position'=>80), + 't.label'=>array('label'=>"LabelTask", 'checked'=>1, 'position'=>80), + 't.description'=>array('label'=>"Description", 'checked'=>0, 'position'=>80), + 't.dateo'=>array('label'=>"DateStart", 'checked'=>1, 'position'=>100), + 't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>101), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>0), + 'p.fk_statut'=>array('label'=>"ProjectStatus", 'checked'=>1), + 't.planned_workload'=>array('label'=>"PlannedWorkload", 'checked'=>1, 'position'=>102), + 't.duration_effective'=>array('label'=>"TimeSpent", 'checked'=>1, 'position'=>103), + 't.progress_calculated'=>array('label'=>"ProgressCalculated", 'checked'=>1, 'position'=>104), + 't.progress'=>array('label'=>"ProgressDeclared", 'checked'=>1, 'position'=>105), + 't.progress_summary'=>array('label'=>"TaskProgressSummary", 'checked'=>1, 'position'=>106), + 't.tobill'=>array('label'=>"TimeToBill", 'checked'=>0, 'position'=>110), + 't.billed'=>array('label'=>"TimeBilled", 'checked'=>0, 'position'=>111), + 't.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + //'t.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -334,17 +334,17 @@ if ($search_task_user > 0) { $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity IN (".getEntity('project').')'; if (!$user->rights->projet->all->lire) { - $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users + $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users } if (is_object($projectstatic) && $projectstatic->id > 0) { - $sql .= " AND p.rowid = ".$projectstatic->id; + $sql .= " AND p.rowid = ".((int) $projectstatic->id); } // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; } if ($search_categ > 0) { - $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); + $sql .= " AND cs.fk_categorie = ".((int) $search_categ); } if ($search_categ == -2) { $sql .= " AND cs.fk_categorie IS NULL"; @@ -389,10 +389,10 @@ if ($search_public != '') { $sql .= " AND p.public = ".$db->escape($search_public); } if ($search_project_user > 0) { - $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; + $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; } if ($search_task_user > 0) { - $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; + $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -588,29 +588,29 @@ $morehtmlfilter = ''; if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ProjectCategories').': '; - $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); + $tmptitle = $langs->trans('ProjectCategories'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('project', $search_categ, 'search_categ', 0, $tmptitle, 'maxwidth300'); $moreforfilter .= '
    '; } // If the user can view users $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; +$tmptitle = $langs->trans('ProjectsWithThisUserAsContact'); $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; // If the user can view users $moreforfilter .= '
    '; -$moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; +$tmptitle = $langs->trans('TasksWithThisUserAsContact'); $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_task_user, 'search_task_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; if (!empty($moreforfilter)) { @@ -658,7 +658,7 @@ if (!empty($arrayfields['t.dateo']['checked'])) { print ''; } print ''; - $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); + print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); print ''; } // End date @@ -668,7 +668,7 @@ if (!empty($arrayfields['t.datee']['checked'])) { print ''; } print ''; - $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); + print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'valignmiddle width75', 1); print ''; } if (!empty($arrayfields['p.ref']['checked'])) { diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 2452cc71d86..4d581afc30a 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -129,7 +129,7 @@ if ($object->id > 0) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -247,7 +247,7 @@ if ($object->id > 0) { if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { $object->next_prev_filter = " fk_projet = ".$projectstatic->id; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 828b32c599f..780d387512e 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -73,14 +73,14 @@ if ($reshook < 0) { * Actions */ -if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) { +if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $error = 0; if (empty($taskref)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (empty($_POST["label"])) { + if (!GETPOST("label")) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } @@ -240,7 +240,7 @@ if ($id > 0 || !empty($ref)) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -474,14 +474,14 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); } if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { - $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); } $morehtmlref = ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index eb1c394d8cf..1c3cacb4cee 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -158,7 +158,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors'); $error++; } - if (empty($_POST["userid"])) { + if (!GETPOST("userid", 'int')) { $langs->load("errors"); setEventMessages($langs->trans('ErrorUserNotAssignedToTask'), null, 'errors'); $error++; @@ -185,19 +185,19 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) { $action = 'createtime'; $error++; } else { - $object->timespent_note = $_POST["timespent_note"]; + $object->timespent_note = GETPOST("timespent_note", 'alpha'); if (GETPOST('progress', 'int') > 0) { $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value } - $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["timespent_durationmin"] ? $_POST["timespent_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_duration = GETPOSTINT("timespent_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT('timespent_durationmin') ? GETPOSTINT('timespent_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); } - $object->timespent_fk_user = $_POST["userid"]; + $object->timespent_fk_user = GETPOST("userid", 'int'); $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -233,17 +233,17 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $result = $object->delTimeSpent($user); $object->fetch($id, $ref); - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_note = GETPOST("timespent_note_line", 'alpha'); + $object->timespent_old_duration = GETPOST("old_duration"); + $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } - $object->timespent_fk_user = $_POST["userid_line"]; + $object->timespent_fk_user = GETPOST("userid_line", 'int'); $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -255,18 +255,18 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - $object->timespent_id = $_POST["lineid"]; - $object->timespent_note = $_POST["timespent_note_line"]; - $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_id = GETPOST("lineid", 'int'); + $object->timespent_note = GETPOST("timespent_note_line"); + $object->timespent_old_duration = GETPOST("old_duration"); + $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds + $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); $object->timespent_withhour = 1; } else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } - $object->timespent_fk_user = $_POST["userid_line"]; + $object->timespent_fk_user = GETPOST("userid_line", 'int'); $result = $object->updateTimeSpent($user); if ($result >= 0) { @@ -428,8 +428,8 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; - $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { $error++; @@ -467,8 +467,8 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; - $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { $error++; @@ -503,8 +503,8 @@ if ($action == 'confirm_generateinvoice') { $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; - $sql .= ' WHERE rowid in ('.join(',', $toselect).')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')'; $result = $db->query($sql); if (!$result) { $error++; @@ -600,7 +600,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { // Define a complementary filter for search of next/prev ref. if (!$user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -761,7 +761,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { if (!GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; } else { $object->next_prev_filter = " fk_projet = ".$projectstatic->id; } @@ -1036,7 +1036,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { if (empty($projectidforalltimes)) { $sql .= " AND t.fk_task =".$object->id; } else { - $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; + $sql .= " AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).")"; } if ($search_note) { $sql .= natural_search('t.note', $search_note); @@ -1141,7 +1141,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { // Date print ''; - //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); $newdate = ''; print $form->selectDate($newdate, 'time', ($conf->browser->layout == 'phone' ? 2 : 1), 1, 2, "timespent_date", 1, 0); print ''; diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 454201203cc..ea9eeb377e7 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -122,19 +122,19 @@ if (!empty($tag)) { //Update status of target $statut = '2'; - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid = ".((int) $obj->rowid); + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) dol_print_error($db); //Update status communication of thirdparty prospect if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.$obj->source_id; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.((int) $obj->source_id); $resql = $db->query($sql); } //Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { - $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.$obj->source_id.')'; + $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')'; $resql = $db->query($sql); } } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index d8c25bbebbb..e6b7a3e7a38 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,7 +218,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
    \n"; } - if (GETPOST("firstname")) { + if (!GETPOST("firstname")) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
    \n"; } diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index a19c1212761..80e092f2951 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -131,7 +131,7 @@ llxHeaderVierge($langs->trans("ListOfValidatedPublicMembers"), $morehead); $sql = "SELECT rowid, firstname, lastname, societe, zip, town, email, birth, photo"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; -$sql .= " WHERE entity = ".$entity; +$sql .= " WHERE entity = ".((int) $entity); $sql .= " AND statut = 1"; $sql .= " AND public = 1"; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 90dab0379ff..5f5446ae3f1 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -203,7 +203,6 @@ if ($testmodifier) { //var_dump($_POST);exit; $nouveauchoix = ''; for ($i = 0; $i < $nbcolonnes; $i++) { - //var_dump($_POST["choix$i"]); if (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '1') { $nouveauchoix .= "1"; } elseif (GETPOSTISSET("choix".$i) && GETPOST("choix".$i) == '2') { @@ -217,7 +216,7 @@ if ($testmodifier) { accessforbidden('', 0, 0, 1); } - $idtomodify = $_POST["idtomodify".$modifier]; + $idtomodify = GETPOST("idtomodify".$modifier); $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " SET reponses = '".$db->escape($nouveauchoix)."'"; $sql .= " WHERE id_users = '".$db->escape($idtomodify)."'"; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index dc5d99a43eb..9a88a1b49ac 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART + * 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 @@ -405,8 +406,8 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { } dol_syslog("--- newpayment.php Execute action = ".$action, LOG_DEBUG, 0, '_stripe'); - dol_syslog("POST keys : ".join(',', array_keys($_POST)), LOG_DEBUG, 0, '_stripe'); - dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); + dol_syslog("GET=".var_export($_GET, true), LOG_DEBUG, 0, '_stripe'); + dol_syslog("POST=".var_export($_POST, true), LOG_DEBUG, 0, '_stripe'); $stripeToken = GETPOST("stripeToken", 'alpha'); $email = GETPOST("email", 'alpha'); @@ -414,7 +415,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { $dol_type = (GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha')); $dol_id = GETPOST('dol_id', 'int'); $vatnumber = GETPOST('vatnumber', 'alpha'); - $savesource = GETPOSTISSET('savesource') ?GETPOST('savesource', 'int') : 1; + $savesource = GETPOSTISSET('savesource') ? GETPOST('savesource', 'int') : 1; dol_syslog("POST stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe'); dol_syslog("POST email = ".$email, LOG_DEBUG, 0, '_stripe'); @@ -1438,6 +1439,39 @@ if ($source == 'membersubscription') { } } + if ($member->type) { + // Last member type + print ''.$langs->trans("LastMemberType"); + print ''.dol_escape_htmltag($member->type); + print "\n"; + } + + if (!empty($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE)) { + // Amount by member type + $amountbytype = json_decode($conf->global->MEMBER_SUBSCRIPTION_AMOUNT_BY_TYPE, true); + // 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 = $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 ''.$langs->trans("NewSubscription"); + print ''; + print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); + print "\n"; + } elseif ($action == dopayment) { + print ''.$langs->trans("NewMemberType"); + print ''.dol_escape_htmltag($member->type); + print ''; + print "\n"; + } + } + // Amount print ''.$langs->trans("Amount"); if (empty($amount)) { diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 99a97e0c321..1942635001f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2002 Rodolphe Quiedeville * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin + * 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 @@ -98,10 +99,11 @@ $FULLTAG = GETPOST('FULLTAG'); if (empty($FULLTAG)) { $FULLTAG = GETPOST('fulltag'); } -$source = GETPOST('s', 'alpha') ?GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); +$source = GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); $ref = GETPOST('ref'); $suffix = GETPOST("suffix", 'aZ09'); +$membertypeid = GETPOST("membertypeid", 'int'); // Detect $paymentmethod @@ -339,7 +341,8 @@ if ($ispaymentok) { $user->rights->facture = new stdClass(); } if (empty($user->rights->adherent)) { - $user->rights->adherent = new stdClass(); $user->rights->adherent->cotisation = new stdClass(); + $user->rights->adherent = new stdClass(); + $user->rights->adherent->cotisation = new stdClass(); } $user->rights->societe->creer = 1; $user->rights->facture->creer = 1; @@ -460,7 +463,7 @@ if ($ispaymentok) { if (!$error) { dol_syslog("Call ->subscription to create subscription", LOG_DEBUG, 0, '_payment'); - $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid); if ($crowid <= 0) { $error++; $errmsg = $object->error; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index f25843f69e4..048df9c41b3 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -223,11 +223,11 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
    \n"; } - if (empty($_POST["lastname"])) { + if (!GETPOST("lastname")) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
    \n"; } - if (empty($_POST["firstname"])) { + if (!GETPOST("firstname")) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
    \n"; } diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index c7381059a39..5118f7ebfc0 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -261,7 +261,7 @@ if ($display_ticket_list) { $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { - $sql .= 'AND '.$key.' IN ('.implode(',', $value).')'; + $sql .= 'AND '.$key.' IN ('.$db->sanitize(implode(',', $value)).')'; } else { $sql .= ' AND '.$key.' = '.$db->escape($value); } diff --git a/htdocs/public/stripe/confirm_payment.php b/htdocs/public/stripe/confirm_payment.php deleted file mode 100644 index b0f8f8213a0..00000000000 --- a/htdocs/public/stripe/confirm_payment.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * 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 . - */ - -// TODO Do we really need this page. We alread have a ipn.php page ! - -if (!defined('NOLOGIN')) { - define("NOLOGIN", 1); // This means this output page does not require to be logged. -} -if (!defined('NOCSRFCHECK')) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. -} -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} -if (!defined('NOBROWSERNOTIF')) { - define('NOBROWSERNOTIF', '1'); -} - -$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) { - define("DOLENTITY", $entity); -} - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - -require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; -require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - -if (empty($conf->stripe->enabled)) { - accessforbidden('', 0, 0, 1); -} - - -// You can find your endpoint's secret in your webhook settings -if (isset($_GET['connect'])) { - if (isset($_GET['test'])) { - $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY; - $service = 'StripeTest'; - $servicestatus = 0; - } else { - $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; - $service = 'StripeLive'; - $servicestatus = 1; - } -} else { - if (isset($_GET['test'])) { - $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; - $service = 'StripeTest'; - $servicestatus = 0; - } else { - $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY; - $service = 'StripeLive'; - $servicestatus = 1; - } -} - - - -/* - * Actions - */ - -$langs->load("main"); - -// TODO Do we really need a user in setup just to have an name to fill an email topic when it is a technical system notification email -$user = new User($db); -$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS); -$user->getrights(); - -// list of action -$stripe = new Stripe($db); - -// Subject -$societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $societeName = $conf->global->MAIN_APPLICATION_TITLE; -} - - -dol_syslog("Stripe confirm_payment was called"); -dol_syslog("GET=".var_export($_GET, true)); -dol_syslog("POST=".var_export($_POST, true)); - - -header('Content-Type: application/json'); - -// retrieve json from POST body -$json_str = file_get_contents('php://input'); -$json_obj = json_decode($json_str); - -$intent = null; -try { - if (isset($json_obj->payment_method_id)) { - // Create the PaymentIntent - $intent = \Stripe\PaymentIntent::create(array( - 'payment_method' => $json_obj->payment_method_id, - 'amount' => 1099, - 'currency' => 'eur', - 'confirmation_method' => 'manual', - 'confirm' => true, - )); - } - if (isset($json_obj->payment_intent_id)) { - $intent = \Stripe\PaymentIntent::retrieve( - $json_obj->payment_intent_id - ); - $intent->confirm(); - } - generatePaymentResponse($intent); -} catch (\Stripe\Error\Base $e) { - // Display error on client - echo json_encode(array( - 'error' => $e->getMessage() - )); -} - -/** - * Generate payment response - * - * @param \Stripe\PaymentIntent $intent PaymentIntent - * @return void - */ -function generatePaymentResponse($intent) -{ - if ($intent->status == 'requires_source_action' && - $intent->next_action->type == 'use_stripe_sdk') { - // Tell the client to handle the action - echo json_encode(array( - 'requires_action' => true, - 'payment_intent_client_secret' => $intent->client_secret - )); - } elseif ($intent->status == 'succeeded') { - // The payment didn’t need any additional actions and completed! - // Handle post-payment fulfillment - - // TODO - - echo json_encode(array( - "success" => true - )); - } else { - // Invalid status - http_response_code(500); - echo json_encode(array('error' => 'Invalid PaymentIntent status')); - } -} diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index d39f48f2dfe..f44bc0b1c99 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -373,7 +373,7 @@ if ($event->type == 'payout.created') { } } elseif ($event->type == 'payment_method.detached') { $db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE number = '".$db->escape($event->data->object->id)."' and status = ".$servicestatus; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE number = '".$db->escape($event->data->object->id)."' and status = ".((int) $servicestatus); $db->query($sql); $db->commit(); } elseif ($event->type == 'charge.succeeded') { diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 5b7ba4ecf22..85b40430d4c 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -392,7 +392,7 @@ if ($action != "infos_success") { print '
    '; } else { print '
    '.$langs->trans('TicketPublicInfoCreateTicket').'
    '; - $formticket->showForm(); + $formticket->showForm(0, 'edit', 1); } } diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 81d13832ca4..31ee838f6f5 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -82,9 +82,9 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); print ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index befeee00a7b..92962732a68 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -55,7 +55,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = strtolower(GETPOST('email', 'alpha')); if (GETPOST('btn_view_ticket_list')) { unset($_SESSION['track_id_customer']); @@ -65,7 +65,7 @@ if (isset($_SESSION['track_id_customer'])) { $track_id = $_SESSION['track_id_customer']; } if (isset($_SESSION['email_customer'])) { - $email = $_SESSION['email_customer']; + $email = strtolower($_SESSION['email_customer']); } $object = new Ticket($db); @@ -105,7 +105,7 @@ if ($action == "view_ticketlist") { // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == $email) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -116,7 +116,7 @@ if ($action == "view_ticketlist") { } if ($object->fk_soc > 0) { $object->fetch_thirdparty(); - if ($email == $object->thirdparty->email) { + if ($email == strtolower($object->thirdparty->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -125,14 +125,14 @@ if ($action == "view_ticketlist") { if ($object->fk_user_create > 0) { $tmpuser = new User($db); $tmpuser->fetch($object->fk_user_create); - if ($email == $tmpuser->email) { + if ($email == strtolower($tmpuser->email)) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; } } - $emailorigin = CMailFile::getValidAddress($object->origin_email, 2); + $emailorigin = strtolower(CMailFile::getValidAddress($object->origin_email, 2)); if ($email == $emailorigin) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; @@ -364,7 +364,7 @@ if ($action == "view_ticketlist") { $sql .= " AND ".$key." = '".$db->escape($value)."'"; } elseif ($key == 't.fk_statut') { if (is_array($value) && count($value) > 0) { - $sql .= 'AND '.$key.' IN ('.implode(',', $value).')'; + $sql .= 'AND '.$key.' IN ('.$db->sanitize(implode(',', $value)).')'; } else { $sql .= ' AND '.$key.' = '.$db->escape($value); } @@ -432,7 +432,7 @@ if ($action == "view_ticketlist") { if (!empty($arrayfields['category.code']['checked'])) { print ''; - $formTicket->selectGroupTickets($search_category, 'search_category', '', 2, 1, 1); + $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1); print ''; } diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index d556ca2935f..2f70ded9914 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -57,7 +57,7 @@ $langs->loadLangs(array("companies", "other", "ticket")); $track_id = GETPOST('track_id', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); -$email = GETPOST('email', 'alpha'); +$email = GETPOST('email', 'email'); if (GETPOST('btn_view_ticket')) { unset($_SESSION['email_customer']); @@ -106,14 +106,14 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($ret && $object->dao->id > 0) { // Check if emails provided is the one of author $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2); - if ($emailofticket == $email) { + if (strtolower($emailofticket) == strtolower($email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } else { // Check if emails provided is inside list of contacts $contacts = $object->dao->liste_contact(-1, 'external'); foreach ($contacts as $contact) { - if ($contact['email'] == $email) { + if (strtolower($contact['email']) == strtolower($email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; break; @@ -134,7 +134,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->fk_user_create > 0) { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_create); - if ($email == $tmpuser->email) { + if (strtolower($email) == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } @@ -143,7 +143,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create) { $tmpuser = new User($db); $tmpuser->fetch($object->dao->fk_user_assign); - if ($email == $tmpuser->email) { + if (strtolower($email) == strtolower($tmpuser->email)) { $display_ticket = true; $_SESSION['email_customer'] = $email; } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 83701e59e40..1e78c6636ce 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -86,25 +86,6 @@ if (empty($origin_id)) { $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; -// Security check -$socid = ''; -if ($user->socid) { - $socid = $user->socid; -} - -if ($origin == 'reception') { - $result = restrictedArea($user, $origin, $id); -} else { - $result = restrictedArea($user, 'reception'); - if ($origin == 'supplierorder') { - if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { - accessforbidden(); - } - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { - accessforbidden(); - } -} - $action = GETPOST('action', 'alpha'); //Select mail models is same action as presend if (GETPOST('modelselected')) { @@ -136,6 +117,25 @@ $permissiondellink = $user->rights->reception->creer; // Used by the include of $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_deliverymin', 'int'), 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int')); +// Security check +$socid = ''; +if ($user->socid) { + $socid = $user->socid; +} + +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + /* * Actions @@ -259,8 +259,6 @@ if (empty($reshook)) { $objectsrc = new $classname($db); $objectsrc->fetch($object->origin_id); - - $object->socid = $objectsrc->socid; $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->model_pdf = GETPOST('model'); @@ -299,15 +297,12 @@ if (empty($reshook)) { $stockLocation = "ent1".$i."_0"; $qty = "qtyl".$i; - - - //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; - //reception line for product with no batch management and no multiple stock location - if (GETPOST($qty, 'int') > 0) { - $totalqty += GETPOST($qty, 'int'); + //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; + //reception line for product with no batch management and no multiple stock location + if (GETPOST($qty, 'alpha') > 0) { + $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS'); } - // Extrafields $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i); } @@ -317,11 +312,16 @@ if (empty($reshook)) { //var_dump($_POST);exit; for ($i = 1; $i <= $num; $i++) { $lineToTest = ''; + $lineId = GETPOST($idl, 'int'); foreach ($objectsrc->lines as $linesrc) { - if ($linesrc->id == GETPOST($idl, 'int')) { + if ($linesrc->id == $lineId) { $lineToTest = $linesrc; + break; } } + if (empty($lineToTest)) { + continue; + } $qty = "qtyl".$i; $comment = "comment".$i; $eatby = "dlc".$i; @@ -337,10 +337,16 @@ if (empty($reshook)) { $entrepot_id = is_numeric(GETPOST($ent, 'int')) ? GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int'); + if (!empty($lineToTest)) { + $fk_product = $lineToTest->fk_product; + } else { + $fk_product = $linesrc->fk_product; + } + if ($entrepot_id < 0) { $entrepot_id = ''; } - if (!($linesrc->fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + if (!($fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $entrepot_id = 0; } $eatby = GETPOST($eatby, 'alpha'); @@ -779,7 +785,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">'.$langs->trans("AddProject").''; + print '   id).'">'; print ''; print ''; } @@ -1117,12 +1123,12 @@ if ($action == 'create') { if (!empty($product->status_batch)) { print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; + print ''; print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; + print ''; print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); print ''; } @@ -1793,7 +1799,7 @@ if ($action == 'create') { print ''.$formproduct->selectWarehouses($lines[$i]->fk_entrepot, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).''; // Batch number managment if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) { - print '
    '; + print '
    '; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print $langs->trans('EatByDate').' : '; print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
    '; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index a8a55c7faf2..b2f31505c44 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1410,7 +1410,7 @@ class Reception extends CommonObject if (!empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql .= " WHERE em.rowid = ".$this->shipping_method_id; + $sql .= " WHERE em.rowid = ".((int) $this->shipping_method_id); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index f814bbbf64a..3caa9a90fea 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -43,12 +43,6 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', $id, ''); - $object = new Reception($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); @@ -69,6 +63,24 @@ if ($id > 0 || !empty($ref)) { } +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $object->id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + + /* * Actions */ @@ -95,10 +107,10 @@ if ($action == 'addcontact' && $user->rights->reception->creer) { } } elseif ($action == 'swapstatut' && $user->rights->reception->creer) { // bascule du statut d'un contact - $result = $objectsrc->swapContactStatus(GETPOST('ligne')); + $result = $objectsrc->swapContactStatus(GETPOST('ligne', 'int')); } elseif ($action == 'deletecontact' && $user->rights->reception->creer) { // Efface un contact - $result = $objectsrc->delete_contact(GETPOST("lineid")); + $result = $objectsrc->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 3aa6b8af754..a54eea592c0 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -36,13 +36,21 @@ $hookmanager->initHooks(array('receptionindex')); $langs->loadLangs(array("orders", "receptions")); +$reception = new Reception($db); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); + + /* * View */ $orderstatic = new CommandeFournisseur($db); $companystatic = new Societe($db); -$reception = new Reception($db); $helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones'; llxHeader('', $langs->trans("Reception"), $helpurl); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 661c14c9d01..bdc65fb301b 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -40,13 +40,6 @@ $socid = GETPOST('socid', 'int'); $massaction = GETPOST('massaction', 'alpha'); $toselect = GETPOST('toselect', 'array'); -// Security check -$receptionid = GETPOST('id', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', $receptionid, ''); - $diroutputmassaction = $conf->reception->dir_output.'/temp/massgeneration/'.$user->id; $search_ref_rcp = GETPOST("search_ref_rcp"); @@ -129,6 +122,13 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); $error = 0; +// Security check +$receptionid = GETPOST('id', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', $receptionid, ''); + /* * Actions @@ -472,10 +472,10 @@ if ($search_state) { $sql .= natural_search("state.nom", $search_state); } if ($search_country) { - $sql .= " AND s.fk_pays IN (".$search_country.')'; + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; } if ($search_ref_rcp) { $sql .= natural_search('e.ref', $search_ref_rcp); diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index b1588a07b14..a3a2b31589c 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -33,26 +33,12 @@ if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -$langs->load("receptions"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load('deliveries'); -$langs->load('orders'); -$langs->load('stocks'); -$langs->load('other'); -$langs->load('propal'); +$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -// Security check -$socid = ''; -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, $origin, $origin_id); - $object = new Reception($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); @@ -77,6 +63,24 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if ($origin == 'reception') { + $result = restrictedArea($user, $origin, $object->id); +} else { + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { + if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) { + accessforbidden(); + } + } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + accessforbidden(); + } +} + + /* * Actions diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 0b118c5d733..1fe3397ef66 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -34,11 +34,6 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -// Security check -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; -} $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; @@ -46,10 +41,13 @@ $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; $startyear = $year - 1; $endyear = $year; -$langs->load("reception"); -$langs->load("other"); -$langs->load("companies"); +$langs->loadLangs(array("reception", "other", "companies")); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); /* diff --git a/htdocs/reception/stats/month.php b/htdocs/reception/stats/month.php index 25c6b16e116..806006394df 100644 --- a/htdocs/reception/stats/month.php +++ b/htdocs/reception/stats/month.php @@ -29,6 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $year = GETPOST("year", 'int'); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'reception', 0, ''); + /* * View diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 99ac555ba8e..db9c4eaaa4a 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -106,7 +106,7 @@ class RecruitmentCandidature extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'comment'=>"Id"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of candidature"), - 'fk_recruitmentjobposition' => array('type'=>'integer:RecruitmentJobPosition:recruitment/class/recruitmentjobposition.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>1, 'index'=>1), + 'fk_recruitmentjobposition' => array('type'=>'integer:RecruitmentJobPosition:recruitment/class/recruitmentjobposition.class.php', 'label'=>'Job', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'picto'=>'recruitmentjobposition', 'css'=>'maxwidth500'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -116,7 +116,7 @@ class RecruitmentCandidature extends CommonObject 'lastname' => array('type'=>'varchar(128)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>1,), 'firstname' => array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>21, 'notnull'=>0, 'visible'=>1,), 'email' => array('type'=>'varchar(255)', 'label'=>'EMail', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'picto'=>'email'), - 'phone' => array('type'=>'varchar(64)', 'label'=>'Phone', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1,), + 'phone' => array('type'=>'phone', 'label'=>'Phone', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'picto'=>'phone'), 'date_birth' => array('type'=>'date', 'label'=>'DateOfBirth', 'enabled'=>'1', 'position'=>70, 'visible'=>-1,), 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'), //'fk_recruitment_origin' => array('type'=>'integer:CRecruitmentOrigin:recruitment/class/crecruitmentorigin.class.php', 'label'=>'Origin', 'enabled'=>'1', 'position'=>45, 'visible'=>1, 'index'=>1), @@ -819,6 +819,9 @@ class RecruitmentCandidature extends CommonObject if ($status == self::STATUS_CANCELED) { $statusType = 'status6'; } + if ($status == self::STATUS_REFUSED) { + $statusType = 'status10'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index d82e2265e7e..68fb7a1fea6 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -670,7 +670,7 @@ class RecruitmentJobPosition extends CommonObject $newprivatenote = dol_concatdesc($this->note_private, $note); $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET status = ".$status.", note_private = '".$this->db->escape($newprivatenote)."'"; + $sql .= " SET status = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."'"; //$sql .= ", date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 21ff7c2a7ba..fcbbdb76930 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -929,13 +929,24 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) { + if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { $object->fetch_projet(); if (!empty($object->project->ref)) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); + } + } + + if (!empty($conf->global->PDF_SHOW_PROJECT)) { + $object->fetch_projet(); + if (!empty($object->project->ref)) { + $outputlangs->load("projects"); + $posy += 3; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } diff --git a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php index 2be1fea7756..a7bfe03aac4 100644 --- a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php +++ b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php @@ -127,8 +127,8 @@ function getPublicJobPositionUrl($mode, $ref = '', $localorexternal = 0) $out = $urltouse.'/public/recruitment/view.php?ref='.($mode ? '' : '').$ref.($mode ? '' : ''); /*if (!empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) { - if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.$conf->global->RECRUITMENT_SECURITY_TOKEN; - else $out .= '&securekey='.dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2); + if (empty($conf->global->RECRUITMENT_SECURITY_TOKEN)) $out .= '&securekey='.urlencode($conf->global->RECRUITMENT_SECURITY_TOKEN); + else $out .= '&securekey='.urlencode(dol_hash($conf->global->RECRUITMENT_SECURITY_TOKEN, 2)); }*/ // For multicompany diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 2930b3889c6..b70fd7cd0b6 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -111,12 +111,13 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; } +$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'recruitment', $object->id); - -$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft); /* diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 653b38c90b3..4826dc735ef 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -132,10 +132,8 @@ $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $obje // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -//$result = restrictedArea($user, 'recruitment', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -//if (!$permissiontoread) accessforbidden(); +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft); /* @@ -555,55 +553,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
    - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
    '; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - 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 (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - print '
    '; - - print "
    \n"; - } - - // Buttons for actions if ($action != 'presend' && $action != 'editline') { diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index ee79a4c59a5..2d736e1564b 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -106,7 +106,8 @@ if ($id > 0 || !empty($ref)) { // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'recruitment', $object->id); +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft); $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 05f007fcb1a..515ddfe80c0 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -180,17 +180,11 @@ $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read; $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete; -// Security check -if (empty($conf->recruitment->enabled)) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'recruitment', $id, ''); -//if (!$permissiontoread) accessforbidden(); +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandidature', 'recruitmentjobposition'); diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 9dbe3909f2c..d4c18155c5d 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -74,11 +74,6 @@ $hookmanager->initHooks(array('recruitmentjobpositionnote', 'globalcard')); // N // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'recruitment', $id); - // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { @@ -88,6 +83,11 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentcandidature', 'recruitmentjobposition', '', 'rowid', $isdraft); /* diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 844cd8a221a..3b6ff756b3c 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -90,7 +90,7 @@ if ($conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -168,7 +168,7 @@ if ($conf->use_javascript_ajax) { $colorseries = array(); $vals = array(); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -246,7 +246,7 @@ if (! empty($conf->recruitment->enabled) && $user->rights->recruitment->read) { $langs->load("orders"); - $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 388d4e8eadc..253bf2a7e0c 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -111,12 +111,13 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; } +$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'recruitment', $object->id); - -$permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); /* diff --git a/htdocs/recruitment/recruitmentjobposition_applications.php b/htdocs/recruitment/recruitmentjobposition_applications.php index c126c594c3a..95daeae54a6 100644 --- a/htdocs/recruitment/recruitmentjobposition_applications.php +++ b/htdocs/recruitment/recruitmentjobposition_applications.php @@ -131,10 +131,8 @@ $upload_dir = $conf->recruitment->multidir_output[isset($object->entity) ? $obje // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -//$result = restrictedArea($user, 'recruitment', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -//if (!$permissiontoread) accessforbidden(); +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); /* @@ -412,54 +410,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
    - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
    '; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - 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 (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - print '
    '; - - print "
    \n"; - } - print '
    '.$langs->trans("FeatureNotYetAvailable"); } diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index 2b832b3b467..58ee9260617 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -133,10 +133,8 @@ $usercanclose = $permissiontoadd; // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -//$result = restrictedArea($user, 'recruitment', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); - -//if (!$permissiontoread) accessforbidden(); +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); /* @@ -440,54 +438,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
    - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
    '; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - 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 (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
    '; - } - print '
    '; - - print "
    \n"; - } - - // Buttons for actions if ($action != 'presend' && $action != 'editline') { @@ -602,11 +552,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Load translation files required by the page $langs->loadLangs(array('recruitment')); - $out = img_picto('', 'globe').' '.$langs->trans("PublicUrl").'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("PublicUrl").'
    '; $url = getPublicJobPositionUrl(0, $object->ref); - $out .= ''; - $out .= ''.img_picto('', 'globe').''; + $out .= ''; $out .= ajax_autoselect("recruitmentjobpositionurl", 0); print $out; diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index 9a3339b5130..0f1bdeef0fc 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -106,7 +106,8 @@ if ($id > 0 || !empty($ref)) { // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; -//$result = restrictedArea($user, 'recruitment', $object->id); +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index d497fa3d998..c28a55e0b2d 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -181,17 +181,11 @@ $permissiontoread = $user->rights->recruitment->recruitmentjobposition->read; $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete; -// Security check -if (empty($conf->recruitment->enabled)) { - accessforbidden('Module not enabled'); -} -$socid = 0; -if ($user->socid > 0) { // Protection if external user - //$socid = $user->socid; - accessforbidden(); -} -//$result = restrictedArea($user, 'recruitment', $id, ''); -//if (!$permissiontoread) accessforbidden(); +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentjobposition', 'recruitmentjobposition'); diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index 9dcb5ad9d7d..9dbcd0e1180 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -88,6 +88,11 @@ if ($id > 0 || !empty($ref)) { $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php +// Security check - Protection if external user +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; +$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); +$result = restrictedArea($user, 'recruitment', $object->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); /* diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 5ab07cdd536..4979a883d9c 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -410,7 +410,7 @@ class Dolresource extends CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " WHERE rowid =".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this), LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index c16018a30c1..83a8d58d410 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2018 Jean-François Ferry * Copyright (C) 2016 Gilles Poirier * Copyright (C) 2019 Josep Lluís Amador + * Copyright (C) 2021 Frédéric France * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -118,7 +119,7 @@ if (empty($reshook)) { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($resource_type)."'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($objstat->element)."'"; - $sql .= " WHERE er.resource_id = ".$resource_id; + $sql .= " WHERE er.resource_id = ".((int) $resource_id); $sql .= " AND er.busy = 1"; $sql .= " AND ("; @@ -193,8 +194,8 @@ if (empty($reshook)) { $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = '".$db->escape($object->resource_type)."'"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element_type)."'"; - $sql .= " WHERE er.resource_id = ".$object->resource_id; - $sql .= " AND ac.id != ".$object->element_id; + $sql .= " WHERE er.resource_id = ".((int) $object->resource_id); + $sql .= " AND ac.id <> ".((int) $object->element_id); $sql .= " AND er.busy = 1"; $sql .= " AND ("; @@ -355,7 +356,10 @@ if (!$ret) { // Type if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''.$act->type.''; + print ''.$langs->trans("Type").''; + print $act->getTypePicto(); + print $langs->trans("Action".$act->type_code); + print ''; } // Full day event diff --git a/htdocs/salaries/admin/index.html b/htdocs/salaries/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/salaries/admin/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 775221caeb2..323e2c74c5a 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -45,6 +45,7 @@ if (!empty($conf->projet->enabled)) { } $id = GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0; @@ -63,13 +64,6 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday $label = GETPOST('label', 'alphanohtml'); $fk_user = GETPOSTINT('userid'); -// Security check -$socid = GETPOSTINT('socid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - $object = new Salary($db); $extrafields = new ExtraFields($db); @@ -79,6 +73,18 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salarycard', 'globalcard')); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', $object->id, 'salary', ''); + /** * Actions @@ -282,7 +288,7 @@ if ($action == 'confirm_delete') { } -if ($action == 'update' && !$_POST["cancel"] && $user->rights->salaries->write) { +if ($action == 'update' && !GETPOST("cancel") && $user->rights->salaries->write) { $amount = price2num(GETPOST('amount'), 'MT', 2); if (empty($amount)) { @@ -780,7 +786,7 @@ if ($id) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; $sql .= ", ".MAIN_DB_PREFIX."salary as salaire"; - $sql .= " WHERE p.fk_salary = ".$id; + $sql .= " WHERE p.fk_salary = ".((int) $id); $sql .= " AND p.fk_salary = salaire.rowid"; $sql .= " AND salaire.entity IN (".getEntity('tax').")"; $sql .= " ORDER BY dp DESC"; @@ -885,21 +891,22 @@ if ($id) { /* * Action bar */ + print '
    '."\n"; if ($action != 'edit') { // Reopen if ($object->paye && $user->rights->salaries->write) { - print ""; + print ""; } // Edit if ($object->paye == 0 && $user->rights->salaries->write) { - print ""; + print ""; } // Emit payment if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->salaries->write) { - print ""; + print ""; } // Classify 'paid' @@ -909,16 +916,16 @@ if ($id) { || (round($resteapayer) >= 0 && $object->amount < 0) ) && $user->rights->salaries->write) { - print ""; + print ""; } // Clone if ($user->rights->salaries->write) { - print ""; + print ""; } if (!empty($user->rights->salaries->delete) && empty($totalpaye)) { - print ''; + print ''; } else { print ''; } diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index dc7e310d560..dcb50dac49a 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -570,7 +570,7 @@ class PaymentSalary extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index 123dc044a4a..b3e6c20a0ca 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -64,10 +64,10 @@ class SalariesStats extends Stats $this->where = " entity = ".$conf->entity; if ($this->socid > 0) { - $this->where .= " AND fk_soc = ".$this->socid; + $this->where .= " AND fk_soc = ".((int) $this->socid); } if (is_array($this->userid) && count($this->userid) > 0) { - $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; + $this->where .= ' AND fk_user IN ('.$this->db->sanitize(join(',', $this->userid)).')'; } elseif ($this->userid > 0) { $this->where .= ' AND fk_user = '.$this->userid; } @@ -101,7 +101,7 @@ class SalariesStats extends Stats { $sql = "SELECT MONTH(datep) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(datep) = ".$year; + $sql .= " WHERE YEAR(datep) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index fdd1bfd7f73..85ccfc0a1db 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -463,7 +463,7 @@ class Salary extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.((int) $id_bank); $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php index 9534d074d5f..5772de8af3a 100644 --- a/htdocs/salaries/document.php +++ b/htdocs/salaries/document.php @@ -44,14 +44,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -70,13 +62,21 @@ if (!$sortfield) { $sortfield = "name"; } - $object = new Salary($db); -$object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} $upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id); $modulepart = 'salaries'; +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', $object->id, 'salary', ''); + /* * Actions diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php index e0e6aec7f3c..1b81a80189f 100644 --- a/htdocs/salaries/info.php +++ b/htdocs/salaries/info.php @@ -33,14 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm")); $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'salaries', '', '', ''); +restrictedArea($user, 'salaries', $object->id, 'salary', ''); /* diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 7bc75f52793..7c4f0a2cec3 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -108,13 +108,6 @@ if (!GETPOST('search_type_id', 'int')) { $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'salaries', '', '', ''); - // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -161,6 +154,13 @@ $permissiontoread = $user->rights->salaries->read; $permissiontoadd = $user->rights->salaries->write; $permissiontodelete = $user->rights->salaries->delete; +// Security check +$socid = GETPOST("socid", "int"); +if ($user->socid) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', '', 'salary', ''); + /* * Actions @@ -234,8 +234,8 @@ $help_url = ''; $title = $langs->trans('Salaries'); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; -$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, ps.fk_typepayment as paymenttype, "; -$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; +$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment as paymenttype, "; +$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,"; $sql .= " pst.code as payment_code,"; $sql .= " SUM(ps.amount) as alreadypayed"; $sql .= " FROM ".MAIN_DB_PREFIX."salary as s"; @@ -247,7 +247,7 @@ $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = s.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; if (empty($user->rights->salaries->readall)) { - $sql .= " AND s.fk_user IN (".join(',', $childids).")"; + $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; } // Search criteria @@ -270,21 +270,17 @@ if ($search_amount) { $sql .= natural_search("s.amount", $search_amount, 1); } if ($search_account > 0) { - $sql .= " AND b.fk_account=".((int) $search_account); + $sql .= " AND s.fk_account=".((int) $search_account); } if ($search_status != '' && $search_status >= 0) { $sql .= " AND s.paye = ".$db->escape($search_status); } -if ($filtre) { - $filtre = str_replace(":", "=", $filtre); - $sql .= " AND ".$filtre; -} if ($search_type_id) { $sql .= " AND s.fk_typepayment=".$search_type_id; } $sql .= " GROUP BY u.rowid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary, u.fk_soc, u.statut,"; -$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, ps.fk_typepayment, s.fk_bank,"; -$sql .= " ba.rowid, ba.ref, ba.number, ba.account_number, ba.fk_accountancy_journal, ba.label,"; +$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment, s.fk_bank,"; +$sql .= " ba.rowid, ba.ref, ba.number, ba.account_number, ba.fk_accountancy_journal, ba.label, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos,"; $sql .= " pst.code"; $sql .= $db->order($sortfield, $sortorder); @@ -413,10 +409,6 @@ print ''; print ''; print ''; print ''; -// Employee -print ''; -print ''; -print ''; // Label print ''; @@ -440,6 +432,11 @@ print $form->selectDate($search_date_end_to ? $search_date_end_to : -1, 'search_ print '
    '; print ''; +// Employee +print ''; +print ''; +print ''; + // Type print ''; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); @@ -479,10 +476,10 @@ print ''."\n"; // -------------------------------------------------------------------- print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "s.dateep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("DefaultPaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) { print_liste_field_titre("DefaultBankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); @@ -545,12 +542,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } - // Employee - print "".$userstatic->getNomUrl(1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - // Label payment print "".dol_trunc($obj->label, 40)."\n"; if (!$i) { @@ -569,8 +560,16 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } + // Employee + print "".$userstatic->getNomUrl(1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + // Type - print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).''; + print ''; + if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -582,7 +581,13 @@ while ($i < ($limit ? min($num, $limit) : $num)) { //$accountstatic->fetch($obj->fk_bank); $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; + $accountstatic->label = $obj->blabel; $accountstatic->number = $obj->bnumber; + $accountstatic->iban = $obj->iban; + $accountstatic->bic = $obj->bic; + $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $accountstatic->account_number = $obj->account_number; + $accountstatic->clos = $obj->clos; if (!empty($conf->accounting->enabled)) { $accountstatic->account_number = $obj->account_number; @@ -606,7 +611,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; // Amount - print ''.price($obj->amount).''; + print ''.price($obj->amount).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index ac70d5c4a8c..2f4a0c85905 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/compta/paiement_charge.php - * \ingroup tax - * \brief Page to add payment of a tax + * \file htdocs/compta/paiement_salary.php + * \ingroup salary + * \brief Page to add payment of a salary */ require '../main.inc.php'; @@ -31,15 +31,25 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->load("bills"); -$chid = GETPOST("id", 'int'); $action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + +$id = GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); $amounts = array(); +$object = new Salary($db); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} + // Security check -$socid = 0; +$socid = GETPOST("socid", "int"); if ($user->socid > 0) { $socid = $user->socid; } +restrictedArea($user, 'salaries', $object->id, 'salary', ''); /* @@ -49,8 +59,8 @@ if ($user->socid > 0) { if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; - if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; + if ($cancel) { + $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; header("Location: ".$loc); exit; } @@ -73,29 +83,29 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y $action = 'create'; } + // Read possible payments + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_') { + $other_chid = substr($key, 7); + $amounts[$other_chid] = price2num($_POST[$key]); + } + } + + if ($amounts[key($amounts)] <= 0) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); + $action = 'create'; + } + if (!$error) { $paymentid = 0; - // Read possible payments - foreach ($_POST as $key => $value) { - if (substr($key, 0, 7) == 'amount_') { - $other_chid = substr($key, 7); - $amounts[$other_chid] = price2num($_POST[$key]); - } - } - - if (count($amounts) <= 0) { - $error++; - setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); - $action = 'create'; - } - if (!$error) { $db->begin(); // Create a line of payments $paiement = new PaymentSalary($db); - $paiement->chid = $chid; + $paiement->chid = $id; $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Tableau de montant $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); @@ -123,7 +133,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y if (!$error) { $db->commit(); - $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; + $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$id; header('Location: '.$loc); exit; } else { @@ -138,15 +148,16 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y * View */ -llxHeader(); - $form = new Form($db); +$help_url = ''; + +llxHeader('', '', $help_url); + +$salary = $object; // Formulaire de creation d'un paiement de charge if ($action == 'create') { - $salary = new Salary($db); // Salary to pay - $salary->fetch($chid); $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid; $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype; @@ -170,15 +181,15 @@ if ($action == 'create') { print '
    '; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print dol_get_fiche_end(); + print dol_get_fiche_head(); print ''; - print ''; + print ''; print '\n"; print '\n"; print '\n"; @@ -187,32 +198,32 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " WHERE p.fk_salary = ".$chid; + $sql .= " WHERE p.fk_salary = ".((int) $id); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''; print '';*/ print '"; print ''; print '\n"; print ''; print ''; print ''; print ''; // Number @@ -270,12 +281,13 @@ if ($action == 'create') { if ($sumpaid < $objp->amount) { $namef = "amount_".$objp->id; $nameRemain = "remain_".$objp->id; + /* Disabled, we autofil the amount with remain to pay by default if (!empty($conf->use_javascript_ajax)) { print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); - } + } */ $remaintopay = $objp->amount - $sumpaid; print ''; - print ''; + print ''; } else { print '-'; } diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index c6d1fd7d07f..ae711719585 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -41,14 +41,13 @@ $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); if ($user->socid) $socid = $user->socid; -// TODO ajouter regle pour restreindre acces paiement -//$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentSalary($db); if ($id > 0) { $result = $object->fetch($id); if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); } +restrictedArea($user, 'salaries', $object->fk_salary, 'salary', ''); // $object is payment of salary /* @@ -255,7 +254,7 @@ print '
    '; if ($action == '') { if ($user->rights->salaries->delete) { if (!$disable_delete) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { print ''.$langs->trans('Delete').''; } diff --git a/htdocs/salaries/payment_salary/index.html b/htdocs/salaries/payment_salary/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/salaries/payment_salary/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 5c0b0c73956..f0602e88a5c 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -75,8 +75,12 @@ $search_user = GETPOST('search_user', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_dateep_start = dol_mktime(0, 0, 0, GETPOST('search_dateep_startmonth', 'int'), GETPOST('search_dateep_startday', 'int'), GETPOST('search_dateep_startyear', 'int')); +$search_dateep_end = dol_mktime(23, 59, 59, GETPOST('search_dateep_endmonth', 'int'), GETPOST('search_dateep_endday', 'int'), GETPOST('search_dateep_endyear', 'int')); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'int'); +$search_fk_bank = GETPOST('search_fk_bank', 'int'); +$search_chq_number = GETPOST('search_chq_number', 'int'); $filtre = GETPOST("filtre", 'restricthtml'); @@ -93,11 +97,6 @@ if (!GETPOST('search_type_id', 'int')) { $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'salaries', '', '', ''); - // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); @@ -115,6 +114,13 @@ $permissiontoread = $user->rights->salaries->read; $permissiontoadd = $user->rights->salaries->write; $permissiontodelete = $user->rights->salaries->delete; +// Security check +$socid = GETPOST("socid", "int"); +if ($user->socid > 0) { + $socid = $user->socid; +} +restrictedArea($user, 'salaries', 0, 'salary', ''); + /* * Actions @@ -139,8 +145,12 @@ if (empty($reshook)) { $search_label = ""; $search_date_start = ''; $search_date_end = ''; + $search_dateep_start = ''; + $search_dateep_end = ''; $search_amount = ""; $search_account = ''; + $search_fk_bank = ''; + $search_chq_number = ''; $search_type_id = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -171,6 +181,7 @@ $salstatic = new Salary($db); $paymentsalstatic = new PaymentSalary($db); $userstatic = new User($db); $accountstatic = new Account($db); +$accountlinestatic = new AccountLine($db); $now = dol_now(); @@ -179,8 +190,8 @@ $help_url = ''; $title = $langs->trans('SalariesPayments'); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; -$sql .= " s.rowid, s.fk_user, s.amount, s.salary, sal.rowid as id_salary, sal.label, s.datep as datep, b.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; -$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; +$sql .= " s.rowid, s.fk_user, s.amount, s.salary, sal.rowid as id_salary, sal.label, s.datep as datep, sal.dateep, b.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; +$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,"; $sql .= " pst.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as sal ON (sal.rowid = s.fk_salary)"; @@ -190,22 +201,23 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = sal.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; -if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")"; +if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; // Search criteria if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref); -if ($search_ref_salary) $sql .= " AND sal.rowid=".((int) $search_ref_salary); +if ($search_ref_salary) $sql .= " AND sal.rowid=".((int) $search_ref_salary); if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); if ($search_label) $sql .= natural_search(array('sal.label'), $search_label); if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; +if ($search_dateep_start) $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'"; +if ($search_dateep_end) $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'"; if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); -if ($filtre) { - $filtre = str_replace(":", "=", $filtre); - $sql .= " AND ".$filtre; -} -if ($search_type_id) { +if ($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); +if ($search_chq_number) $sql .= natural_search(array('s.num_payment'), $search_chq_number); + +if ($search_type_id > 0) { $sql .= " AND s.fk_typepayment=".$search_type_id; } $sql .= $db->order($sortfield, $sortorder); @@ -249,11 +261,15 @@ if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_ref_salary) $param .= '&search_ref_salary='.urlencode($search_ref_salary); -if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); +if ($search_user) $param .= '&search_user='.urlencode($search_user); if ($search_label) $param .= '&search_label='.urlencode($search_label); +if ($search_fk_bank) $param .= '&search_fk_bank='.urlencode($search_fk_bank); +if ($search_chq_number) $param .= '&search_chq_number='.urlencode($search_chq_number); if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); +if ($search_dateep_start) $param .= '&search_dateep_startday='.urlencode(GETPOST('search_dateep_startday', 'int')).'&search_dateep_startmonth='.urlencode(GETPOST('search_dateep_startmonth', 'int')).'&search_dateep_startyear='.urlencode(GETPOST('search_dateep_startyear', 'int')); if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +if ($search_dateep_end) $param .= '&search_dateep_endday='.urlencode(GETPOST('search_dateep_endday', 'int')).'&search_dateep_endmonth='.urlencode(GETPOST('search_dateep_endmonth', 'int')).'&search_dateep_endyear='.urlencode(GETPOST('search_dateep_endyear', 'int')); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -296,16 +312,21 @@ print '
    '; print ''; -// Employee -print ''; // Salary print ''; // Label print ''; +// Date end period +print ''; // Date payment print ''; // Date value -print '';*/ +// Employee +print ''; // Type print ''; -// Account +// Chq number +print ''; + if (!empty($conf->banque->enabled)) { + // Bank transaction + print ''; + + // Account print ''; @@ -349,14 +382,19 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); +print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "sal.dateep", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); -print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); +//print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, 'class="left"', $sortfield, $sortorder); -if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); +if (!empty($conf->banque->enabled)) { + print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "s.fk_bank", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); +} print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -411,10 +449,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print "\n"; if (!$i) $totalarray['nbfield']++; - // Employee - print "\n"; - if (!$i) $totalarray['nbfield']++; - print "\n"; if (!$i) $totalarray['nbfield']++; @@ -422,26 +456,49 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print "\n"; if (!$i) $totalarray['nbfield']++; + // Date end period + print '\n"; + if (!$i) $totalarray['nbfield']++; + // Date payment print '\n"; if (!$i) $totalarray['nbfield']++; // Date value - print '\n"; + /*print '\n"; + if (!$i) $totalarray['nbfield']++;*/ + + // Employee + print "\n"; if (!$i) $totalarray['nbfield']++; // Type - print ''; + print ''; + if (!$i) $totalarray['nbfield']++; + + // Chq number + print ''; if (!$i) $totalarray['nbfield']++; // Account if (!empty($conf->banque->enabled)) { + // Bank transaction + print ''; + if (!$i) $totalarray['nbfield']++; + print ''; if (!$i) $totalarray['nbfield']++; } // Amount - print ''; + print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php similarity index 84% rename from htdocs/societe/ajaxcompanies.php rename to htdocs/societe/ajax/ajaxcompanies.php index 3221aafff55..9295c363206 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/societe/ajaxcompanies.php + * \file htdocs/societe/ajax/ajaxcompanies.php * \brief File to return Ajax response on third parties request */ @@ -42,7 +42,22 @@ if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } -require '../main.inc.php'; +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + +$id = GETPOST('socid', 'int') || GETPOST('id_fourn', 'int'); + +$object = new Societe($db); +if ($id > 0) { + $object->fetch($id); +} + +// Security check +if ($user->socid > 0) { + $socid = $user->socid; + $object->id = $socid; +} +restrictedArea($user, 'societe', $object->id, '&societe'); /* @@ -58,20 +73,18 @@ top_httphead(); //print ''."\n"; -dol_syslog(join(',', $_GET)); - -// Generation liste des societes -if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { +// Generate list of companies +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn', 'int')) { $return_arr = array(); // Define filter on text typed - $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + $socid = GETPOST('newcompany'); if (!$socid) { - $socid = $_GET['socid'] ? $_GET['socid'] : ''; + $socid = GETPOST('socid', 'int'); } if (!$socid) { - $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + $socid = GETPOST('id_fourn', 'int'); } $sql = "SELECT rowid, nom"; @@ -90,7 +103,7 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { $sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'"; } if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) { - $sql .= " OR rowid = '".$db->escape($socid)."'"; + $sql .= " OR rowid = ".((int) $socid); } $sql .= ")"; } diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index ba33386f360..76151bccb97 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -42,22 +42,35 @@ if (!defined('NOCSRFCHECK')) { } require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $htmlname = GETPOST('htmlname', 'alpha'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); +$excludeids = GETPOST('excludeids', 'intcomma'); $showtype = GETPOST('showtype', 'int'); +$object = new Societe($db); +if ($id > 0) { + $object->fetch($id); +} + +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; + $object->id = $socid; +} +restrictedArea($user, 'societe', $object->id, '&societe'); + /* * View */ //print ''."\n"; - -dol_syslog(join(',', $_GET)); //print_r($_GET); if (!empty($action) && $action == 'fetch' && !empty($id)) { @@ -65,9 +78,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { $outjson = array(); - $object = new Societe($db); - $ret = $object->fetch($id); - if ($ret > 0) { + if ($object->id > 0) { $outref = $object->ref; $outname = $object->name; $outdesc = ''; @@ -88,12 +99,16 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { return; } + // Filter on the company to search can be: + // Into an array with key $htmlname123 (we take first one found). Which page use this ? + // Into a var with name $htmlname can be 'prodid', 'productid', ... $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $id = (!empty($match[0]) ? $match[0] : ''); + + $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); if (!$searchkey) { return; @@ -102,6 +117,11 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { if (!is_object($form)) { $form = new Form($db); } + + if (!empty($excludeids)) { + $filter .= 'rowid NOT IN ('.$db->sanitize($excludeids).')'; + } + $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); $db->close(); diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php deleted file mode 100644 index a4efc4ecc94..00000000000 --- a/htdocs/societe/ajaxcountries.php +++ /dev/null @@ -1,86 +0,0 @@ - - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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/societe/ajaxcountries.php - * \brief File to return Ajax response on country request - */ - -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', 1); // Disables token renewal -} -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} - -require '../main.inc.php'; - -$country = GETPOST('country', 'alpha'); - - -/* - * View - */ - -// Ajout directives pour resoudre bug IE -//header('Cache-Control: Public, must-revalidate'); -//header('Pragma: public'); - -//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. -top_httphead(); - -print ''."\n"; - -dol_syslog(join(',', $_POST)); - -// Generate list of countries -if (!empty($country)) { - global $langs; - $langs->load("dict"); - - $sql = "SELECT rowid, code, label, active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; - $sql .= " WHERE active = 1 AND label LIKE '%".$db->escape(utf8_decode($country))."%'"; - $sql .= " ORDER BY label ASC"; - - $resql = $db->query($sql); - if ($resql) { - print '
      '; - while ($country = $db->fetch_object($resql)) { - print '
    • '; - // Si traduction existe, on l'utilise, sinon on prend le libellé par défaut - print ($country->code && $langs->trans("Country".$country->code) != "Country".$country->code ? $langs->trans("Country".$country->code) : ($country->label != '-' ? $country->label : ' ')); - print ''; - print '
    • '; - } - print '
    '; - } -} diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index da7e68d4849..53748c1465a 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -387,40 +387,40 @@ abstract class ActionsCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->id = $_POST["socid"]; - $this->object->name = $_POST["nom"]; - $this->object->prefix_comm = $_POST["prefix_comm"]; - $this->object->client = $_POST["client"]; - $this->object->code_client = $_POST["code_client"]; - $this->object->fournisseur = $_POST["fournisseur"]; - $this->object->code_fournisseur = $_POST["code_fournisseur"]; - $this->object->address = $_POST["adresse"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone = $_POST["tel"]; - $this->object->fax = $_POST["fax"]; - $this->object->email = $_POST["email"]; - $this->object->url = $_POST["url"]; - $this->object->capital = $_POST["capital"]; - $this->object->idprof1 = $_POST["idprof1"]; - $this->object->idprof2 = $_POST["idprof2"]; - $this->object->idprof3 = $_POST["idprof3"]; - $this->object->idprof4 = $_POST["idprof4"]; - $this->object->typent_id = $_POST["typent_id"]; - $this->object->effectif_id = $_POST["effectif_id"]; - $this->object->barcode = $_POST["barcode"]; - $this->object->forme_juridique_code = $_POST["forme_juridique_code"]; - $this->object->default_lang = $_POST["default_lang"]; - $this->object->commercial_id = $_POST["commercial_id"]; + $this->object->id = GETPOST("socid"); + $this->object->name = GETPOST("nom"); + $this->object->prefix_comm = GETPOST("prefix_comm"); + $this->object->client = GETPOST("client"); + $this->object->code_client = GETPOST("code_client"); + $this->object->fournisseur = GETPOST("fournisseur"); + $this->object->code_fournisseur = GETPOST("code_fournisseur"); + $this->object->address = GETPOST("adresse"); + $this->object->zip = GETPOST("zipcode"); + $this->object->town = GETPOST("town"); + $this->object->country_id = GETPOST("country_id") ? GETPOST("country_id") : $mysoc->country_id; + $this->object->state_id = GETPOST("state_id"); + $this->object->phone = GETPOST("tel"); + $this->object->fax = GETPOST("fax"); + $this->object->email = GETPOST("email", 'alphawithlgt'); + $this->object->url = GETPOST("url"); + $this->object->capital = GETPOST("capital"); + $this->object->idprof1 = GETPOST("idprof1"); + $this->object->idprof2 = GETPOST("idprof2"); + $this->object->idprof3 = GETPOST("idprof3"); + $this->object->idprof4 = GETPOST("idprof4"); + $this->object->typent_id = GETPOST("typent_id"); + $this->object->effectif_id = GETPOST("effectif_id"); + $this->object->barcode = GETPOST("barcode"); + $this->object->forme_juridique_code = GETPOST("forme_juridique_code"); + $this->object->default_lang = GETPOST("default_lang"); + $this->object->commercial_id = GETPOST("commercial_id"); - $this->object->tva_assuj = $_POST["assujtva_value"] ? $_POST["assujtva_value"] : 1; - $this->object->tva_intra = $_POST["tva_intra"]; + $this->object->tva_assuj = GETPOST("assujtva_value") ? GETPOST("assujtva_value") : 1; + $this->object->tva_intra = GETPOST("tva_intra"); //Local Taxes - $this->object->localtax1_assuj = $_POST["localtax1assuj_value"]; - $this->object->localtax2_assuj = $_POST["localtax2assuj_value"]; + $this->object->localtax1_assuj = GETPOST("localtax1assuj_value"); + $this->object->localtax2_assuj = GETPOST("localtax2assuj_value"); // We set country_id, and country_code label of the chosen country if ($this->object->country_id) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e7d40037155..68efa8e694c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -117,6 +117,13 @@ if (!empty($canvas)) { $objcanvas->getCanvas('thirdparty', 'card', $canvas); } +$permissiontoread = $user->rights->societe->lire; +$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); @@ -130,12 +137,6 @@ if ($object->id > 0) { } */ -$permissiontoread = $user->rights->societe->lire; -$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); -$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php -$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; /* @@ -792,7 +793,7 @@ if (empty($reshook)) { // Update linked member if (!$error && $object->fk_soc > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id; + $sql .= " SET fk_soc = NULL WHERE fk_soc = ".((int) $socid); if (!$object->db->query($sql)) { $error++; $object->error .= $object->db->lasterror(); @@ -2067,8 +2068,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '; // EMail / Web - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -2399,7 +2400,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid <> '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200', '', '', 1, null, false, array($object->id)) ) ); @@ -2773,7 +2774,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
    '.$langs->trans("Ref").''.$chid.'
    '.$langs->trans("Ref").''.$id.'
    '.$langs->trans("DateStart")."".dol_print_date($salary->datesp, 'day')."
    '.$langs->trans("DateEnd")."".dol_print_date($salary->dateep, 'day')."
    '.$langs->trans("Label").''.$salary->label."
    '.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
    '.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
    '.$langs->trans("Date").''; - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : ''; + $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (GETPOST("remonth") ? $datepaye : -1) : ''; print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); print "
    '.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $salary->type_payment, "paiementtype"); + $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $salary->type_payment, "paiementtype"); print "
    '.$langs->trans('AccountToDebit').''; - $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $salary->accountid, "accountid", 0, '', 1); // Show opend bank account list + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $salary->accountid, "accountid", 0, '', 1); // Show opend bank account list print '
    '; print ''; print ''; -print ''; -print ''; print ''; print ''; +print '
    '; +print $form->selectDate($search_dateep_start ? $search_dateep_start : -1, 'search_dateep_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); +print '
    '; +print '
    '; +print $form->selectDate($search_dateep_end ? $search_dateep_end : -1, 'search_dateep_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); +print '
    '; +print '
    '; print '
    '; @@ -316,14 +337,26 @@ print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_e print '
    '; print '
    '; +/*print ''; +print ''; +print ''; print ''; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); print ''; + print ''; + print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print '
    ".$paymentsalstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".$salstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->dateep), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."".$userstatic->getNomUrl(1)."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.$langs->trans("PaymentTypeShort".$obj->payment_code).''.$obj->num_payment.''; + $accountlinestatic->id = $obj->fk_bank; + print $accountlinestatic->getNomUrl(1); + print ''; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; $accountstatic->number = $obj->bnumber; + $accountstatic->iban = $obj->iban; + $accountstatic->bic = $obj->bic; + $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $accountstatic->clos = $obj->clos; if (!empty($conf->accounting->enabled)) { $accountstatic->account_number = $obj->account_number; @@ -452,14 +509,16 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); + if ($accountstatic->id > 0) { + print $accountstatic->getNomUrl(1); + } } else print ' '; print ''.price($obj->amount).''.price($obj->amount).''.img_picto('', 'object_phoning_fax').'
    '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''.img_picto('', 'object_email').'
    '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''.img_picto('', 'object_email').'
    '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''.img_picto('', 'globe').'
    '; print ''; $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, 's.rowid <> '.$object->id, 1); + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, null, 0, array($object->id)); print ''; } diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index 995f256bc01..577256f06aa 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -21,6 +21,8 @@ * \brief Popup screen to validate VAT */ +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) + require "../../main.inc.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once NUSOAP_PATH.'/nusoap.php'; diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 37ad82602fb..5a6513ef6e5 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -74,6 +74,7 @@ class Contacts extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); } + if ($id == 0) { $result = $this->contact->initAsSpecimen(); } else { @@ -117,6 +118,7 @@ class Contacts extends DolibarrApi if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); } + if (empty($email)) { $result = $this->contact->initAsSpecimen(); } else { @@ -192,7 +194,7 @@ class Contacts extends DolibarrApi $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid"; $sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')'; if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { @@ -203,7 +205,7 @@ class Contacts extends DolibarrApi } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Select contacts of given category diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ed62e5a224f..b0b486459b1 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -132,6 +132,10 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); + if (!DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + // case of external user, we force socids $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; @@ -187,14 +191,14 @@ class Thirdparties extends DolibarrApi } //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; if ($socids) { - $sql .= " AND t.rowid IN (".$socids.")"; + $sql .= " AND t.rowid IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Add sql filters if ($sqlfilters) { @@ -575,7 +579,7 @@ class Thirdparties extends DolibarrApi throw new RestException(401, 'Access to thirdparty '.$id.' not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->company->set_price_level($priceLevel, DolibarrApiAccess::$user); + $result = $this->company->setPriceLevel($priceLevel, DolibarrApiAccess::$user); if ($result <= 0) { throw new RestException(500, 'Error setting new price level for thirdparty '.$id, array($this->company->db->lasterror())); } @@ -1017,7 +1021,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id; + $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".((int) $id); if ($filter == "available") { $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; } @@ -1155,7 +1159,7 @@ class Thirdparties extends DolibarrApi $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) { - $sql .= " WHERE fk_soc = ".$id." "; + $sql .= " WHERE fk_soc = ".((int) $id); } @@ -1364,10 +1368,10 @@ class Thirdparties extends DolibarrApi $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; if ($id) { - $sql .= " WHERE fk_soc = ".$id." "; + $sql .= " WHERE fk_soc = ".((int) $id); } if ($companybankid) { - $sql .= " AND rowid = ".$companybankid.""; + $sql .= " AND rowid = ".((int) $companybankid); } $i = 0; @@ -1433,9 +1437,9 @@ class Thirdparties extends DolibarrApi * We select all the records that match the socid */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE fk_soc = $id"; + $sql .= " WHERE fk_soc = ".((int) $id); if ($site) { - $sql .= " AND site ='$site'"; + $sql .= " AND site ='".$this->db->escape($site)."'"; } $result = $this->db->query($sql); @@ -1505,7 +1509,7 @@ class Thirdparties extends DolibarrApi throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."'"; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) == 0) { @@ -1585,7 +1589,7 @@ class Thirdparties extends DolibarrApi // We found an existing SocieteAccount entity, we are replacing it } else { if (isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { @@ -1649,7 +1653,7 @@ class Thirdparties extends DolibarrApi } else { // If the user tries to edit the site member, we check first if if (isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id)." AND site = '".$this->db->escape($request_data['site'])."' "; $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) !== 0) { @@ -1733,7 +1737,7 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".((int) $id); $result = $this->db->query($sql); @@ -1842,9 +1846,11 @@ class Thirdparties extends DolibarrApi private function _fetch($rowid, $ref = '', $ref_ext = '', $barcode = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { global $conf; + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } + if ($rowid === 0) { $result = $this->company->initAsSpecimen(); } else { diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index 6b09d88ac71..eefb71b6772 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -104,7 +104,7 @@ class Client extends Societe $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm"; if ($active >= 0) { - $sql .= " WHERE active = ".$active; + $sql .= " WHERE active = ".((int) $active); } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index c611ccab462..3e410019b22 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -217,12 +217,12 @@ class CompanyBankAccount extends Account $sql .= " WHERE rowid = ".((int) $id); } if ($socid) { - $sql .= " WHERE fk_soc = ".$socid; + $sql .= " WHERE fk_soc = ".((int) $socid); if ($default > -1) { - $sql .= " AND default_rib = ".$this->db->escape($default); + $sql .= " AND default_rib = ".((int) $default); } if ($type) { - $sql .= " AND type ='".$this->db->escape($type)."'"; + $sql .= " AND type = '".$this->db->escape($type)."'"; } } @@ -351,12 +351,12 @@ class CompanyBankAccount extends Account $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; - $sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE type = 'ban' AND fk_soc = ".((int) $obj->fk_soc); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3 .= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".((int) $obj->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index db19840fd8e..1f11e6a29c3 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -318,7 +318,7 @@ class CompanyPaymentMode extends CommonObject public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '') { if ($socid) { - $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1"; + $morewhere .= " AND fk_soc = ".((int) $socid)." AND default_rib = 1"; } if ($type) { $morewhere .= " AND type = '".$this->db->escape($type)."'"; @@ -464,7 +464,7 @@ class CompanyPaymentMode extends CommonObject $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms"; - $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".((int) $obj->fk_soc); if ($type) { $sql2 .= " AND type = '".$this->db->escape($type)."'"; } @@ -472,7 +472,7 @@ class CompanyPaymentMode extends CommonObject $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3 .= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".((int) $obj->id); if ($type) { $sql3 .= " AND type = '".$this->db->escape($type)."'"; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c141290d9e9..9d449922dd2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -868,6 +868,7 @@ class Societe extends CommonObject $sql .= ", name_alias"; $sql .= ", entity"; $sql .= ", datec"; + $sql .= ", fk_typent"; $sql .= ", fk_user_creat"; $sql .= ", canvas"; $sql .= ", status"; @@ -882,6 +883,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_sell"; $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); + $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); $sql .= ", ".$this->status; $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); @@ -958,7 +960,7 @@ class Societe extends CommonObject * @param array $tags Array of tag to affect to contact * @return int <0 if KO, >0 if OK */ - public function create_individual(User $user, $no_email, $tags = array()) + public function create_individual(User $user, $no_email = 0, $tags = array()) { global $conf; @@ -1619,7 +1621,7 @@ class Societe extends CommonObject $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) { - $sql .= ' AND s.rowid = '.$rowid; + $sql .= ' AND s.rowid = '.((int) $rowid); } if ($ref) { $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; @@ -1905,7 +1907,7 @@ class Societe extends CommonObject } } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete; - $sql .= " WHERE fk_soc = ".$id; + $sql .= " WHERE fk_soc = ".((int) $id); if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1928,7 +1930,7 @@ class Societe extends CommonObject if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql .= " SET parent = NULL"; - $sql .= " WHERE parent = ".$id; + $sql .= " WHERE parent = ".((int) $id); if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1983,7 +1985,7 @@ class Societe extends CommonObject $newclient = 3; //If prospect, we keep prospect tag } $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET client = ".$newclient; + $sql .= " SET client = ".((int) $newclient); $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); @@ -2270,7 +2272,6 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the price level * @@ -2278,15 +2279,14 @@ class Societe extends CommonObject * @param User $user Use making change * @return int <0 if KO, >0 if OK */ - public function set_price_level($price_level, User $user) + public function setPriceLevel($price_level, User $user) { - // phpcs:enable if ($this->id) { $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " SET price_level = ".((int) $price_level); + $sql .= " WHERE rowid = ".((int) $this->id); if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -2295,7 +2295,7 @@ class Societe extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices"; $sql .= " (datec, fk_soc, price_level, fk_user_author)"; - $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; + $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", ".((int) $price_level).", ".$user->id.")"; if (!$this->db->query($sql)) { dol_print_error($this->db); @@ -2324,7 +2324,7 @@ class Societe extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user = ".((int) $commid); $resql = $this->db->query($sql); if (!$resql) { @@ -2387,7 +2387,7 @@ class Societe extends CommonObject if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; - $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user = ".((int) $commid); if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::del_commercial Erreur"); @@ -3793,11 +3793,14 @@ class Societe extends CommonObject $this->client = 1; // A member is a customer by default $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; + $this->typent_code = ($member->morphy == 'phy' ? 'TE_PRIVATE' : 0); + $this->typent_id = $this->typent_code ? dol_getIdFromCode($this->db, $this->typent_code, 'c_typent', 'id', 'code') : 0; $this->db->begin(); // Cree et positionne $this->id $result = $this->create($user); + if ($result >= 0) { // Auto-create contact on thirdparty creation if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { @@ -3808,6 +3811,7 @@ class Societe extends CommonObject dol_syslog("We ask to create a contact/address too", LOG_DEBUG); $result = $this->create_individual($user); + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); $this->db->rollback(); @@ -4614,7 +4618,7 @@ class Societe extends CommonObject $resql = $db->query($sql); while ($obj = $db->fetch_object($resql)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$obj->rowid); + $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); } /** diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 5be05d99a56..8fbbbbcee6e 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -284,7 +284,7 @@ class SocieteAccount extends CommonObject { $sql = "SELECT sa.key_account as key_account, sa.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as sa"; - $sql .= " WHERE sa.fk_soc = ".$id; + $sql .= " WHERE sa.fk_soc = ".((int) $id); $sql .= " AND sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.site = '".$this->db->escape($site)."' AND sa.status = ".((int) $status); $sql .= " AND sa.key_account IS NOT NULL AND sa.key_account <> ''"; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index a7ef895041e..3190ad5e64e 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -146,7 +146,7 @@ if ($object->client) { print ' ('.$langs->trans("WrongCustomerCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -183,7 +183,7 @@ if ($object->fournisseur) { print ' ('.$langs->trans("WrongSupplierCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -229,7 +229,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."fichinter as f LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as d ON d.fk_fichinter = f.rowid"; // Must use left join to work also with option that disable usage of lines. - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datec'; $doc_number = 'f.ref'; @@ -239,7 +239,7 @@ if ($type_element == 'invoice') { // Customer : show products from invoices $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_facture = f.rowid"; $where .= " AND f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; @@ -251,7 +251,7 @@ if ($type_element == 'propal') { $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_propal = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $datePrint = 'c.datep'; @@ -263,7 +263,7 @@ if ($type_element == 'order') { $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_commande'; @@ -275,7 +275,7 @@ if ($type_element == 'supplier_invoice') { // Supplier : Show products from inv $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; $tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d"; - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_facture_fourn = f.rowid"; $where .= " AND f.entity = ".$conf->entity; $dateprint = 'f.datef'; @@ -287,7 +287,7 @@ if ($type_element == 'supplier_proposal') { $documentstatic = new SupplierProposal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_supplier_proposal = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; @@ -299,7 +299,7 @@ if ($type_element == 'supplier_order') { // Supplier : Show products from order $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_commande = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; @@ -312,7 +312,7 @@ if ($type_element == 'contract') { // Order $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, '; $tables_from = MAIN_DB_PREFIX."contrat as c,".MAIN_DB_PREFIX."contratdet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); $where .= " AND d.fk_contrat = c.rowid"; $where .= " AND c.entity = ".$conf->entity; $dateprint = 'c.date_valid'; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 600cb03af1a..746d1c403c7 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -39,13 +39,6 @@ $confirm = GETPOST('confirm'); $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Security check -if ($user->socid > 0) { - unset($action); - $socid = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe'); - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -84,6 +77,13 @@ if ($id > 0 || !empty($ref)) { $hookmanager->initHooks(array('thirdpartydocument', 'globalcard')); +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', $object->id, '&societe'); + /* * Actions diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index b76a80e1148..c87d260f23e 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -101,8 +101,8 @@ $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($socid) { - $sql .= " AND s.rowid = ".$socid; +if ($socid > 0) { + $sql .= " AND s.rowid = ".((int) $socid); } if (!$user->rights->fournisseur->lire) { $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 74685d37b05..ef2fbccf490 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -463,7 +463,7 @@ $sql .= " country.code as country_code, country.label as country_label,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " region.code_region as region_code, region.nom as region_name"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) -if ($search_sale) { +if ($search_sale && $search_sale != '-1') { $sql .= ", sc.fk_soc, sc.fk_user"; } // We'll need these fields in order to filter by categ @@ -505,7 +505,7 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; if ($search_sale == -2) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} elseif ($search_sale || (empty($user->rights->societe->client->voir) && !$socid)) { +} elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (".getEntity('societe').")"; @@ -513,7 +513,7 @@ $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_sale && $search_sale != -2) { +if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } if (!$user->rights->fournisseur->lire) { @@ -584,7 +584,7 @@ if ($search_region) { $sql .= natural_search("region.nom", $search_region); } if ($search_country && $search_country != '-1') { - $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } if ($search_email) { $sql .= natural_search("s.email", $search_email); @@ -621,7 +621,7 @@ if (strlen($search_vat)) { } // Filter on type of thirdparty if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) { - $sql .= " AND s.client IN (".$db->sanitize($db->escape($search_type)).")"; + $sql .= " AND s.client IN (".$db->sanitize($search_type).")"; } if ($search_type > 0 && in_array($search_type, array('4'))) { $sql .= " AND s.fournisseur = 1"; @@ -941,7 +941,8 @@ if (empty($type) || $type == 'c' || $type == 'p') { if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'category', 'class="pictofixedwidth"'); + $tmptitle = $langs->trans('Categories'); + $moreforfilter .= img_picto($tmptile, 'category', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); $moreforfilter .= '
    '; } @@ -950,7 +951,8 @@ if (empty($type) || $type == 'f') { if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'category', 'class="pictofixedwidth"'); + $tmptitle = $langs->trans('Categories'); + $moreforfilter .= img_picto($tmptilte, 'category', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort')); $moreforfilter .= '
    '; } @@ -959,8 +961,9 @@ if (empty($type) || $type == 'f') { // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= img_picto('', 'user', 'class="pictofixedwidth"'); - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), 'maxwidth300', 1); + $tmptile = $langs->trans('SalesRepresentatives'); + $moreforfilter .= img_picto($tmptile, 'user', 'class="pictofixedwidth"'); + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1); $moreforfilter .= '
    '; } if ($moreforfilter) { @@ -1525,13 +1528,13 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['s.phone']['checked'])) { - print "".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; + print ''.dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['s.fax']['checked'])) { - print "".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; + print ''.dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 22f235df7de..2ebe97848f2 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -33,12 +33,7 @@ $action = GETPOST('action', 'aZ09'); $langs->load("companies"); -// Security check $id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); -if ($user->socid) { - $id = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) { @@ -50,6 +45,13 @@ $permissionnote = $user->rights->societe->creer; // Used by the include of actio // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartynote', 'globalcard')); +// Security check +if ($user->socid > 0) { + unset($action); + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', $object->id, '&societe'); + /* * Actions diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 8c321b1386d..dc8d95ef42f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -517,10 +517,10 @@ if (empty($reshook)) { $db->begin(); if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; } else { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! } $resql = $db->query($sql); @@ -542,7 +542,7 @@ if (empty($reshook)) { } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$db->escape($site_account)."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $servicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! $resql = $db->query($sql); } } @@ -761,7 +761,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ' ('.$langs->trans("WrongCustomerCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -823,7 +823,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ' ('.$langs->trans("WrongSupplierCode").')'; } print ''; - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 449fd9d7811..2a6dd2176df 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -95,14 +95,14 @@ if ($action == 'addcontact' && $user->rights->societe->creer) { } elseif ($action == 'swapstatut' && $user->rights->societe->creer) { // bascule du statut d'un contact if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } } elseif ($action == 'deletecontact' && $user->rights->societe->creer) { // Efface un contact $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); + $result = $object->delete_contact(GETPOST("lineid", 'int')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -227,7 +227,7 @@ if ($id > 0 || !empty($ref)) { $sql .= " t.libelle as type, t.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql .= " WHERE d.fk_soc = ".$id; + $sql .= " WHERE d.fk_soc = ".((int) $id); $sql .= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index e7a1e086228..e34672bfd1d 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -283,7 +283,7 @@ if ($objectwebsiteaccount->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } -$sql .= " AND fk_soc = ".$object->id; +$sql .= " AND fk_soc = ".((int) $object->id); foreach ($search as $key => $val) { $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0); if ($search[$key] != '') { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index edac0a79833..1e4e2ae9c1d 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -37,7 +37,10 @@ $servicename = 'Stripe'; // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'paypal', 'paybox', 'stripe')); -if (!$user->admin) { +if (empty($user->admin)) { + accessforbidden(); +} +if (empty($conf->stripe->enabled)) { accessforbidden(); } @@ -207,24 +210,21 @@ print ''; if (empty($conf->stripeconnect->enabled)) { print ''; print ''.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").''; - print ''; - print '   '.$langs->trans("Example").': pk_test_xxxxxxxxxxxxxxxxxxxxxxxx'; + print ''; print ''; print ''; print ''.$langs->trans("STRIPE_TEST_SECRET_KEY").''; - print ''; - print '   '.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx<'; + print ''; print ''; print ''; print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; + print ''; + print '
    '; } - print ''; - print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + print ''; $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForTestWebhook").' '; $url = dol_buildpath('/public/stripe/ipn.php?test', 3); $out .= ''; @@ -254,7 +254,7 @@ if (empty($conf->stripeconnect->enabled)) { } //print $endpoint; } else { - print img_picto($langs->trans("inactive"), 'statut5'); + print img_picto($langs->trans("Inactive"), 'statut5'); } } print''; @@ -272,24 +272,21 @@ if (empty($conf->stripeconnect->enabled)) { if (empty($conf->stripeconnect->enabled)) { print ''; print ''.$langs->trans("STRIPE_LIVE_PUBLISHABLE_KEY").''; - print ''; - print '   '.$langs->trans("Example").': pk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; + print ''; print ''; print ''; print ''.$langs->trans("STRIPE_LIVE_SECRET_KEY").''; - print ''; - print '   '.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx'; + print ''; print ''; print ''; print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; + print ''; + print '
    '; } - print ''; - print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + print ''; $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForLiveWebhook").' '; $url = dol_buildpath('/public/stripe/ipn.php', 3); $out .= ''; @@ -319,7 +316,7 @@ if (empty($conf->stripeconnect->enabled)) { } //print $endpoint; } else { - print img_picto($langs->trans("inactive"), 'statut5'); + print img_picto($langs->trans("Inactive"), 'statut5'); } } print ''; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index a3598f1d29f..c6a07593a04 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -52,6 +52,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$result = restrictedArea($user, 'banque'); /* diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9caf72c20e1..7f325090b5e 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -100,7 +100,7 @@ class Stripe extends CommonObject $sql .= " WHERE service = '".$this->db->escape($mode)."'"; $sql .= " AND entity = ".((int) $entity); if ($fk_soc > 0) { - $sql .= " AND fk_soc = ".$fk_soc; + $sql .= " AND fk_soc = ".((int) $fk_soc); } else { $sql .= " AND fk_soc IS NULL"; } diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 68d3a759bf5..75c24ef0561 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -52,6 +52,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$result = restrictedArea($user, 'banque'); /* diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index cde14647061..0d43c830e8e 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -53,6 +53,8 @@ $pageprev = $page - 1; $pagenext = $page + 1; $optioncss = GETPOST('optioncss', 'alpha'); +$result = restrictedArea($user, 'banque'); + /* * View diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1b10c92b0dc..92b43902405 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -118,6 +118,7 @@ $usercancreateorder = $user->rights->fournisseur->commande->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $usercancreate; /* @@ -485,7 +486,6 @@ if (empty($reshook)) { // Actions to build doc $upload_dir = $conf->supplier_proposal->dir_output; - $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -505,9 +505,9 @@ if (empty($reshook)) { $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } elseif ($action == "setabsolutediscount" && $usercancreate) { - if ($_POST["remise_id"]) { + if (GETPOST("remise_id", 'int')) { if ($object->id > 0) { - $result = $object->insert_discount($_POST["remise_id"]); + $result = $object->insert_discount(GETPOST("remise_id", 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 953f1d274fe..3e38ac10b41 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -98,6 +98,10 @@ class Supplierproposals extends DolibarrApi { global $db, $conf; + if (!DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + throw new RestException(401); + } + $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid @@ -124,14 +128,14 @@ class Supplierproposals extends DolibarrApi $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($socids) { - $sql .= " AND t.fk_soc IN (".$socids.")"; + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; } if ($search_sale > 0) { $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale } // Insert sale filter if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; + $sql .= " AND sc.fk_user = ".((int) $search_sale); } // Add sql filters if ($sqlfilters) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 78b1df5f6a4..0320a663ea8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1209,9 +1209,9 @@ class SupplierProposal extends CommonObject $sql .= " WHERE p.fk_statut = c.id"; $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; if ($ref) { - $sql .= " AND p.ref='".$ref."'"; + $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; } else { - $sql .= " AND p.rowid=".$rowid; + $sql .= " AND p.rowid = ".((int) $rowid); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1541,13 +1541,13 @@ class SupplierProposal extends CommonObject $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->supplier_proposal->creer)) { - $remise = price2num($remise); + $remise = price2num($remise, 2); - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal SET remise_percent = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { - $this->remise_percent = $remise; + $this->remise_percent = ((float) $remise); $this->update_price(1); return 1; } else { @@ -1569,13 +1569,15 @@ class SupplierProposal extends CommonObject public function set_remise_absolue($user, $remise) { // phpcs:enable - $remise = trim($remise) ?trim($remise) : 0; + if (empty($remise)) { + $remise = 0; + } + + $remise = price2num($remise); if (!empty($user->rights->supplier_proposal->creer)) { - $remise = price2num($remise); - $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal "; - $sql .= " SET remise_absolue = ".$remise; + $sql .= " SET remise_absolue = ".((float) $remise); $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql)) { @@ -1608,7 +1610,7 @@ class SupplierProposal extends CommonObject $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$this->statut.","; + $sql .= " SET fk_statut = ".((int) $this->statut).","; if (!empty($note)) { $sql .= " note_private = '".$this->db->escape($note)."',"; } @@ -1669,7 +1671,7 @@ class SupplierProposal extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; - $sql .= " SET fk_statut = ".$status.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql .= " WHERE rowid = ".$this->id; $resql = $this->db->query($sql); @@ -1775,7 +1777,7 @@ class SupplierProposal extends CommonObject $price = price2num($product->subprice * $product->qty, 'MU'); $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$this->db->escape($product->ref_fourn).'", ' : '').' price ='.((float) $price).', unitprice ='.((float) $unitPrice).' WHERE rowid = '.((int) $idProductFournPrice); $resql = $this->db->query($sql); if (!$resql) { @@ -2852,7 +2854,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; $sql .= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; - $sql .= ' WHERE pd.rowid = '.$rowid; + $sql .= ' WHERE pd.rowid = '.((int) $rowid); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 527ba87cb3e..3125f81bc01 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -58,7 +58,8 @@ if ($action == 'addcontact' && $permissiontoedit) { if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source")); } if ($result >= 0) { @@ -75,7 +76,7 @@ if ($action == 'addcontact' && $permissiontoedit) { } elseif ($action == 'swapstatut' && $permissiontoedit) { // Toggle the status of a contact if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 0982abe467d..9a7b6fcbb95 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -120,7 +120,7 @@ if ($resql) { } $db->free($resql); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; print '
    '; print ''; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 3ad210b2f77..71540aa2f11 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -329,10 +329,10 @@ if ($search_state) { $sql .= natural_search("state.nom", $search_state); } if ($search_country) { - $sql .= " AND s.fk_pays IN (".$search_country.')'; + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; } if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; } if ($search_ref) { $sql .= natural_search('sp.ref', $search_ref); @@ -560,24 +560,24 @@ if ($resql) { if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; - $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250'); $moreforfilter .= '
    '; } // If the user can view products if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; + $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter .= '
    '; } $parameters = array(); @@ -954,7 +954,7 @@ if ($resql) { // Amount HT if (!empty($arrayfields['sp.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -965,7 +965,7 @@ if ($resql) { } // Amount VAT if (!empty($arrayfields['sp.total_tva']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -976,7 +976,7 @@ if ($resql) { } // Amount TTC if (!empty($arrayfields['sp.total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1005,21 +1005,21 @@ if ($resql) { } // Amount HT if (!empty($arrayfields['sp.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount VAT if (!empty($arrayfields['sp.multicurrency_total_vat']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount TTC if (!empty($arrayfields['sp.multicurrency_total_ttc']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 7d0ce8897e3..f933472a443 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -63,9 +63,6 @@ if ($resql) { if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) { - $_POST["socid"] = ''; - } $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 67bc8edcdf3..0364ff4e64f 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -70,9 +70,6 @@ $error = 0; if ($action == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) { - $_POST["socid"] = ''; - } $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 3e5bb4ccc46..52f451ae163 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -67,9 +67,6 @@ $terminaltouse = $terminal; if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) { - $_POST["socid"] = ''; - } $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity); diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index c9cdb681267..0ccdeb86b9b 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -111,7 +111,7 @@ if ($action == 'getProducts') { $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { - $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.'))'; + $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))'; } $sql .= ' AND tosell = 1'; $sql .= natural_search(array('ref', 'label', 'barcode'), $term); diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 589c10ddf62..12dd2836ea2 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -67,7 +67,7 @@ if (empty($dolibarr_nocache)) { } -require DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; +include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; if (defined('THEME_ONLY_CONSTANT')) { return; } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 7fd162c5fbd..d73f6499c93 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1063,7 +1063,7 @@ $( document ).ready(function() { if ($placeid == $obj->rowid) { echo ""; } - echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); + echo ''.dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); if ($placeid == $obj->rowid) { echo ""; } @@ -1071,7 +1071,7 @@ $( document ).ready(function() { } echo '$("#customerandsales").append(\'\');'; + echo '\\\'; invoiceid=0; Refresh();">
    \');'; } else { dol_print_error($db); } @@ -1419,7 +1419,7 @@ if ($placeid > 0) { $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql .= " WHERE ps.reel != 0"; - $sql .= " AND ps.fk_entrepot = ".$conf->global->$constantforkey; + $sql .= " AND ps.fk_entrepot = ".((int) $conf->global->$constantforkey); $sql .= " AND e.entity IN (".getEntity('stock').")"; $sql .= " AND ps.fk_product = ".$line->fk_product; $resql = $db->query($sql); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index dd895eb4265..e9d721a44e3 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -260,7 +260,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) { $sql .= " cp.code"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; - $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$facid; + $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $facid); $sql .= " ORDER BY p.datep"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index f3f311eccca..dcb61499b63 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -205,7 +205,7 @@ a.badge-dark:focus, a.badge-dark:hover { /* STATUS BADGES */ : 0px !important; } .butActionRefused, .butAction, .butAction:link, .butAction:visited, .butAction:hover, .butAction:active, .butActionDelete, .butActionDelete:link, .butActionDelete:visited, .butActionDelete:hover, .butActionDelete:active { text-decoration: none; text-transform: uppercase; font-weight: bold; - margin: 0em em; + margin: 0em em; padding: 0.6em em; display: inline-block; text-align: center; diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 871ee5aa68c..e0976e0e1db 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -277,14 +277,14 @@ a.top-menu-dropdown-link { text-decoration: none; } -#topmenuloginmoreinfo-btn{ +#topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; text-aling: right; color:#666; cursor: pointer; } -#topmenuloginmoreinfo{ +#topmenuloginmoreinfo, #topmenulogincompanyinfo { display: none; clear: both; font-size: 0.95em; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 6549a4d38cb..4cf7bc0de34 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -21,6 +21,7 @@ --colorbacklinepairchecked: rgb(); --colorbacklinebreak: rgb(); --colorbackbody: rgb(); + --colorbackmobilemenu: #f8f8f8; --colortexttitlenotab: rgb(); --colortexttitlenotab2: rgb(); --colortexttitle: rgba(, 0.9); @@ -45,6 +46,8 @@ --amountremaintopaycolor:#880000; --amountpaymentcomplete:#008800; --amountremaintopaybackcolor:none; + --productlinestockod: #002200; + --productlinestocktoolow: #884400; } global->THEME_DARKMODEENABLED)) { --colorbackhmenu1: #1d1e20; --colorbackvmenu1: #2b2c2e; --colorbacktitle1: #2b2d2f; - --colorbacktabcard1: #38393d; + --colorbacktabcard1: #1d1e20; /* Must be same than colorbackbody */ --colorbacktabactive: rgb(220,220,220); --colorbacklineimpair1: #38393d; --colorbacklineimpair2: #2b2d2f; @@ -66,6 +69,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --colorbacklinepairhover: #2b2d2f; --colorbacklinepairchecked: #0e5ccd; --colorbackbody: #1d1e20; + --colorbackmobilemenu: #080808; --tooltipbgcolor: #2b2d2f; --colortexttitlenotab: rgb(220,220,220); --colortexttitlenotab2: rgb(220,220,220); @@ -89,7 +93,11 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --amountremaintopaycolor:rgb(252,84,91); --amountpaymentcomplete:rgb(101,184,77); --amountremaintopaybackcolor:rbg(245,130,46); - }\n"; + } + + body, button { + color: #bbb; + }\n"; if ($conf->global->THEME_DARKMODEENABLED != 2) { print "}\n"; } @@ -210,7 +218,10 @@ input, select { #mainbody input.buttongen, #mainbody button.buttongen { padding: 3px 4px; } - +input.button:hover { + -webkit-box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); + box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); +} input.button:focus { border-bottom: 0; } @@ -364,6 +375,9 @@ td.rightborder { border-right: 1px solid #ccc; } +td.amount, span.amount, div.amount { + color: #006666; +} td.actionbuttons a { padding-left: 6px; } @@ -574,7 +588,9 @@ button[name='button_removefilter_x'] span.fa.fa-remove { button:focus { outline: none; } - +.fa-info-circle { + padding-: 3px; +} th .button { -webkit-box-shadow: none !important; @@ -711,6 +727,9 @@ textarea.centpercent { .paddingright2 { padding-: 2px; } +.paddingright2imp { + padding-: 2px !important; +} .paddingtop { padding-top: 4px; } @@ -762,6 +781,19 @@ textarea.centpercent { max-width: 100%; overflow-y: auto; } +div.urllink { + padding: 5px; + margin-top: 5px; + margin-bottom: 5px; + /* border: 1px solid #ccc; */ + border-radius: 5px; + /* width: fit-content; */ + background-color: #f0f0f8; + opacity: 0.8; +} +div.urllink, div.urllink a { + color: #339 !important; +} i.fa-mars::before, i.fa-venus::before, i.fa-genderless::before { color: #888 !important; @@ -829,7 +861,7 @@ span.fa.fa-plus-circle.paddingleft { /* Themes for badges */ - + .borderrightlight { @@ -953,6 +985,19 @@ div.div-for-modal { z-index: 100; } +div.div-for-modal-topright { + /* display: none; */ + position: fixed; + top: 0; + right: 0; + width:50%; /* adjust as per your needs */ + height:250px; /* adjust as per your needs */ + background: #fff; + border: 1px solid #bbb; + box-shadow: 2px 2px 20px #ddd; + z-index: 1100; +} + browser->layout == 'phone') { @@ -1086,6 +1131,18 @@ select.flat.selectlimit { text-overflow: ellipsis; white-space: nowrap; } +.tdoverflowmax400 { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 400px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.tdoverflowmax500 { /* For tdoverflow, the max-midth become a minimum ! */ + max-width: 500px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} .tdoverflowauto { max-width: 0; overflow: auto; @@ -1794,7 +1851,7 @@ div.vmenu, td.vmenu { div.fiche { - margin-: dol_optimize_smallscreen) ? '32' : '6')); ?>px; + margin-: dol_optimize_smallscreen) ? '34' : '6')); ?>px; margin-: dol_optimize_smallscreen) ? '30' : '6')); ?>px; global->THEME_DARKMODEENABLED)) { ?> + color: #000; + } div.pagination li.pagination span.inactive { cursor: default; @@ -4238,8 +4296,8 @@ div.boximport { min-height: unset; } -.product_line_stock_ok { color: #002200; } -.product_line_stock_too_low { color: #884400; } +.product_line_stock_ok { color: var(--productlinestockok); } +.product_line_stock_too_low { color: var(--productlinestocktoolow); } .fieldrequired { font-weight: bold; color: var(--fieldrequiredcolor) !important; } @@ -4751,7 +4809,7 @@ table.cal_month td { padding-left: 1px !important; padding-right: 1px !important div.event { margin-left: 8px; margin-right: 8px; margin-bottom: 8px; margin-top: 4px; border-radius: 4px; box-shadow: 2px 2px 5px rgba(100, 100, 100, 0.2); } table.cal_event { border: none; border-collapse: collapse; margin-bottom: 1px; min-height: 20px; filter: saturate(0.8); border-radius: 3px; } table.cal_event td { border: none; padding-: 2px; padding-: 2px; padding-top: 0px; padding-bottom: 0px; } -table.cal_event td.cal_event { padding: 4px 4px !important; } +table.cal_event td.cal_event { padding: 4px 4px !important; padding-bottom: 2px !important; padding-top: 2px !important; } table.cal_event td.cal_event_right { padding: 4px 4px !important; } .cal_event { font-size: 1em; } .cal_event a:link { color: #111111; font-weight: normal !important; } @@ -6040,7 +6098,7 @@ li.ui-li-divider .ui-link { color: #FFF !important; } .ui-btn { - margin: 0.1em 2px + margin: 0 2px; } a.ui-link, a.ui-link:hover, .ui-btn:hover, span.ui-btn-text:hover, span.ui-btn-inner:hover { text-decoration: none !important; @@ -6194,7 +6252,7 @@ ul.ulmenu { } .alilevel0 { color: var(--colortexttitle) !important; - background: #f8f8f8 + background: var(--colorbackmobilemenu); } .ulmenu { box-shadow: none !important; @@ -6258,12 +6316,6 @@ div.tabsElem a.tab { /* POS */ /* ============================================================================== */ -.menu_choix1 a { - background: url('') top left no-repeat; -} -.menu_choix2 a { - background: url('') top left no-repeat; -} .menu_choix1,.menu_choix2 { font-size: 1.4em; text-align: left; @@ -6275,7 +6327,7 @@ div.tabsElem a.tab { color: #fff; text-decoration: none; padding-top: 18px; - padding-left: 54px; + padding-left: 10px; font-size: 14px; height: 38px; } diff --git a/htdocs/theme/eldy/img/object_zapier.png b/htdocs/theme/eldy/img/object_zapier.png index b1337750b67..b244cb1d5d6 100644 Binary files a/htdocs/theme/eldy/img/object_zapier.png and b/htdocs/theme/eldy/img/object_zapier.png differ diff --git a/htdocs/theme/eldy/main_menu_fa_icons.inc.php b/htdocs/theme/eldy/main_menu_fa_icons.inc.php index 339235ce2c7..9b119fa593c 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.inc.php +++ b/htdocs/theme/eldy/main_menu_fa_icons.inc.php @@ -169,7 +169,7 @@ div.mainmenu.generic4::before { .fa-play { color: #444; } -.fa-unlink { +.fa-link, .fa-unlink { color: #555; } diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 8bb2fd3bbca..82cbf9cf2a9 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -114,6 +114,7 @@ $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#25a580'; $badgeStatus8 = '#993013'; $badgeStatus9 = '#e7f0f0'; +$badgeStatus10 = '#993013'; // status color ajustement for color blind $colorblind_deuteranopes_badgeStatus4 = $colorblind_deuteranopes_badgeStatus7 = $colorblind_deuteranopes_badgeSuccess; //! text color black diff --git a/htdocs/theme/md/badges.inc.php b/htdocs/theme/md/badges.inc.php index 7dd0229ae46..fd1b1122a17 100644 --- a/htdocs/theme/md/badges.inc.php +++ b/htdocs/theme/md/badges.inc.php @@ -1,7 +1,8 @@ +} +?> /*
    '.price($obj->total_ht)."'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($obj->total_ttc)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.price($obj->multicurrency_total_ttc)."