diff --git a/ChangeLog b/ChangeLog index 31bfa1c1cff..555258f3901 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,15 +25,18 @@ For developers: NEW: A lot of addition of hooks. - + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The default value for MAIN_SECURITY_CSRF_WITH_TOKEN has been set to 2. It means any POST and any GET request that contains the "action" or "massaction" with a value of a sensitive action must also a valid token parameter (With previous value 1, only POST was concerned). Note: With value 3, any URL with parameter "action" or "massaction" need the token, whatever is the value of the action. * verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true. * The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead. -* All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose. -* Rename build_path_from_id_categ() into buildPathFromId() and set method to private +* All triggers with a name XXX_UPDATE have been renamed with name XXX_MODIFY for code consistency purpose. +* Rename build_path_from_id_categ() into buildPathFromId() and set method to private. +* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php +* Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code). +* Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions. ***** ChangeLog for 15.0.1 compared to 15.0.0 ***** diff --git a/README.md b/README.md index 4e120a4cb91..43682368ba0 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Customers/Prospects + Contacts management - Opportunities or Leads management -- Commercial proposals management +- Commercial proposals management (online signing) - Customer Orders management - Contracts/Subscription management - Interventions management @@ -129,11 +129,11 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Supplier Invoices/credit notes and payment management - INCOTERMS - Finance / Accounting + Finance/Accounting -- Invoices / Payments +- Invoices/Payments - Bank accounts management -- Direct debit orders management (European SEPA) +- Direct debit and Credit transfer management (European SEPA) - Accounting management - Donations management - Loan management @@ -142,14 +142,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Collaboration -- Shared calendar/agenda (with ical and vcal export for third party tools integration) +- Shared calendar/agenda (with ical and vcal import/export for third party tools integration) - Projects & Tasks management - Ticket System - Surveys HR -- Employee's leave requests management +- Employee's leaves management - Expense reports - Recruitment management - Timesheets @@ -157,16 +157,14 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other application/modules - Electronic Document Management (EDM) -- Bookmarks management +- Bookmarks - Reporting - Data export/import - Barcodes -- Margin calculations - LDAP connectivity - ClickToDial integration - Mass emailing - RSS integration -- Skype integration - Social platforms linking - Payment platforms integration (PayPal, Stripe, Paybox...) - Email-Collector @@ -175,13 +173,12 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other general features -- Localization in most major languages -- Multi-Language Support +- Multi-Language Support (Localization in most major languages) - Multi-Users and groups with finely grained rights - Multi-Currency - Multi-Company (by adding of an external module) - Very user friendly and easy to use -- customizable Dashboard +- Customizable dashboards - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) - APIs (REST, SOAP) - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) @@ -191,8 +188,9 @@ 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... + - ZATCA e-invoicing QR-Code - Compatible with [European directives](https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - - Compatible with European GDPR rules + - Compatible with data privacy rules (europe GDPR, ...) - ... - Flexible PDF & ODT generation for invoices, proposals, orders... - ... @@ -244,6 +242,7 @@ Follow Dolibarr project on: - [Facebook](https://www.facebook.com/dolibarr) - [Twitter](https://www.twitter.com/dolibarr) - [LinkedIn](https://www.linkedin.com/company/association-dolibarr) +- [Reddit](https://www.reddit.com/r/Dolibarr/) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [GitHub](https://github.com/Dolibarr/dolibarr) diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 477d129d459..d4e37e32629 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -8,12 +8,13 @@ This files describe steps made by Dolibarr packaging team to make a beta version of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. -To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +- Update version/info in ChangeLog, for this you can: +To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +To generate a changelog of a major new version x.y.0 (from a repo on branch x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -- To know number of lines changes: git diff --shortstat A B -- Update version number with x.y.z-w in htdocs/filefunc.inc.php +Recopy the content of the output file into the file ChangeLog. +- Note: To know number of lines changes: git diff --shortstat A B +- Update version number with x.y.z-w in file htdocs/filefunc.inc.php - Commit all changes. - Run makepack-dolibarr.pl to generate all packages. @@ -24,7 +25,6 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol (/home/dolibarr/wwwroot/files/lastbuild). - Post a news on dolibarr.org/dolibarr.fr + social networks -- Send mail on mailings-list ***** Actions to do a RELEASE ***** @@ -32,12 +32,13 @@ This files describe steps made by Dolibarr packaging team to make a complete release of Dolibarr, step by step. - Check all files are commited. -- Update version/info in ChangeLog. -To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +- Update version/info in ChangeLog, for this you can: +To generate a changelog of a major new version x.y.0 (from a repo on branch develop), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" +To generate a changelog of a major new version x.y.0 (from a repo pn branch x.y), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" -- To know number of lines changes: git diff --shortstat A B -- Update version number with x.y.z in htdocs/filefunc.inc.php +Recopy the content of the output file into the file ChangeLog. +- Note: To know the number of lines changes: git diff --shortstat A B +- Update version number with x.y.z in file htdocs/filefunc.inc.php - Commit all changes. - Run makepack-dolibarr.pl to generate all packages. @@ -52,4 +53,3 @@ To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dol on server to point to new files (used by some web sites). - Post a news on dolibarr.org/dolibarr.fr + social networks -- Send mail on mailings-list diff --git a/dev/resources/iso-normes/accountancy_rules.txt b/dev/resources/iso-normes/accountancy/accountancy_rules.txt similarity index 61% rename from dev/resources/iso-normes/accountancy_rules.txt rename to dev/resources/iso-normes/accountancy/accountancy_rules.txt index 15e07ffbea1..a265bcf4f54 100644 --- a/dev/resources/iso-normes/accountancy_rules.txt +++ b/dev/resources/iso-normes/accountancy/accountancy_rules.txt @@ -2,13 +2,13 @@ Gestion escompte: Sur une facture de 120 € TTC : -707xxx 100 € HT -44571x 20 € TVA -411xxx 120 € TTC - +707xxx 100 € HT +44571x 20 € TVA +411xxx 120 € TTC + Le client règle rapidement et on lui accorde un escompte de 3% (120 € * 3% = 3.6 € TTC), on aura donc : -665000 3,00 € HT -44571x 0,60 € TVA -411xxx 3.60 € TVA - +665000 3,00 € HT +44571x 0,60 € TVA +411xxx 3,60 € TTC + Et ça marche à l’inverse avec un fournisseur sauf que l’on est en 775000 au lieu de 665000 pour escompte obtenus. diff --git a/dev/resources/iso-normes/banknumber_format.txt b/dev/resources/iso-normes/banking/banknumber_format.txt similarity index 100% rename from dev/resources/iso-normes/banknumber_format.txt rename to dev/resources/iso-normes/banking/banknumber_format.txt diff --git a/dev/resources/iso-normes/iban_iso-13616.txt b/dev/resources/iso-normes/banking/iban_iso-13616_fr.txt similarity index 100% rename from dev/resources/iso-normes/iban_iso-13616.txt rename to dev/resources/iso-normes/banking/iban_iso-13616_fr.txt diff --git a/dev/resources/iso-normes/QR code for invoices.txt b/dev/resources/iso-normes/barcodes/QR code for invoices.txt similarity index 88% rename from dev/resources/iso-normes/QR code for invoices.txt rename to dev/resources/iso-normes/barcodes/QR code for invoices.txt index f03351f453f..639435238f9 100644 --- a/dev/resources/iso-normes/QR code for invoices.txt +++ b/dev/resources/iso-normes/barcodes/QR code for invoices.txt @@ -1,3 +1,8 @@ +QR-Code = Quick Response Code - is a two-dimensional / 2D- / Matrix-Barcode + +ISO/IEC 18004 + + List of QR Code format we found on some invoices ------------------------------------------------ diff --git a/dev/resources/iso-normes/barcode_EAN13.txt b/dev/resources/iso-normes/barcodes/barcode_EAN13.txt similarity index 60% rename from dev/resources/iso-normes/barcode_EAN13.txt rename to dev/resources/iso-normes/barcodes/barcode_EAN13.txt index f6b3c5f5ebb..e8000035788 100644 --- a/dev/resources/iso-normes/barcode_EAN13.txt +++ b/dev/resources/iso-normes/barcodes/barcode_EAN13.txt @@ -31,60 +31,60 @@ Here is the list of country codes or system: List ==== -00 - 13 UCC (U.S.A / États-Unis & Canada) +00 - 13 UCC (U.S.A / États-Unis & Canada) 20 - 29 Flag for internal numbering / Codification interne en magasin 30 - 37 GENCOD-EAN France 380 BCCI (Bulgaria) 383 SANA (Slovenia) 385 CRO-EAN (Croatia) 387 EAN-BIH (Bosnia-Herzegovina) -400-440 CCG (Allemagne/Germany) +400-440 CCG (DE/Germany/Allemagne) 45 + 49 Distribution Code Center - DCC (Japan) 460-469 UNISCAN - EAN Russia (Federation de Russie) 471 CAN Taiwan -474 EAN Estonia -475 EAN Latvia -476 EAN Azerbaijan -477 EAN Lithuania -478 EAN Uzbekistan -479 EAN Sri Lanka +474 EAN Estonia +475 EAN Latvia +476 EAN Azerbaijan +477 EAN Lithuania +478 EAN Uzbekistan +479 EAN Sri Lanka 480 PANC Philippines -481 EAN Belarus -482 EAN Ukraine -484 EAN Moldova -485 EAN Armenia -486 EAN Georgia -487 EAN Kazakhstan +481 EAN Belarus +482 EAN Ukraine +484 EAN Moldova +485 EAN Armenia +486 EAN Georgia +487 EAN Kazakhstan 489 HKANA Hong Kong 50 E Centre UK - United Kingdom -520 HELLCAN-EAN HELLAS (Grece) -528 EAN Liban -529 EAN Chypre -531 EAN-MAC (FYR Macedonie) -535 EAN Malte -539 EAN Irlande -54 ICODIF/EAN Belgique. Luxembourg -560 CODIPOR (Portugal) -569 EAN Islande -57 EAN Danemark -590 EAN Pologne -594 EAN Roumanie -599 H.A.P.M.H. (Hongrie) -600 - 601 EAN Afrique du Sud -609 EAN Ile Maurice -611 EAN Maroc -613 EAN Algerie -619 Tunicode (Tunisie) -621 EAN Syrie -622 EAN Egypte -625 EAN Jordanie -626 EAN Iran -628 EAN Arabie Saoudite -64 EAN Finlande -690 - 693 Article Numbering Centre of China - ANCC (Chine) -70 EAN Norge (Norvege) -729 Israeli Bar Code Association � EAN Israel -73 EAN Suede +520 HELLCAN-EAN HELLAS - Greece +528 EAN Lebanon +529 EAN Cyprus +531 EAN-MAC (FYR Macedonia) +535 EAN Malta +539 EAN Ireland +54 ICODIF/EAN Belgium & Luxembourg +560 CODIPOR (Portugal) +569 EAN Iceland/Islande +57 EAN Denmark +590 EAN Poland +594 EAN Romania +599 H.A.P.M.H. (Hungary) +600-601 EAN South Africa +609 EAN Mauritius Island +611 EAN Morocco +613 EAN Algeria +619 Tunicode (Tunisia) +621 EAN Syria +622 EAN Egypt +625 EAN Jordan/Jordanie +626 EAN Iran +628 EAN Saudi Arabia +64 EAN Finland +690-693 ANCC - Article Numbering Centre of China +70 EAN Norge (Norvege) +729 Israeli Bar Code Association - EAN Israel +73 EAN Suede 740 EAN Guatemala 741 EAN El Salvador 742 ICCC (Honduras) @@ -93,7 +93,7 @@ List 746 746 EAN Republique Dominicaine 750 AMECE (Mexique) 759 EAN Venezuela -76 EAN (Schweiz, Suisse, Svizzera) +76 EAN (Schweiz, Suisse, Svizzera) 770 IAC (Colombie) 773 EAN Uruguay 775 APC - EAN Peru (Perou) @@ -103,15 +103,15 @@ List 784 EAN Paraguay 786 ECOP (Equateur) 789 EAN Bresil -80 � 83 INDICOD (Italie) -84 AECOC (Espagne) +80 - 83 INDICOD (Italy) +84 AECOC (Espagne) 850 Camera de Comercio de la Republica de Cuba (Cuba) 858 EAN Slovaquie 859 EAN Republique Tcheque 860 EAN YU (Yougoslavie) 867 EAN DPR Korea (Coree du Nord) 869 Union of Chambers of Commerce of Turkey (Turquie) -87 EAN Nederland (Hollande) +87 EAN Nederland (Hollande) 880 EAN Korea (Coree du Sud) 885 EAN Thailande 888 SANC (Singapour) @@ -119,11 +119,11 @@ List 893 EAN Vietnam 899 EAN Indonesie 90 - 91 EAN Autriche -93 EAN Australie -94 EAN Nouvelle Zelande +93 EAN Australie +94 EAN Nouvelle Zelande 955 Malaysian Article Numbering Council (MANC) - Malaisie 977 Publications sirielles (ISSN) 978 - 979 Livres (ISBN) 980 Refus de remboursement 981 - 982 Coupons (monnaie courante) -99 Coupons +99 Coupons diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 847891c949b..8a8ca0ecf46 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Ari Elbaz (elarifr) + * 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 @@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("companies", "compta", "accountancy", "products")); @@ -59,6 +62,8 @@ $account_number_sell = GETPOST('account_number_sell'); $changeaccount = GETPOST('changeaccount', 'array'); $changeaccount_buy = GETPOST('changeaccount_buy', 'array'); $changeaccount_sell = GETPOST('changeaccount_sell', 'array'); +$searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0); +$searchCategoryProductList = GETPOST('search_category_product_list', 'array'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_desc = GETPOST('search_desc', 'alpha'); @@ -144,6 +149,8 @@ if ($reshook < 0) { // Purge search criteria 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 + $searchCategoryProductOperator = 0; + $searchCategoryProductList = array(); $search_ref = ''; $search_label = ''; $search_desc = ''; @@ -283,7 +290,16 @@ $aacompta_prodsell = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUN $aacompta_prodsell_intra = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans("CodeNotDef")); $aacompta_prodsell_export = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans("CodeNotDef")); -llxHeader('', $langs->trans("ProductsBinding")); + +$title = $langs->trans("ProductsBinding"); +$helpurl = ''; + +$paramsCat = ''; +foreach ($searchCategoryProductList as $searchCategoryProduct) { + $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); +} + +llxHeader('', $title, $helpurl, '', 0, 0, array(), array(), $paramsCat, ''); $pcgverid = getDolGlobalString('CHARTOFACCOUNTS'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); @@ -308,6 +324,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { } else { $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) . "'"; } +if (!empty($searchCategoryProductList)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +} $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account); @@ -318,6 +337,30 @@ if ($search_current_account_valid == 'withoutvalidaccount') { if ($search_current_account_valid == 'withvalidaccount') { $sql .= " AND aa.account_number IS NOT NULL"; } +$searchCategoryProductSqlList = array(); +if ($searchCategoryProductOperator == 1) { + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; + } elseif (intval($searchCategoryProduct) > 0) { + $searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct); + } + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } +} else { + foreach ($searchCategoryProductList as $searchCategoryProduct) { + 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 = ".((int) $searchCategoryProduct).")"; + } + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; + } +} // Add search filter like if (strlen(trim($search_ref))) { $sql .= natural_search("p.ref", $search_ref); @@ -338,6 +381,15 @@ if ($search_onpurchase != '' && $search_onpurchase != '-1') { $sql .= natural_search('p.tobuy', $search_onpurchase, 1); } +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; +$sql .= " p.fk_product_type,"; +$sql .= ' p.tms,'; +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 .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export"; +} + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -365,11 +417,17 @@ if ($result) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } + if ($searchCategoryProductOperator == 1) { + $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); + } + foreach ($searchCategoryProductList as $searchCategoryProduct) { + $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); + } if ($search_ref > 0) { - $param .= "&search_desc=".urlencode($search_ref); + $param .= "&search_ref=".urlencode($search_ref); } if ($search_label > 0) { - $param .= "&search_desc=".urlencode($search_label); + $param .= "&search_label=".urlencode($search_label); } if ($search_desc > 0) { $param .= "&search_desc=".urlencode($search_desc); @@ -461,6 +519,40 @@ if ($result) { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($chk_prod)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); } + // Filter on categories + $moreforfilter = ''; + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $moreforfilter .= '
'; + $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'); + $moreforfilter .= ' '.$langs->trans('UseOrOperatorForCategories').''; + $moreforfilter .= '
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { + $moreforfilter .= '
'; + $moreforfilter .= ''; + $moreforfilter .= ' '; + $moreforfilter .= '
'; + } + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } + + if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; + } + print '
'; print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 5b645796a32..511b12de3c2 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -267,7 +267,7 @@ if ($action == "confirm_update") { if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } - $action = 'update'; + $action = ''; $id = $object->id; $piece_num = $object->piece_num; } @@ -647,6 +647,12 @@ if ($action == 'create') { print "\n"; + // Empty line is the first line of $object->linesmvt + // So we must get the first line (the empty one) and put it at the end of the array + // in order to display it correctly to the user + $empty_line = array_shift($object->linesmvt); + $object->linesmvt[]= $empty_line; + foreach ($object->linesmvt as $line) { print ''; $total_debit += $line->debit; @@ -677,7 +683,33 @@ if ($action == 'create') { print ''."\n"; print ''; print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { + if ($action == "" || $action == 'add') { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } else { + print ''; $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - print '
'; + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print ''; + } + print '
'; + print '
'; + print ''; + print ''; if ($resultfetch > 0) { @@ -733,35 +765,6 @@ if ($action == 'create') { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } - if (empty($object->date_export) && empty($object->date_validation)) { - if ($action == "" || $action == 'add') { - print '
'; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); - } else { - print ''; - } - print '
'; - print '
'; - print ''; - print '
'; print '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a760a550bef..bc7ea7c7072 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -42,6 +43,10 @@ $langs->loadLangs(array("accountancy", "compta")); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); @@ -86,6 +91,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', ' $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); +$search_import_key = GETPOST("search_import_key", 'alpha'); //var_dump($search_date_start);exit; if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { @@ -191,6 +197,7 @@ $arrayfields = array( 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1), + 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -220,10 +227,12 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ +$param = ''; + if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') { $massaction = ''; } @@ -294,10 +303,11 @@ if (empty($reshook)) { $search_credit = ''; $search_lettering_code = ''; $search_not_reconciled = ''; + $search_import_key = ''; + $toselect = ''; } // Must be after the remove filter action, before the export. - $param = ''; $filter = array(); if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; @@ -416,77 +426,143 @@ if (empty($reshook)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } -} + if (!empty($search_import_key)) { + $filter['t.import_key'] = $search_import_key; + $param .= '&search_import_key='.urlencode($search_import_key); + } -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); - - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + // $delmonth = GETPOST('delmonth', 'int'); + // $delyear = GETPOST('delyear', 'int'); + // if ($delyear == -1) { + // $delyear = 0; + // } + // $deljournal = GETPOST('deljournal', 'alpha'); + // if ($deljournal == -1) { + // $deljournal = 0; + // } + // + // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { + // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + // if ($result < 0) { + // setEventMessages($object->error, $object->errors, 'errors'); + // } else { + // setEventMessages("RecordDeleted", null, 'mesgs'); + // } + // + // // Make a redirect to avoid to launch the delete later after a back button + // header("Location: list.php".($param ? '?'.$param : '')); + // exit; + // } else { + // setEventMessages("NoRecordDeleted", null, 'warnings'); + // } + //} + if ($action == 'setreexport') { + $setreexport = GETPOST('value', 'int'); + if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) { + $error++; } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + if (!$error) { + if ($conf->global->ACCOUNTING_REEXPORT == 1) { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + } } else { - setEventMessages("RecordDeleted", null, 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'errors'); } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } - - header("Location: list.php?noreset=1".($param ? '&'.$param : '')); - exit; - } -} -if ($action == 'setreexport') { - $setreexport = GETPOST('value', 'int'); - if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) { - $error++; } - if (!$error) { - if ($conf->global->ACCOUNTING_REEXPORT == 1) { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + // Mass actions + $objectclass = 'Bookkeeping'; + $objectlabel = 'Bookkeeping'; + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { + $result = $object->deleteMvtNum($object->piece_num); + if ($result > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } elseif ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + + // Message for elements well deleted + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } elseif (!$error) { + setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); + } + + if (!$error) { + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); + exit; + } + } + + // others mass actions + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if ($massaction == 'lettering') { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } elseif ($action == 'unlettering' && $confirm == "yes") { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } } - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -520,7 +596,8 @@ $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export,"; -$sql .= " t.date_validated as date_validation"; +$sql .= " t.date_validated as date_validation,"; +$sql .= " t.import_key"; $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -667,6 +744,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $db->num_rows($resql); } +$arrayofselected = is_array($toselect) ? $toselect : array(); // Output page // -------------------------------------------------------------------- @@ -684,7 +762,7 @@ if ($action == 'export_file') { 'name' => 'notifiedexportdate', 'type' => 'checkbox', 'label' => $langs->trans('NotifiedExportDate'), - 'value' => $checked, + 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'), ); $form_question['separator'] = array('name'=>'separator', 'type'=>'separator'); @@ -703,50 +781,46 @@ if ($action == 'export_file') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600); } -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.urlencode(GETPOST('mvt_num')).$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); -} - -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'morecss' => 'minwidth150', - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320); -} +//if ($action == 'delbookkeepingyear') { +// $form_question = array(); +// $delyear = GETPOST('delyear', 'int'); +// $deljournal = GETPOST('deljournal', 'alpha'); +// +// if (empty($delyear)) { +// $delyear = dol_print_date(dol_now(), '%Y'); +// } +// $month_array = array(); +// for ($i = 1; $i <= 12; $i++) { +// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); +// } +// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); +// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); +// +// $form_question['delmonth'] = array( +// 'name' => 'delmonth', +// 'type' => 'select', +// 'label' => $langs->trans('DelMonth'), +// 'values' => $month_array, +// 'morecss' => 'minwidth150', +// 'default' => '' +// ); +// $form_question['delyear'] = array( +// 'name' => 'delyear', +// 'type' => 'select', +// 'label' => $langs->trans('DelYear'), +// 'values' => $year_array, +// 'default' => $delyear +// ); +// $form_question['deljournal'] = array( +// 'name' => 'deljournal', +// 'type' => 'other', // We don't use select here, the journal_array is already a select html component +// 'label' => $langs->trans('DelJournal'), +// 'value' => $journal_array, +// 'default' => $deljournal +// ); +// +// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320); +//} // Print form confirm print $formconfirm; @@ -759,6 +833,22 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } +// List of mass actions available +$arrayofmassactions = array(); +/* +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering'); + $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering'); +} +*/ +if ($user->rights->accounting->mouvements->supprimer) { + $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); + print '
'; print ''; print ''; @@ -768,8 +858,7 @@ if ($optioncss != '') { print ''; print ''; print ''; - -$massactionbutton = ''; +print ''; if (count($filter)) { $buttonLabel = $langs->trans("ExportFilteredList"); @@ -794,7 +883,7 @@ if (empty($reshook)) { $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param, '', 1, array('morecss' => 'marginleftonly')); $url = './card.php?action=create'; if (!empty($socid)) { @@ -805,9 +894,21 @@ if (empty($reshook)) { print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); +if ($massaction == 'preunlettering') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1); +} elseif ($massaction == 'predeletebookkeepingwriting') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); +} + +//$topicmail = "Information"; +//$modelmail = "accountingbookkeeping"; +//$objecttmp = new BookKeeping($db); +//$trackid = 'bk'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -954,6 +1055,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['t.import_key']['checked'])) { + print ''; + print ''; + print ''; +} // Action column print ''; $searchpicto = $form->showFilterButtons(); @@ -1008,6 +1114,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) { if (!empty($arrayfields['t.date_validated']['checked'])) { print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.import_key']['checked'])) { + print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -1252,17 +1361,21 @@ while ($i < min($num, $limit)) { } } - // Action column - print ''; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; + if (!empty($arrayfields['t.import_key']['checked'])) { + print ''.$obj->import_key."\n"; + if (!$i) { + $totalarray['nbfield']++; } } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + + // Action column + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // 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($line->id, $arrayofselected)) { + $selected = 1; } + print ''; } print ''; @@ -1283,11 +1396,11 @@ print ""; print ''; // TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} +//if ($user->rights->accounting->mouvements->supprimer_tous) { +// print '
'."\n"; +// print ''.$langs->trans("DeleteMvt").''; +// print '
'; +//} print '
'; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 837a372a32d..cb8a2ee0517 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; @@ -39,6 +40,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$type = GETPOST('type', 'alpha'); +if ($type == 'sub') { + $context_default = 'bookkeepingbysubaccountlist'; +} else { + $context_default = 'bookkeepingbyaccountlist'; +} +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; $search_date_startyear = GETPOST('search_date_startyear', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startday = GETPOST('search_date_startday', 'int'); @@ -64,6 +75,7 @@ $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', ' $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); +$search_import_key = GETPOST("search_import_key", 'alpha'); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -109,7 +121,7 @@ if ($sortfield == "") { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new BookKeeping($db); $formfile = new FormFile($db); -$hookmanager->initHooks(array('bookkeepingbyaccountlist')); +$hookmanager->initHooks(array($context_default)); $formaccounting = new FormAccounting($db); $form = new Form($db); @@ -153,6 +165,7 @@ $arrayfields = array( 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), + 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -187,10 +200,13 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Action */ +$param = ''; + if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') { $massaction = ''; } @@ -242,10 +258,11 @@ if (empty($reshook)) { $search_credit = ''; $search_lettering_code = ''; $search_not_reconciled = ''; + $search_import_key = ''; + $toselect = ''; } // Must be after the remove filter action, before the export. - $param = ''; $filter = array(); if (!empty($search_date_start)) { @@ -261,12 +278,20 @@ if (empty($reshook)) { $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + if ($type == 'sub') { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + } else { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + } + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + if ($type == 'sub') { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + } else { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + } + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); } if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; @@ -326,61 +351,133 @@ if (empty($reshook)) { $filter['t.date_validated<='] = $search_date_validation_end; $param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear; } -} + if (!empty($search_import_key)) { + $filter['t.import_key'] = $search_import_key; + $param .= '&search_import_key='.urlencode($search_import_key); + } -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); + // param with type of list + $url_param = substr($param, 1); // remove first "&" + if (!empty($type)) { + $param = '&type='.$type.$param; + } - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + // $delmonth = GETPOST('delmonth', 'int'); + // $delyear = GETPOST('delyear', 'int'); + // if ($delyear == -1) { + // $delyear = 0; + // } + // $deljournal = GETPOST('deljournal', 'alpha'); + // if ($deljournal == -1) { + // $deljournal = 0; + // } + // + // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { + // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + // if ($result < 0) { + // setEventMessages($object->error, $object->errors, 'errors'); + // } else { + // setEventMessages("RecordDeleted", null, 'mesgs'); + // } + // + // // Make a redirect to avoid to launch the delete later after a back button + // header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); + // exit; + // } else { + // setEventMessages("NoRecordDeleted", null, 'warnings'); + // } + //} + + // Mass actions + $objectclass = 'Bookkeeping'; + $objectlabel = 'Bookkeeping'; + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) { + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { + $result = $object->deleteMvtNum($object->piece_num); + if ($result > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } elseif ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages("RecordDeleted", null, 'mesgs'); + // Message for elements well deleted + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); + } elseif ($nbok > 0) { + setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + } elseif (!$error) { + setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); } - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + if (!$error) { + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); + exit; } + } - header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); - exit; + // others mass actions + if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + if ($massaction == 'lettering') { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } elseif ($action == 'unlettering' && $confirm == "yes") { + $lettering = new Lettering($db); + $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); + if ($nb_lettering < 0) { + setEventMessages('', $lettering->errors, 'errors'); + $error++; + $nb_lettering = max(0, abs($nb_lettering) - 2); + } elseif ($nb_lettering == 0) { + $nb_lettering = 0; + setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); + } + if ($nb_lettering == 1) { + setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); + } elseif ($nb_lettering > 1) { + setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); + } + + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); + exit(); + } + } } } @@ -394,73 +491,101 @@ $formfile = new FormFile($db); $formother = new FormOther($db); $form = new Form($db); -$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("Bookkeeping").')'; +$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('; +if ($type == 'sub') { + $title_page .= $langs->trans("BookkeepingSubAccount"); +} else { + $title_page .= $langs->trans("Bookkeeping"); +} +$title_page .= ')'; llxHeader('', $title_page); // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + if ($type == 'sub') { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + } else { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + } + if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } -$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); +if ($type == 'sub') { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); +} else { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); +} if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } +$arrayofselected = is_array($toselect) ? $toselect : array(); + $num = count($object->lines); -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; +///if ($action == 'delbookkeepingyear') { +// $form_question = array(); +// $delyear = GETPOST('delyear', 'int'); +// $deljournal = GETPOST('deljournal', 'alpha'); +// +// if (empty($delyear)) { +// $delyear = dol_print_date(dol_now(), '%Y'); +// } +// $month_array = array(); +// for ($i = 1; $i <= 12; $i++) { +// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); +// } +// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); +// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); +// +// $form_question['delmonth'] = array( +// 'name' => 'delmonth', +// 'type' => 'select', +// 'label' => $langs->trans('DelMonth'), +// 'values' => $month_array, +// 'default' => '' +// ); +// $form_question['delyear'] = array( +// 'name' => 'delyear', +// 'type' => 'select', +// 'label' => $langs->trans('DelYear'), +// 'values' => $year_array, +// 'default' => $delyear +// ); +// $form_question['deljournal'] = array( +// 'name' => 'deljournal', +// 'type' => 'other', // We don't use select here, the journal_array is already a select html component +// 'label' => $langs->trans('DelJournal'), +// 'value' => $journal_array, +// 'default' => $deljournal +// ); +// +// $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); +//} + +// Print form confirm +print $formconfirm; + +// List of mass actions available +$arrayofmassactions = array(); +if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) { + $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering'); + $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering'); } -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); - print $formconfirm; +if ($user->rights->accounting->mouvements->supprimer) { + $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } - +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); print '
'; print ''; @@ -469,15 +594,22 @@ if ($optioncss != '') { print ''; } print ''; +print ''; print ''; print ''; +print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); + if ($type == 'sub') { + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + } else { + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + } $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } @@ -488,11 +620,29 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + +if ($massaction == 'preunlettering') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1); +} elseif ($massaction == 'predeletebookkeepingwriting') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); +} +//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité +//DelMonth=Mois à effacer +//DelYear=Année à supprimer +//DelJournal=Journal à supprimer +//ConfirmDeleteMvt=Cette action supprime les lignes des opérations pour l'année/mois et/ou pour le journal sélectionné (au moins un critère est requis). Vous devrez utiliser de nouveau la fonctionnalité '%s' pour retrouver vos écritures dans la comptabilité. +//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées). + +//$topicmail = "Information"; +//$modelmail = "accountingbookkeeping"; +//$objecttmp = new BookKeeping($db); +//$trackid = 'bk'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -503,15 +653,28 @@ if (preg_match('/^asc/i', $sortorder)) { $sortorder = "desc"; } +// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) +if ($type == 'sub') { + print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); +} + $moreforfilter = ''; // Accountancy account $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= '
'; -$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200'); +if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); +} else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200'); +} $moreforfilter .= ' '; -$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200'); +if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); +} else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200'); +} $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -599,6 +762,11 @@ if (!empty($arrayfields['t.date_validated']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['t.import_key']['checked'])) { + print ''; + print ''; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -643,6 +811,9 @@ if (!empty($arrayfields['t.date_export']['checked'])) { if (!empty($arrayfields['t.date_validated']['checked'])) { print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); } +if (!empty($arrayfields['t.import_key']['checked'])) { + print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -667,7 +838,11 @@ while ($i < min($num, $limit)) { $total_debit += $line->debit; $total_credit += $line->credit; - $accountg = length_accountg($line->numero_compte); + if ($type == 'sub') { + $accountg = length_accounta($line->subledger_account); + } else { + $accountg = length_accountg($line->numero_compte); + } //if (empty($accountg)) $accountg = '-'; $colspan = 0; // colspan before field 'label of operation' @@ -686,7 +861,11 @@ while ($i < min($num, $limit)) { // Show a subtotal by accounting account if (isset($displayed_account_number)) { print ''; - print ''.$langs->trans("TotalForAccount").' '.length_accountg($displayed_account_number).':'; + if ($type == 'sub') { + print '' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':'; + } else { + print '' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':'; + } print ''.price($sous_total_debit).''; print ''.price($sous_total_credit).''; print ''; @@ -712,11 +891,28 @@ while ($i < min($num, $limit)) { // Show the break account print ''; - print ''; - if ($line->numero_compte != "" && $line->numero_compte != '-1') { - print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); + print ''; + if ($type == 'sub') { + if ($line->subledger_account != "" && $line->subledger_account != '-1') { + print $line->subledger_label . ' : ' . length_accounta($line->subledger_account); + } else { + // Should not happen: subledger account must be null or a non empty value + print '' . $langs->trans("Unknown"); + if ($line->subledger_label) { + print ' (' . $line->subledger_label . ')'; + $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined'; + } else { + $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel'; + } + print $form->textwithpicto('', $htmltext); + print ''; + } } else { - print ''.$langs->trans("Unknown").''; + if ($line->numero_compte != "" && $line->numero_compte != '-1') { + print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); + } else { + print '' . $langs->trans("Unknown") . ''; + } } print ''; print ''; @@ -890,22 +1086,26 @@ while ($i < min($num, $limit)) { } } + if (!empty($arrayfields['t.import_key']['checked'])) { + print ''.$line->import_key."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$line); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // 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($line->id, $arrayofselected)) { + $selected = 1; } + print ''; } print ''; if (!$i) { @@ -955,11 +1155,11 @@ print ""; print ''; // TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} +//if ($user->rights->accounting->mouvements->supprimer_tous) { +// print '
'."\n"; +// print ''.$langs->trans("DeleteMvt").''; +// print '
'; +//} print '
'; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php deleted file mode 100644 index c6fb95d5ab7..00000000000 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ /dev/null @@ -1,979 +0,0 @@ - - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2018-2020 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 - * 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/bookkeeping/listbysubaccount.php - * \ingroup Accountancy (Double entries) - * \brief List operation of ledger ordered by subaccount number - */ - -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("accountancy", "compta")); - -$action = GETPOST('action', 'aZ09'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$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(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'); -$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); -$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); -$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); -$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); -$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); -$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); -$search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int'); -$search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int'); -$search_date_validation_startday = GETPOST('search_date_validation_startday', 'int'); -$search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int'); -$search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int'); -$search_date_validation_endday = GETPOST('search_date_validation_endday', 'int'); -$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); -$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); - -$search_accountancy_code = GETPOST("search_accountancy_code"); -$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); -if ($search_accountancy_code_start == - 1) { - $search_accountancy_code_start = ''; -} -$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); -if ($search_accountancy_code_end == - 1) { - $search_accountancy_code_end = ''; -} -$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); -$search_label_operation = GETPOST('search_label_operation', 'alpha'); -$search_mvt_num = GETPOST('search_mvt_num', 'int'); -$search_direction = GETPOST('search_direction', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'array'); -$search_debit = GETPOST('search_debit', 'alpha'); -$search_credit = GETPOST('search_credit', 'alpha'); -$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); -$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); - -if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { - $action = 'delbookkeepingyear'; -} - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) { - $page = 0; -} -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if ($sortorder == "") { - $sortorder = "ASC"; -} -if ($sortfield == "") { - $sortfield = "t.doc_date,t.rowid"; -} - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$object = new BookKeeping($db); -$formfile = new FormFile($db); -$hookmanager->initHooks(array('bookkeepingbysubaccountlist')); - -$formaccounting = new FormAccounting($db); -$form = new Form($db); - -if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { - $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) { - $fiscalYear = $db->fetch_object($res); - $search_date_start = strtotime($fiscalYear->date_start); - $search_date_end = strtotime($fiscalYear->date_end); - } 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 (dol_print_date(dol_now(), '%m') < $month_start) { - $year_start--; // If current month is lower that starting fiscal month, we start last year - } - $year_end = $year_start + 1; - $month_end = $month_start - 1; - if ($month_end < 1) { - $month_end = 12; - $year_end--; - } - $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); - $search_date_end = dol_get_last_day($year_end, $month_end); - } -} - -$arrayfields = array( - // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), - 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), - 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), - 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), - 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), - 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), - 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), -); - -if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { - unset($arrayfields['t.lettering_code']); -} - -if ($search_date_start && empty($search_date_startyear)) { - $tmparray = dol_getdate($search_date_start); - $search_date_startyear = $tmparray['year']; - $search_date_startmonth = $tmparray['mon']; - $search_date_startday = $tmparray['mday']; -} -if ($search_date_end && empty($search_date_endyear)) { - $tmparray = dol_getdate($search_date_end); - $search_date_endyear = $tmparray['year']; - $search_date_endmonth = $tmparray['mon']; - $search_date_endday = $tmparray['mday']; -} - -if (empty($conf->accounting->enabled)) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (empty($user->rights->accounting->mouvements->lire)) { - accessforbidden(); -} - - -/* - * Action - */ - -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} - -$parameters = array('socid'=>$socid); -$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)) { - 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 tests are required to be compatible with all browsers - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_label_account = ''; - $search_doc_ref = ''; - $search_label_operation = ''; - $search_mvt_num = ''; - $search_direction = ''; - $search_ledger_code = array(); - $search_date_start = ''; - $search_date_end = ''; - $search_date_startyear = ''; - $search_date_startmonth = ''; - $search_date_startday = ''; - $search_date_endyear = ''; - $search_date_endmonth = ''; - $search_date_endday = ''; - $search_date_export_start = ''; - $search_date_export_end = ''; - $search_date_export_startyear = ''; - $search_date_export_startmonth = ''; - $search_date_export_startday = ''; - $search_date_export_endyear = ''; - $search_date_export_endmonth = ''; - $search_date_export_endday = ''; - $search_date_validation_start = ''; - $search_date_validation_end = ''; - $search_date_validation_startyear = ''; - $search_date_validation_startmonth = ''; - $search_date_validation_startday = ''; - $search_date_validation_endyear = ''; - $search_date_validation_endmonth = ''; - $search_date_validation_endday = ''; - $search_debit = ''; - $search_credit = ''; - $search_lettering_code = ''; - $search_not_reconciled = ''; - } - - // Must be after the remove filter action, before the export. - $param = ''; - $filter = array(); - - if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth='.$search_date_startmonth.'&search_date_startday='.$search_date_startday.'&search_date_startyear='.$search_date_startyear; - } - if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth='.$search_date_endmonth.'&search_date_endday='.$search_date_endday.'&search_date_endyear='.$search_date_endyear; - } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); - } - if (!empty($search_accountancy_code_start)) { - $filter['t.subledger_account>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); - } - if (!empty($search_accountancy_code_end)) { - $filter['t.subledger_account<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); - } - if (!empty($search_label_account)) { - $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte='.urlencode($search_label_account); - } - if (!empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); - } - if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); - } - if (!empty($search_label_operation)) { - $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation='.urlencode($search_label_operation); - } - if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); - } - if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - foreach ($search_ledger_code as $code) { - $param .= '&search_ledger_code[]='.urlencode($code); - } - } - if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); - } - if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); - } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } - if (!empty($search_not_reconciled)) { - $filter['t.reconciled_option'] = $search_not_reconciled; - $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); - } - if (!empty($search_date_export_start)) { - $filter['t.date_export>='] = $search_date_export_start; - $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; - } - if (!empty($search_date_export_end)) { - $filter['t.date_export<='] = $search_date_export_end; - $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; - } - if (!empty($search_date_validation_start)) { - $filter['t.date_validated>='] = $search_date_validation_start; - $param .= '&search_date_validation_startmonth='.$search_date_validation_startmonth.'&search_date_validation_startday='.$search_date_validation_startday.'&search_date_validation_startyear='.$search_date_validation_startyear; - } - if (!empty($search_date_validation_end)) { - $filter['t.date_validated<='] = $search_date_validation_end; - $param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear; - } -} - -if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { - $import_key = GETPOST('importkey', 'alpha'); - - if (!empty($import_key)) { - $result = $object->deleteByImportkey($import_key); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } -} -if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { - $delmonth = GETPOST('delmonth', 'int'); - $delyear = GETPOST('delyear', 'int'); - if ($delyear == -1) { - $delyear = 0; - } - $deljournal = GETPOST('deljournal', 'alpha'); - if ($deljournal == -1) { - $deljournal = 0; - } - - if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { - $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages("RecordDeleted", null, 'mesgs'); - } - - // Make a redirect to avoid to launch the delete later after a back button - header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); - exit; - } else { - setEventMessages("NoRecordDeleted", null, 'warnings'); - } -} -if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { - $mvt_num = GETPOST('mvt_num', 'int'); - - if (!empty($mvt_num)) { - $result = $object->deleteMvtNum($mvt_num); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } - - header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); - exit; - } -} - - -/* - * View - */ - -$formaccounting = new FormAccounting($db); -$formfile = new FormFile($db); -$formother = new FormOther($db); -$form = new Form($db); - -$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')'; - -llxHeader('', $title_page); - -// List -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); - if ($nbtotalofrecords < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); - -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); -} - -$num = count($object->lines); - - -if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); - print $formconfirm; -} -if ($action == 'delbookkeepingyear') { - $form_question = array(); - $delyear = GETPOST('delyear', 'int'); - $deljournal = GETPOST('deljournal', 'alpha'); - - if (empty($delyear)) { - $delyear = dol_print_date(dol_now(), '%Y'); - } - $month_array = array(); - for ($i = 1; $i <= 12; $i++) { - $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); - } - $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); - - $form_question['delmonth'] = array( - 'name' => 'delmonth', - 'type' => 'select', - 'label' => $langs->trans('DelMonth'), - 'values' => $month_array, - 'default' => '' - ); - $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear - ); - $form_question['deljournal'] = array( - 'name' => 'deljournal', - 'type' => 'other', // We don't use select here, the journal_array is already a select html component - 'label' => $langs->trans('DelJournal'), - 'value' => $journal_array, - 'default' => $deljournal - ); - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); - print $formconfirm; -} - - -print '
'; -print ''; -print ''; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; - -$parameters = array(); -$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); -} - -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); -} - -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); - -print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); -} - -// Reverse sort order -if (preg_match('/^asc/i', $sortorder)) { - $sortorder = "asc"; -} else { - $sortorder = "desc"; -} - -$moreforfilter = ''; - -// Accountancy account -$moreforfilter .= '
'; -$moreforfilter .= $langs->trans('AccountAccounting').': '; -$moreforfilter .= '
'; -$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); -$moreforfilter .= ' '; -$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); -$moreforfilter .= '
'; -$moreforfilter .= '
'; - -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -print '
'; -print $moreforfilter; -print '
'; - -print '
'; -print ''; - -// Filters lines -print ''; - -// Movement number -if (!empty($arrayfields['t.piece_num']['checked'])) { - print ''; -} -// Code journal -if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; -} -// Date document -if (!empty($arrayfields['t.doc_date']['checked'])) { - print ''; -} -// Ref document -if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; -} -// Label operation -if (!empty($arrayfields['t.label_operation']['checked'])) { - print ''; -} -// Debit -if (!empty($arrayfields['t.debit']['checked'])) { - print ''; -} -// Credit -if (!empty($arrayfields['t.credit']['checked'])) { - print ''; -} -// Lettering code -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''; -} -// Date export -if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; -} -// Date validation -if (!empty($arrayfields['t.date_validated']['checked'])) { - print ''; -} - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -// Action column -print ''; -print "\n"; - -print ''; -if (!empty($arrayfields['t.piece_num']['checked'])) { - print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); -} -if (!empty($arrayfields['t.code_journal']['checked'])) { - print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.doc_date']['checked'])) { - print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.doc_ref']['checked'])) { - print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['t.label_operation']['checked'])) { - print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['t.debit']['checked'])) { - print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); -} -if (!empty($arrayfields['t.credit']['checked'])) { - print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); -} -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.date_export']['checked'])) { - print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['t.date_validated']['checked'])) { - print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); -} -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); -print "\n"; - - -$total_debit = 0; -$total_credit = 0; -$sous_total_debit = 0; -$sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$totalarray = array(); -while ($i < min($num, $limit)) { - $line = $object->lines[$i]; - - $total_debit += $line->debit; - $total_credit += $line->credit; - - $accountg = length_accounta($line->subledger_account); - //if (empty($accountg)) $accountg = '-'; - - $colspan = 0; // colspan before field 'label of operation' - $colspanend = 3; // colspan after debit/credit - if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; } - if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; } - if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; } - if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; } - - // Is it a break ? - if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - // Show a subtotal by accounting account - if (isset($displayed_account_number)) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Show balance of last shown account - $balance = $sous_total_debit - $sous_total_credit; - print ''; - print ''; - if ($balance > 0) { - print ''; - print ''; - } else { - print ''; - print ''; - } - print ''; - print ''; - } - - // Show the break account - print ''; - print ''; - print ''; - - $displayed_account_number = $accountg; - //if (empty($displayed_account_number)) $displayed_account_number='-'; - $sous_total_debit = 0; - $sous_total_credit = 0; - - $colspan = 0; - } - - print ''; - - // Piece number - if (!empty($arrayfields['t.piece_num']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Journal code - if (!empty($arrayfields['t.code_journal']['checked'])) { - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Document date - if (!empty($arrayfields['t.doc_date']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Document ref - if (!empty($arrayfields['t.doc_ref']['checked'])) { - if ($line->doc_type == 'customer_invoice') { - $langs->loadLangs(array('bills')); - - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $objectstatic = new Facture($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'facture'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'supplier_invoice') { - $langs->loadLangs(array('bills')); - - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $objectstatic = new FactureFournisseur($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'invoice_supplier'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } elseif ($line->doc_type == 'expense_report') { - $langs->loadLangs(array('trips')); - - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $objectstatic = new ExpenseReport($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'expensereport'; - - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'bank') { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $objectstatic = new AccountLine($db); - $objectstatic->fetch($line->fk_doc); - } else { - // Other type - } - - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label operation - if (!empty($arrayfields['t.label_operation']['checked'])) { - // Affiche un lien vers la facture client/fournisseur - $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount debit - if (!empty($arrayfields['t.debit']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; - } - $totalarray['val']['totaldebit'] += $line->debit; - } - - // Amount credit - if (!empty($arrayfields['t.credit']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; - } - $totalarray['val']['totalcredit'] += $line->credit; - } - - // Lettering code - if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Exported operation date - if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Validated operation date - if (!empty($arrayfields['t.date_validated']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action column - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; - - print "\n"; - - $i++; -} - -if ($num > 0 && $colspan > 0) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Show balance of last shown account - $balance = $sous_total_debit - $sous_total_credit; - print ''; - print ''; - if ($balance > 0) { - print ''; - print ''; - } else { - print ''; - print ''; - } - print ''; - print ''; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - -print "
'; - print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); - print ''; - print '
'; - print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; - print ''; - print '
'.$langs->trans("NotReconciled").''; - print '
'; - print '
'; - print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print '
'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); - print ''; - print price($sous_total_credit - $sous_total_debit); - print '
'; - if ($line->subledger_account != "" && $line->subledger_account != '-1') { - print $line->subledger_label.' : '.length_accounta($line->subledger_account); - } else { - // Should not happen: subledger account must be null or a non empty value - print ''.$langs->trans("Unknown"); - if ($line->subledger_label) { - print ' ('.$line->subledger_label.')'; - $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined'; - } else { - $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel'; - } - print $form->textwithpicto('', $htmltext); - print ''; - } - print '
'; - $object->id = $line->id; - $object->piece_num = $line->piece_num; - print $object->getNomUrl(1, '', 0, '', 1); - print ''.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''; - - print ''; - // Picto + Ref - print '
'; - - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { - print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - print $documentlink; - } elseif ($line->doc_type == 'bank') { - print $objectstatic->getNomUrl(1); - $bank_ref = strstr($line->doc_ref, '-'); - print " " . $bank_ref; - } else { - print $line->doc_ref; - } - print '
'; - - print "
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
'.($line->debit ? price($line->debit) : '').''.($line->credit ? price($line->credit) : '').''.$line->lettering_code.''.dol_print_date($line->date_export, 'dayhour').''.dol_print_date($line->date_validation, 'dayhour').''; - if (empty($line->date_export) && empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->creer) { - print '' . img_edit() . ''; - } - } - if (empty($line->date_validation)) { - if ($user->rights->accounting->mouvements->supprimer) { - print ''.img_delete().''; - } - } - print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); - print ''; - print price($sous_total_credit - $sous_total_debit); - print '
"; -print '
'; - -// TODO Replace this with mass delete action -if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; -} - -print '
'; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3c30200c130..128b14fa800 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -980,6 +980,8 @@ class AccountancyExport print dol_string_unaccent($date_creation) . $separator; // FEC:EcritureLib + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print dol_string_unaccent($line->label_operation) . $separator; // FEC:Debit @@ -1007,6 +1009,8 @@ class AccountancyExport print $date_limit_payment . $separator; // FEC_suppl:NumFacture + // Clean ref invoice to prevent problem on export with tab separator & other character + $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice); print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1); print $end_line; @@ -1107,6 +1111,8 @@ class AccountancyExport print $date_document . $separator; // FEC:EcritureLib + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print dol_string_unaccent($line->label_operation) . $separator; // FEC:Debit @@ -1134,6 +1140,8 @@ class AccountancyExport print $date_limit_payment . $separator; // FEC_suppl:NumFacture + // Clean ref invoice to prevent problem on export with tab separator & other character + $refInvoice = str_replace(array("\t", "\n", "\r"), " ", $refInvoice); print dol_trunc(self::toAnsi($refInvoice), 17, 'right', 'UTF-8', 1); @@ -1712,6 +1720,8 @@ class AccountancyExport print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->doc_ref, 20).$separator; //Piece + // Clean label operation to prevent problem on export with tab separator & other character + $line->label_operation = str_replace(array("\t", "\n", "\r"), " ", $line->label_operation); print self::trunc($line->label_operation, 60).$separator; //Operation label print price(abs($line->debit - $line->credit)).$separator; //Amount print $line->sens.$separator; //Direction diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a83a311010d..21b723b003b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -852,7 +852,8 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.date_export,"; - $sql .= " t.date_validated as date_validation"; + $sql .= " t.date_validated as date_validation,"; + $sql .= " t.import_key"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -947,6 +948,7 @@ class BookKeeping extends CommonObject $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_export = $this->db->jdate($obj->date_export); $line->date_validation = $this->db->jdate($obj->date_validation); + $line->import_key = $obj->import_key; $this->lines[] = $line; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index f722a716b79..a2718973185 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -33,6 +33,12 @@ include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class Lettering extends BookKeeping { + /** + * @var BookKeeping[] Bookkeeping cached + */ + public static $bookkeeping_cached = array(); + + /** * letteringThirdparty * @@ -119,6 +125,7 @@ class Lettering extends BookKeeping $ids[$obj2->rowid] = $obj2->rowid; $ids_fact[] = $obj2->fact_id; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -146,6 +153,7 @@ class Lettering extends BookKeeping while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -205,6 +213,7 @@ class Lettering extends BookKeeping while ($obj2 = $this->db->fetch_object($resql2)) { $ids[$obj2->rowid] = $obj2->rowid; } + $this->db->free($resql2); } else { $this->errors[] = $this->db->lasterror; return -1; @@ -216,6 +225,7 @@ class Lettering extends BookKeeping $result = $this->updateLettering($ids); } } + $this->db->free($resql); } if ($error) { foreach ($this->errors as $errmsg) { @@ -230,17 +240,31 @@ class Lettering extends BookKeeping /** * - * @param array $ids ids array - * @param boolean $notrigger no trigger - * @return number + * @param array $ids ids array + * @param boolean $notrigger no trigger + * @return int */ public function updateLettering($ids = array(), $notrigger = false) { $error = 0; $lettre = 'AAA'; - $sql = "SELECT DISTINCT lettering_code FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; - $sql .= " lettering_code != '' ORDER BY lettering_code DESC limit 1"; + $sql = "SELECT DISTINCT ab2.lettering_code"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping As ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu2 ON bu2.url_id = bu.url_id"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab2 ON ab2.fk_doc = bu2.fk_bank"; + $sql .= " WHERE ab.rowid IN (" . $this->db->sanitize(implode(',', $ids)) . ")"; + $sql .= " AND ab.doc_type = 'bank'"; + $sql .= " AND ab2.doc_type = 'bank'"; + $sql .= " AND bu.type = 'company'"; + $sql .= " AND bu2.type = 'company'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab2.subledger_account != ''"; + $sql .= " AND ab.lettering_code IS NULL"; + $sql .= " AND ab2.lettering_code != ''"; + $sql .= " ORDER BY ab2.lettering_code DESC"; + $sql .= " LIMIT 1 "; $result = $this->db->query($sql); if ($result) { @@ -249,13 +273,14 @@ class Lettering extends BookKeeping if (!empty($obj->lettering_code)) { $lettre++; } + $this->db->free($result); } else { $this->errors[] = 'Error'.$this->db->lasterror(); $error++; } $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; - $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL"; + $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -263,6 +288,7 @@ class Lettering extends BookKeeping $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } + $this->db->free($result); } else { $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; @@ -276,8 +302,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 (".$this->db->sanitize(implode(',', $ids)).") AND date_validated IS NULL "; - $this->db->begin(); + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -293,11 +318,429 @@ class Lettering extends BookKeeping dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - $this->db->rollback(); return -1 * $error; } else { - $this->db->commit(); return 1; } } + + /** + * + * @param array $ids ids array + * @param boolean $notrigger no trigger + * @return int + */ + public function deleteLettering($ids, $notrigger = false) + { + $error = 0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; + $sql .= " lettering_code = NULL"; + $sql .= " , date_lettering = NULL"; + $sql .= " WHERE rowid IN (".$this->db->sanitize(implode(',', $ids)).")"; + $sql .= " AND subledger_account != ''"; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + return -1 * $error; + } else { + return 1; + } + } + + /** + * Lettering bookkeeping lines all types + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param bool $unlettering Do unlettering + * @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered) + */ + public function bookkeepingLetteringAll($bookkeeping_ids, $unlettering = false) + { + dol_syslog(__METHOD__ . " - ", LOG_DEBUG); + + $error = 0; + $errors = array(); + $nb_lettering = 0; + + $result = $this->bookkeepingLettering($bookkeeping_ids, 'customer_invoice', $unlettering); + if ($result < 0) { + $error++; + $errors = array_merge($errors, $this->errors); + $nb_lettering += abs($result) - 2; + } else { + $nb_lettering += $result; + } + + $result = $this->bookkeepingLettering($bookkeeping_ids, 'supplier_invoice', $unlettering); + if ($result < 0) { + $error++; + $errors = array_merge($errors, $this->errors); + $nb_lettering += abs($result) - 2; + } else { + $nb_lettering += $result; + } + + if ($error) { + $this->errors = $errors; + return -2 - $nb_lettering; + } else { + return $nb_lettering; + } + } + + /** + * Lettering bookkeeping lines + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @param bool $unlettering Do unlettering + * @return int <0 if error (nb lettered = result -1), 0 if noting to lettering, >0 if OK (nb lettered) + */ + public function bookkeepingLettering($bookkeeping_ids, $type = 'customer_invoice', $unlettering = false) + { + global $langs; + + $this->errors = array(); + + // Clean parameters + $bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array(); + $type = trim($type); + + $error = 0; + $nb_lettering = 0; + $grouped_lines = $this->getLinkedLines($bookkeeping_ids, $type); + foreach ($grouped_lines as $lines) { + $group_error = 0; + $total = 0; + $do_it = !$unlettering; + $lettering_code = null; + $piece_num_lines = array(); + $bookkeeping_lines = array(); + foreach ($lines as $line_infos) { + $bookkeeping_lines[$line_infos['id']] = $line_infos['id']; + $piece_num_lines[$line_infos['piece_num']] = $line_infos['piece_num']; + $total += ($line_infos['credit'] > 0 ? $line_infos['credit'] : -$line_infos['debit']); + + // Check lettering code + if ($unlettering) { + if (isset($lettering_code) && $lettering_code != $line_infos['lettering_code']) { + $this->errors[] = $langs->trans('AccountancyErrorMismatchLetteringCode'); + $group_error++; + break; + } + if (!isset($lettering_code)) $lettering_code = (string) $line_infos['lettering_code']; + if (!empty($line_infos['lettering_code'])) $do_it = true; + } elseif (!empty($line_infos['lettering_code'])) $do_it = false; + } + + // Check balance amount + if (!$group_error && !$unlettering && price2num($total) != 0) { + $this->errors[] = $langs->trans('AccountancyErrorMismatchBalanceAmount', $total); + $group_error++; + } + + // Lettering/Unlettering the group of bookkeeping lines + if (!$group_error && $do_it) { + if ($unlettering) $result = $this->deleteLettering($bookkeeping_lines); + else $result = $this->updateLettering($bookkeeping_lines); + if ($result < 0) { + $group_error++; + } else { + $nb_lettering++; + } + } + + if ($group_error) { + $this->errors[] = $langs->trans('AccountancyErrorLetteringBookkeeping', implode(', ', $piece_num_lines)); + $error++; + } + } + + if ($error) { + return -2 - $nb_lettering; + } else { + return $nb_lettering; + } + } + + /** + * Lettering bookkeeping lines + * + * @param array $bookkeeping_ids Lettering specific list of bookkeeping id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @return array|int <0 if error otherwise all linked lines by block + */ + public function getLinkedLines($bookkeeping_ids, $type = 'customer_invoice') + { + global $conf, $langs; + $this->errors = array(); + + // Clean parameters + $bookkeeping_ids = is_array($bookkeeping_ids) ? $bookkeeping_ids : array(); + $type = trim($type); + + if ($type == 'customer_invoice') { + $doc_type = 'customer_invoice'; + $bank_url_type = 'payment'; + $payment_element = 'paiement_facture'; + $fk_payment_element = 'fk_paiement'; + $fk_element = 'fk_facture'; + $account_number = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + } elseif ($type == 'supplier_invoice') { + $doc_type = 'supplier_invoice'; + $bank_url_type = 'payment_supplier'; + $payment_element = 'paiementfourn_facturefourn'; + $fk_payment_element = 'fk_paiementfourn'; + $fk_element = 'fk_facturefourn'; + $account_number = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + } else { + $langs->load('errors'); + $this->errors[] = $langs->trans('ErrorBadParameters'); + return -1; + } + + $payment_ids = array(); + + // Get all payment id from bank lines + $sql = "SELECT DISTINCT bu.url_id AS payment_id"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url AS bu ON bu.fk_bank = ab.fk_doc"; + $sql .= " WHERE ab.doc_type = 'bank'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; + if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $payment_ids[$obj->payment_id] = $obj->payment_id; + } + $this->db->free($resql); + + // Get all payment id from payment lines + $sql = "SELECT DISTINCT pe.$fk_payment_element AS payment_id"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe ON pe.$fk_element = ab.fk_doc"; + $sql .= " WHERE ab.doc_type = '" . $this->db->escape($doc_type) . "'"; + // $sql .= " AND ab.subledger_account != ''"; + // $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND pe.$fk_payment_element IS NOT NULL"; + if (!empty($bookkeeping_ids)) $sql .= " AND ab.rowid IN (" . $this->db->sanitize(implode(',', $bookkeeping_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get all payment id from bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $payment_ids[$obj->payment_id] = $obj->payment_id; + } + $this->db->free($resql); + + if (empty($payment_ids)) { + return array(); + } + + // Get all payments linked by group + $payment_by_group = $this->getLinkedPaymentByGroup($payment_ids, $type); + + $groups = array(); + foreach ($payment_by_group as $payment_list) { + $lines = array(); + + // Get bank lines + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit"; + $sql .= " FROM " . MAIN_DB_PREFIX . "bank_url AS bu"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = bu.fk_bank"; + $sql .= " WHERE bu.url_id IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")"; + $sql .= " AND bu.type = '" . $this->db->escape($bank_url_type) . "'"; + $sql .= " AND ab.doc_type = 'bank'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + + dol_syslog(__METHOD__ . " - Get bank lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit); + } + $this->db->free($resql); + + // Get payment lines + $sql = "SELECT DISTINCT ab.rowid, ab.piece_num, ab.lettering_code, ab.debit, ab.credit"; + $sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab ON ab.fk_doc = pe.$fk_element"; + $sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_list)) . ")"; + $sql .= " AND ab.doc_type = '" . $this->db->escape($doc_type) . "'"; + $sql .= " AND ab.subledger_account != ''"; + $sql .= " AND ab.numero_compte = '" . $this->db->escape($account_number) . "'"; + + dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + while ($obj = $this->db->fetch_object($resql)) { + $lines[$obj->rowid] = array('id' => $obj->rowid, 'piece_num' => $obj->piece_num, 'lettering_code' => $obj->lettering_code, 'debit' => $obj->debit, 'credit' => $obj->credit); + } + $this->db->free($resql); + + if (!empty($lines)) { + $groups[] = $lines; + } + } + + return $groups; + } + + /** + * Linked payment by group + * + * @param array $payment_ids list of payment id + * @param string $type Type of bookkeeping type to lettering ('customer_invoice' or 'supplier_invoice') + * @return array|int <0 if error otherwise all linked lines by block + */ + public function getLinkedPaymentByGroup($payment_ids, $type) + { + global $langs; + + // Clean parameters + $payment_ids = is_array($payment_ids) ? $payment_ids : array(); + $type = trim($type); + + if (empty($payment_ids)) { + return array(); + } + + if ($type == 'customer_invoice') { + $payment_element = 'paiement_facture'; + $fk_payment_element = 'fk_paiement'; + $fk_element = 'fk_facture'; + } elseif ($type == 'supplier_invoice') { + $payment_element = 'paiementfourn_facturefourn'; + $fk_payment_element = 'fk_paiementfourn'; + $fk_element = 'fk_facturefourn'; + } else { + $langs->load('errors'); + $this->errors[] = $langs->trans('ErrorBadParameters'); + return -1; + } + + // Get payment lines + $sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element"; + $sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element"; + $sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")"; + + dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $this->errors[] = "Error " . $this->db->lasterror(); + return -1; + } + + $current_payment_ids = array(); + $payment_by_element = array(); + $element_by_payment = array(); + while ($obj = $this->db->fetch_object($resql)) { + $current_payment_ids[$obj->$fk_payment_element] = $obj->$fk_payment_element; + $element_by_payment[$obj->$fk_payment_element][$obj->$fk_element] = $obj->$fk_element; + $payment_by_element[$obj->$fk_element][$obj->$fk_payment_element] = $obj->$fk_payment_element; + } + $this->db->free($resql); + + if (count(array_diff($payment_ids, $current_payment_ids))) { + return $this->getLinkedPaymentByGroup($current_payment_ids, $type); + } + + return $this->getGroupElements($payment_by_element, $element_by_payment); + } + + /** + * Get payment ids grouped by payment id and element id in common + * + * @param array $payment_by_element List of payment ids by element id + * @param array $element_by_payment List of element ids by payment id + * @param int $element_id Element Id (used for recursive function) + * @param array $current_group Current group (used for recursive function) + * @return array List of payment ids grouped by payment id and element id in common + */ + public function getGroupElements(&$payment_by_element, &$element_by_payment, $element_id = 0, &$current_group = array()) + { + $grouped_payments = array(); + if ($element_id > 0 && !isset($payment_by_element[$element_id])) { + // Return if specific element id not found + return $grouped_payments; + } + + if ($element_id == 0) { + // Save list when is the begin of recursive function + $save_payment_by_element = $payment_by_element; + $save_element_by_payment = $element_by_payment; + } + + do { + // Get current element id, get this payment id list and delete the entry + $current_element_id = $element_id > 0 ? $element_id : array_keys($payment_by_element)[0]; + $payment_ids = $payment_by_element[$current_element_id]; + unset($payment_by_element[$current_element_id]); + + foreach ($payment_ids as $payment_id) { + // Continue if payment id in not found + if (!isset($element_by_payment[$payment_id])) continue; + + // Set the payment in the current group + $current_group[$payment_id] = $payment_id; + + // Get current element ids, get this payment id list and delete the entry + $element_ids = $element_by_payment[$payment_id]; + unset($element_by_payment[$payment_id]); + + // Set payment id on the current group for each element id of the payment + foreach ($element_ids as $id) { + $this->getGroupElements($payment_by_element, $element_by_payment, $id, $current_group); + } + } + + if ($element_id == 0) { + // Save current group and reset the current group when is the begin of recursive function + $grouped_payments[] = $current_group; + $current_group = array(); + } + } while (!empty($payment_by_element) && $element_id == 0); + + if ($element_id == 0) { + // Restore list when is the begin of recursive function + $payment_by_element = $save_payment_by_element; + $element_by_payment = $save_element_by_payment; + } + + return $grouped_payments; + } } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4841b8bf171..8a02ac3849a 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -665,6 +665,8 @@ if (!$error && $action == 'writebookkeeping') { // Line into thirdparty account foreach ($tabtp[$key] as $k => $mt) { if ($mt) { + $lettering = false; + $reflabel = ''; if (!empty($val['lib'])) { $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); @@ -693,11 +695,13 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->date_creation = $now; if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $lettering = true; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->label_compte = $accountingaccountcustomer->label; } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $lettering = true; $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; @@ -780,6 +784,12 @@ if (!$error && $action == 'writebookkeeping') { $errorforline++; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); + } } } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8b1ac0d3de3..7c0a8b90f7d 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -377,6 +377,12 @@ if ($action == 'writebookkeeping') { $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'supplier_invoice'); + } } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7a5ccd79b21..7cc7f0effbc 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -390,6 +390,12 @@ if ($action == 'writebookkeeping') { $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } + } else { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; + $lettering_static = new Lettering($db); + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'customer_invoice'); + } } } } diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 94621195ac9..e9eb00d23f7 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -79,7 +79,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { } $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; } $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; @@ -110,7 +110,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { $adherentstatic->firstname = $objp->firstname; // Format extrafield so they can be parsed in function complete_substitutions_array - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $adherentstatic->array_options = array(); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { $tmpkey = 'options_'.$key; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1936d855a7e..9fa02f1c01b 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -172,7 +172,7 @@ $result = restrictedArea($user, 'adherent'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -587,7 +587,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').' '.$langs->trans("SendByMail"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); if ($user->rights->adherent->creer) { diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 0b83881e502..aed531d86b4 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -111,7 +111,7 @@ $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 5c8eb88126c..f4afd27d46b 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -302,6 +302,7 @@ foreach ($dirmodels as $reldir) { $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $commande->type = 0; + $nextval = $module->getNextValue($mysoc, $commande); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; @@ -614,7 +615,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; @@ -630,7 +631,7 @@ print "'; print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 3e878b9398b..8195683c5ab 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -93,15 +93,17 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; print "\n"; -print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; -print ''; // This slow seriously output -print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput"); +print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; +print ''; +print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); +print ''; +print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").''; print ''; -print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; -print ''; -print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); -print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower"); +print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; +print ''; // This slow seriously output +print ''; +print ''.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").''; print ''; print ''; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 7a4faa989d0..d01b160ca31 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -428,15 +428,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir); } - $timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT; - $timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT; + $timeoutconnect = empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 5 : $conf->global->MAIN_USE_CONNECT_TIMEOUT; + $timeoutread = empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 20 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT; dol_syslog("imap_open connectstring=".$connectstringsource." login=".$object->login." password=".$object->password." timeoutconnect=".$timeoutconnect." timeoutread=".$timeoutread); - imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); - imap_timeout(IMAP_READTIMEOUT, $timeoutread); + $result1 = imap_timeout(IMAP_OPENTIMEOUT, $timeoutconnect); // timeout seems ignored with ssl connect + $result2 = imap_timeout(IMAP_READTIMEOUT, $timeoutread); + $result3 = imap_timeout(IMAP_WRITETIMEOUT, 5); + $result4 = imap_timeout(IMAP_CLOSETIMEOUT, 5); + + dol_syslog("result1=".$result1." result2=".$result2." result3=".$result3." result4=".$result4); $connection = imap_open($connectstringsource, $object->login, $object->password); + + //dol_syslog("end imap_open connection=".var_export($connection, true)); } catch (Exception $e) { print $e->getMessage(); } @@ -490,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; print ''; - print ''; + print ''; print ''; // Add filter print ''; @@ -647,7 +653,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); } print ''; - print '
'.img_picto('', 'filter', 'class="pictofixedwidth"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).''.img_picto('', 'filter', 'class="pictofixedwidth opacitymedium"').$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'
'; + print ''; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { print '
'; print ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 9e93dd78b86..32b55d0a612 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + dol_include_once('/emailcollector/class/emailcollector.class.php'); // Load translation files required by page @@ -43,6 +44,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // 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') +$mode = GETPOST('mode', 'aZ'); $id = GETPOST('id', 'int'); @@ -52,8 +54,9 @@ $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') || (empty($toselect) && $massaction === '0')) { + // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -73,7 +76,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition. } if (!$sortorder) { $sortorder = "ASC"; @@ -88,12 +91,16 @@ if ($user->socid > 0) { // Protection if external user //$result = restrictedArea($user, 'emailcollector', $id, ''); // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alphanohtml'); +$search_all = GETPOST('search_all', '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" @@ -109,29 +116,19 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = dol_eval($val['visible'], 1, 1, '1'); + $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, 1, '1')), - 'position'=>$val['position'] + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' ); } } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { - $arrayfields["ef.".$key] = array( - 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), - 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]), - 'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key] - ); - } - } -} +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'); @@ -156,7 +153,8 @@ if (empty($conf->emailcollector->enabled)) { */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -176,8 +174,12 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -200,20 +202,22 @@ if (empty($reshook)) { $form = new Form($db); +$now = dol_now(); + $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électronique|ES:Module_EMail_Collector"; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); +$morejs = array(); +$morecss = array(); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks @@ -222,7 +226,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($object->ismultientitymanaged == 1) { @@ -231,18 +235,32 @@ if ($object->ismultientitymanaged == 1) { $sql .= " WHERE 1 = 1"; } foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') { - $search[$key] = ''; + 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) || !empty($object->fields[$key]['arrayofkeyval'])) { + if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search("t.".$db->escape($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.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; + } + } } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } if ($search_all) { @@ -257,49 +275,48 @@ $sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY "; -foreach ($object->fields as $key => $val) -{ - $sql .= "t.".$key.", "; +foreach ($object->fields as $key => $val) { + $sql .= "t.".$db->escape($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.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + } } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/','', $sql); +$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 $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); + $db->free($resql); } +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} + +$resql = $db->query($sql); +if (!$resql) { + 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) { @@ -313,7 +330,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -327,9 +344,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -338,6 +357,10 @@ if ($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( @@ -352,7 +375,7 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -print '
'; +print ''."\n"; if ($optioncss != '') { print ''; } @@ -407,25 +430,43 @@ print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $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') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -438,45 +479,57 @@ $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 ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $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') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label 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"; + $totalarray['nbfield']++; } } // 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); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 @@ -488,8 +541,10 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$savnbfield = $totalarray['nbfield']; +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -498,73 +553,107 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // 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 ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - 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); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $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']++; - } + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - print ''."\n"; + 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')) && empty($val['arrayofkeyval'])) { + $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 == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $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 + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; } @@ -581,7 +670,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } @@ -594,6 +683,34 @@ print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + 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) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $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, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); + } 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 '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + // Output Kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + 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($object->id, $arrayofselected)) { + $selected = 1; + } + 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($object->id, $arrayofselected)) { - $selected = 1; - } - 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; print ''."\n"; +print load_fiche_titre($langs->trans("Other"), '', ''); + + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''; + +print ''; +print ''; +print ''; +print "\n"; + +// Hide e-mail headers from collected messages +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameter").'
'.$form->textwithpicto($langs->trans("EmailCollectorHideMailHeaders"), $langs->transnoentitiesnoconv("EmailCollectorHideMailHeadersHelp")).''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); +} +print '
'; +print '
'; + +print '
'; + print '
'."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 254f7d3c8d4..f5b1fd0a4db 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -220,7 +220,7 @@ if ($action == 'edit') { foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { $setupnotempty++; - print '
aa'; + print '
'; $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); $tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '

'."\n".$langs->trans($constname . 'Tooltip2') : ''); print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 2c997d746d9..bf486ea3d4e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -475,6 +475,7 @@ if ($mode == 'other') { print '
'; print ''; + print ''; print '
'; print '
'; @@ -485,18 +486,17 @@ if ($mode == 'other') { print ''; print ''; + print $langs->trans("Miscellaneous"); + print ''; + print ''; + print ''; // Max size of lists print ''; - print ''; print ''; // Max size of short lists on customer card print ''; - print ''; print ''; // show input border @@ -504,7 +504,6 @@ if ($mode == 'other') { print ''; - print ''; print ''; */ @@ -512,21 +511,18 @@ if ($mode == 'other') { print ''; - print ''; print ''; // DefaultWorkingDays print ''; - print ''; print ''; // DefaultWorkingHours print ''; - print ''; print ''; // Firstname/Name @@ -534,7 +530,6 @@ if ($mode == 'other') { $array = array(0 => $langs->trans("Firstname") . ' ' . $langs->trans("Lastname"), 1 => $langs->trans("Lastname") . ' ' . $langs->trans("Firstname")); print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? $conf->global->MAIN_FIRSTNAME_NAME_POSITION : 0)); print ''; - print ''; print ''; // Hide unauthorized menus @@ -542,7 +537,6 @@ if ($mode == 'other') { //print $form->selectyesno('MAIN_MENU_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_MENU_HIDE_UNAUTHORIZED : 0, 1); print ajax_constantonoff("MAIN_MENU_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); print ''; - print ''; print ''; // Hide unauthorized button @@ -550,7 +544,6 @@ if ($mode == 'other') { //print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) ? $conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED : 0, 1); print ajax_constantonoff("MAIN_BUTTON_HIDE_UNAUTHORIZED", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); print ''; - print ''; print ''; // Hide version link @@ -559,17 +552,21 @@ if ($mode == 'other') { print ''; - print ''; print ''; */ + // Show Quick Add link + print ''; + print ''; + // Show bugtrack link print ''; - print ''; print ''; // Hide wiki link on login page @@ -578,15 +575,11 @@ if ($mode == 'other') { print ajax_constantonoff("MAIN_HELP_DISABLELINK", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); //print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK) ? $conf->global->MAIN_HELP_DISABLELINK : 0, 1); print ''; - print ''; print ''; // Disable javascript and ajax - print ''; - print ''; print ''; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index d10e789f39c..e58cf45dd7e 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -435,7 +435,8 @@ foreach ($configfileparameters as $key => $value) { if (empty($valuetoshow)) { print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); } - print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; + print ''; + print ''."\n"; } elseif ($newkey == 'dolibarr_main_prod') { print ${$newkey}; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index ebf4187eabf..f257b040636 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -103,10 +103,11 @@ if ($action == 'updateMask') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); + $notification_email_description = "Sender of ticket replies sent from Dolibarr"; if (!empty($notification_email)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity); + } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity); } if (!($res > 0)) { $error++; @@ -114,30 +115,33 @@ if ($action == 'updateMask') { // altairis : differentiate notification email FROM and TO $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); + $notification_email_to_description = "Notified e-mail for ticket replies sent from Dolibarr"; if (!empty($notification_email_to)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, $notification_email_to_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, $notification_email_to_description, $conf->entity); } if (!($res > 0)) { $error++; } $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml'); + $mail_intro_description = "Introduction text of ticket replies sent from Dolibarr"; if (!empty($mail_intro)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, $mail_intro_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', '', 'chaine', 0, $mail_intro_description, $conf->entity); } if (!($res > 0)) { $error++; } $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml'); + $signature_description = "Signature of ticket replies sent from Dolibarr"; if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, $signature_description, $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', '', 'chaine', 0, $signature_description, $conf->entity); } if (!($res > 0)) { $error++; @@ -644,7 +648,7 @@ print ''; print ''; // Email for notification of TICKET_CREATE -print ''; +print ''; print ''; print ''; print '\n"; print ''; @@ -477,7 +483,7 @@ if ($mode == 'searchkey') { //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder; $title = $langs->trans("Translation"); if ($nbtotalofrecords > 0) { - $title .= ' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')'; + $title .= ' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')'; } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index b5098bfd3ce..53760aaa586 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -113,7 +113,7 @@ $tabcond[1] = (!empty($conf->website->enabled)); // List of help for fields $tabhelp = array(); -$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref')); +$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref')); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -271,8 +271,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($resql) { $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); if ($newname != $website->ref) { - $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref; - $destfile = DOL_DATA_ROOT.'/website/'.$newname; + $srcfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref; + $destfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$newname; if (dol_is_dir($destfile)) { $error++; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9bf7dd7c117..81ba8e3b09d 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -611,6 +611,16 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object = new FactureFournisseur($this->db); + } elseif ($modulepart == 'commande' || $modulepart == 'order') { + $modulepart = 'commande'; + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $object = new Commande($this->db); + } elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') { + $modulepart = 'supplier_order'; + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $object = new CommandeFournisseur($this->db); } elseif ($modulepart == 'project') { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object = new Project($this->db); @@ -669,7 +679,7 @@ class Documents extends DolibarrApi } // Special cases that need to use get_exdir to get real dir of object - // If future, all object should use this to define path of documents. + // In future, all object should use this to define path of documents. if ($modulepart == 'supplier_invoice') { $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 5449975e777..7ab09e8d891 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -25,6 +25,7 @@ * \brief File of class to parse ical calendars */ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; /** @@ -39,6 +40,7 @@ class ICal public $todo_count; // Number of Todos public $freebusy_count; // Number of Freebusy public $last_key; //Help variable save last key (multiline string) + public $error; /** @@ -61,11 +63,15 @@ class ICal $this->file = $file; $file_text = ''; - $tmparray = file($file); - if (is_array($tmparray)) { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + $tmpresult = getURLContent($file, 'GET'); + if ($tmpresult['http_code'] != 200) { + $file_text = ''; + $this->error = 'Error: '.$tmpresult['http_code'].' '.$tmpresult['content']; + } else { + $file_text = preg_replace("/[\r\n]{1,} /", "", $tmpresult['content']); } + //var_dump($tmpresult); + return $file_text; // return all text } @@ -396,19 +402,19 @@ class ICal public function get_event_list() { // phpcs:enable - return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); + return (empty($this->cal['VEVENT']) ? '' : $this->cal['VEVENT']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return eventlist array (not sort eventlist array) + * Return freebusy array (not sort eventlist array) * * @return array */ public function get_freebusy_list() { // phpcs:enable - return $this->cal['VFREEBUSY']; + return (empty($this->cal['VFREEBUSY']) ? '' : $this->cal['VFREEBUSY']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9f6ee0c539f..4f8b8509f4e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -277,12 +277,12 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) { if (!empty($conf->global->$source) && !empty($conf->global->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' $listofextcals[] = array( - 'src'=>$conf->global->$source, - 'name'=>$conf->global->$name, + 'src' => getDolGlobalString($source), + 'name' => getDolGlobalString($name), 'offsettz' => (!empty($conf->global->$offsettz) ? $conf->global->$offsettz : 0), - 'color'=>$conf->global->$color, - 'default'=>$conf->global->$default, - 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0) + 'color' => getDolGlobalString($color), + 'default' => getDolGlobalString($default), + 'buggedfile' => (isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0) ); } } @@ -302,12 +302,12 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { if (!empty($user->conf->$source) && !empty($user->conf->$name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' $listofextcals[] = array( - 'src'=>$user->conf->$source, - 'name'=>$user->conf->$name, + 'src' => $user->conf->$source, + 'name' => $user->conf->$name, 'offsettz' => (!empty($user->conf->$offsettz) ? $user->conf->$offsettz : 0), - 'color'=>$user->conf->$color, - 'default'=>$user->conf->$default, - 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0) + 'color' => $user->conf->$color, + 'default' => $user->conf->$default, + 'buggedfile' => (isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0) ); } } @@ -397,7 +397,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { if ($resourceid > 0) { $param .= "&search_resourceid=".urlencode($resourceid); } -if ($status || GETPOSTISSET('status')) { +if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); } if ($filter) { @@ -622,7 +622,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= '
 
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { $s .= $hookmanager->resPrint; @@ -1213,7 +1213,7 @@ if (count($listofextcals)) { $addevent = true; } elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) $datestart = $icalevent['DTSTART']; - $dateend = $icalevent['DTEND']; + $dateend = empty($icalevent['DTEND']) ? $datestart : $icalevent['DTEND']; $datestart += +($offsettz * 3600); $dateend += +($offsettz * 3600); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index eee8baa2b20..9869bd2d305 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -93,15 +93,15 @@ if (empty($user->rights->agenda->allactions->read) || $filter == 'mine') { // I } $mode = 'show_pertype'; -$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); -$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); -$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); -$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); -$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); -$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); -$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); -$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$resourceid = GETPOST("search_resourceid", "int") ? GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); +$year = GETPOST("year", "int") ? GETPOST("year", "int") : date("Y"); +$month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m"); +$week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W"); +$day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d"); +$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); +$maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { @@ -144,7 +144,7 @@ $tmparray = explode('-', $tmp); $begin_d = 1; $end_d = 53; -if ($status == '' && !GETPOSTISSET('status')) { +if ($status == '' && !GETPOSTISSET('search_status')) { $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { @@ -164,6 +164,8 @@ if (GETPOST('viewyear', 'alpha') || $mode == 'show_year') { $mode = 'show_year'; } // View by year +$object = new ActionComm($db); + // Load translation files required by the page $langs->loadLangs(array('users', 'agenda', 'other', 'commercial')); @@ -175,6 +177,8 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } +$search_status = $status; + /* * Actions @@ -276,7 +280,7 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { if ($resourceid > 0) { $param .= "&search_resourceid=".urlencode($resourceid); } -if ($status || GETPOSTISSET('status')) { +if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); } if ($filter) { @@ -402,7 +406,7 @@ if ($conf->use_javascript_ajax) { //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { $s .= $hookmanager->resPrint; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 957ccd6e361..68c9088815d 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -98,9 +98,9 @@ $year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); -$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); -$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); +$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) @@ -153,9 +153,10 @@ if ($end_d < $begin_d) { $end_d = $begin_d + 1; } -if ($status == '' && !GETPOSTISSET('status')) { +if ($status == '' && !GETPOSTISSET('search_status')) { $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } + if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); } @@ -170,6 +171,8 @@ if (GETPOST('viewday', 'alpha') || $mode == 'show_day') { $mode = 'show_day'; $day = ($day ? $day : date("d")); } // View by day +$object = new ActionComm($db); + // Load translation files required by the page $langs->loadLangs(array('users', 'agenda', 'other', 'commercial')); @@ -181,6 +184,8 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } +$search_status = $status; + /* * Actions @@ -282,7 +287,8 @@ if ($actioncode || GETPOSTISSET('search_actioncode')) { if ($resourceid > 0) { $param .= "&search_resourceid=".urlencode($resourceid); } -if ($status || GETPOSTISSET('status')) { + +if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { $param .= "&search_status=".urlencode($status); } if ($filter) { @@ -412,7 +418,7 @@ if ($conf->use_javascript_ajax) { //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { $s .= $hookmanager->resPrint; @@ -509,9 +515,7 @@ $s = $newtitle; print $s; print '
'; -if (empty($search_status)) { - $search_status = ''; -} + print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f6989d90d59..e89f30ce60a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -831,6 +831,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; @@ -1579,19 +1586,19 @@ if ($action == 'create') { print '
'; - print $langs->trans("Miscelaneous"); - print ''; - print '
' . $langs->trans("DefaultMaxSizeList") . ' 
' . $langs->trans("DefaultMaxSizeShortList") . ' 
'.$langs->trans("showInputBorder").''; print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1); print ' 
' . $langs->trans("WeekStartOnDay") . ''; print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : '1'), 'MAIN_START_WEEK', 0); print ' 
' . $langs->trans("DefaultWorkingDays") . ''; print ''; print ' 
' . $langs->trans("DefaultWorkingHours") . ''; print ''; print ' 
 
 
 
'.$langs->trans("HideVersionLink").''; print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1); print ' 
' . $langs->trans("ShowQuickAddLink") . ''; + print ajax_constantonoff("MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); + print '
'; print $form->textwithpicto($langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")), $langs->trans("ShowBugTrackLinkDesc")); print ''; print ''; print ' 
 
' . $langs->trans("DisableJavascript") . ''; + print '
' . $form->textwithpicto($langs->trans("DisableJavascript"), $langs->trans("DisableJavascriptNote")) . ''; print ajax_constantonoff("MAIN_DISABLE_JAVASCRIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', 'other'); - print ' ' . $langs->trans("DisableJavascriptNote") . ''; - print ''; print '
  => '.$langs->trans("HashForPing").''.md5('dolibarr'.$valuetoshow).'
'.$langs->trans("TicketEmailNotificationTo").' ('.$langs->trans("Creation").')
'.$langs->trans("TicketEmailNotificationTo").''; print ''; @@ -671,7 +675,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print '
'.$langs->trans("TicketMessageMailIntroLabelAdmin").' ('.$langs->trans("Responses").')'; +print '
'.$langs->trans("TicketMessageMailIntroLabelAdmin"); print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index bb42808ebd4..10f0f8375e3 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -271,7 +271,8 @@ $recordtoshow = array(); // Search modules dirs $modulesdir = dolGetModulesDirs(); -$nbtotaloffiles = 0; +$listoffiles = array(); +$listoffilesexternalmodules = array(); // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) $i = 0; @@ -298,7 +299,10 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) { if ($result < 0) { print 'Failed to load language file '.$tmpfile.'
'."\n"; } else { - $nbtotaloffiles++; + $listoffiles[$langkey] = $tmpfile; + if (strpos($langkey, '@') !== false) { + $listoffilesexternalmodules[$langkey] = $tmpfile; + } } //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records
'."\n"; @@ -307,6 +311,8 @@ foreach ($modulesdir as $keydir => $tmpsearchdir) { $i++; } +$nbtotaloffiles = count($listoffiles); +$nbtotaloffilesexternal = count($listoffilesexternalmodules); if ($mode == 'overwrite') { print ''; @@ -358,7 +364,7 @@ if ($mode == 'overwrite') { print '
'; print ''; - print ''; + print ''; print "
'; // Reference - print ''; + print ''; // Ref customer - print ''; print ''; // Third party - print ''; - print ''; + print ''; + print ''; $shipping_method_id = 0; if ($socid > 0) { - print ''; @@ -1600,7 +1607,7 @@ if ($action == 'create') { } //$warehouse_id = $soc->warehouse_id; } else { - print ''; // Third party discounts info line - print ''; // Validaty duration - print ''; + print ''; // Terms of payment - print ''; // Mode of payment - print ''; // Bank Account if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { - print ''; } // Source / Channel - What trigger creation - print ''; // Delivery delay - print ''; @@ -1688,7 +1695,7 @@ if ($action == 'create') { if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { $shipping_method_id = $soc->shipping_method_id; } - print ''; @@ -1698,14 +1705,14 @@ if ($action == 'create') { if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - print ''; } // Delivery date (or manufacturing) - print ''; - print ''; + print ''; - print ''; + print ''; @@ -1730,18 +1737,18 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; } // Template to use by default - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; } // Public note - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; // Payment mode - print ''; - print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; + print '
'.$langs->trans('RefCustomer').''; print '
'.$langs->trans('Customer').'
'.$langs->trans('Customer').''; + print ''; print $soc->getNomUrl(1); print ''; print ''; + print ''; print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { @@ -1623,13 +1630,13 @@ if ($action == 'create') { if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "
".$langs->trans("DefaultContact").''; + print '
'.$langs->trans("DefaultContact").''; print img_picto('', 'contact'); print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, '', '', 0, 'minwidth300'); print '
'.$langs->trans('Discounts').''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts(); @@ -1641,45 +1648,45 @@ if ($action == 'create') { } // Date - print '
'.$langs->trans('DatePropal').''; + print '
'.$langs->trans('DatePropal').''; print $form->selectDate('', '', '', '', '', "addprop", 1, 1); print '
'.$langs->trans("ValidityDuration").''.img_picto('', 'clock').'  '.$langs->trans("days").'
'.$langs->trans("ValidityDuration").''.img_picto('', 'clock', 'class="paddingright"').' '.$langs->trans("days").'
'.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment'); + print '
'.$langs->trans('PaymentConditionsShort').''; + print img_picto('', 'payment', 'class="pictofixedwidth"'); $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '
'.$langs->trans('PaymentMode').''; - print img_picto('', 'bank').' '; + print '
'.$langs->trans('PaymentMode').''; + print img_picto('', 'bank', 'class="pictofixedwidth"'); $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('BankAccount').''; + print '
'.$langs->trans('Source').''; + print '
'.$langs->trans('Source').''; print img_picto('', 'question', 'class="pictofixedwidth"'); $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('AvailabilityPeriod'); + print '
'.$langs->trans('AvailabilityPeriod'); if (!empty($conf->commande->enabled)) { print ' ('.$langs->trans('AfterOrder').')'; } - print ''; - print img_picto('', 'clock').' '; + print ''; + print img_picto('', 'clock', 'class="pictofixedwidth"'); $form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('SendingMethod').''; + print '
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('Warehouse').''; + print '
'.$langs->trans('Warehouse').''; print img_picto('', 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); print '
'.$langs->trans("DeliveryDate").''; + print '
'.$langs->trans("DeliveryDate").''; if (isset($conf->global->DATE_LIVRAISON_WEEK_DELAY) && is_numeric($conf->global->DATE_LIVRAISON_WEEK_DELAY)) { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); @@ -1720,8 +1727,8 @@ if ($action == 'create') { // Project if (!empty($conf->projet->enabled)) { $langs->load("projects"); - print '
'.$langs->trans("Project").''; + print '
'.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' id).'">'; print '
'; + print '
'; print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : '')); print '
'.$langs->trans("DefaultModel").''; - print img_picto('', 'pdf').' '; + print '
'.$langs->trans("DefaultModel").''; + print img_picto('', 'pdf', 'class="pictofixedwidth"'); $liste = ModelePDFPropales::liste_modeles($db); $preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF")); print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); @@ -1749,26 +1756,26 @@ if ($action == 'create') { // Multicurrency if (!empty($conf->multicurrency->enabled)) { - print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); + print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); print '
'.$langs->trans('NotePublic').''; + print '
'.$langs->trans('NotePublic').''; $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // Private note if (empty($user->socid)) { - print '
'.$langs->trans('NotePrivate').''; + print '
'.$langs->trans('NotePrivate').''; $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null)); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); @@ -2172,9 +2179,9 @@ if ($action == 'create') { print '
'; - print ''; + print '
'; + print '
'; + print ''; if ($action != 'editmode' && $usercancreate && $caneditfield) { @@ -2193,7 +2200,7 @@ if ($action == 'create') { $langs->load('deliveries'); print ''; print ''; @@ -2224,7 +2231,7 @@ if ($action == 'create') { // Shipping Method if (!empty($conf->expedition->enabled)) { print '
'; print $langs->trans('PaymentMode'); print '
'; print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); - print ''; + print ''; print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); print '
'; - print '
'; + print ''; if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) { @@ -2246,7 +2253,7 @@ if ($action == 'create') { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - print '
'; print $langs->trans('SendingMethod'); print '
'; + print '
'; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print ''; @@ -2261,7 +2268,7 @@ if ($action == 'create') { // Origin of demand print '
'; - print ''; @@ -3479,10 +3478,9 @@ if ($action == 'create') { if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; @@ -3503,10 +3501,9 @@ if ($action == 'create') { // Remainder to pay back print ''; print ''; @@ -3516,10 +3513,9 @@ if ($action == 'create') { if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 0e682351992..bc0e80e9f69 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -228,7 +228,7 @@ if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MA if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -446,7 +446,7 @@ if (!empty($search_categ_sup) && $search_categ_supplier != '-1') { } $sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; } if (!$search_all) { @@ -829,7 +829,7 @@ if ($resql) { //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); - //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); + if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) { $langs->load('withdrawals'); $arrayofmassactions['banktransfertrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder"); @@ -837,7 +837,7 @@ if ($resql) { if ($user->rights->fournisseur->facture->supprimer) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } - if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { + if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -868,45 +868,6 @@ if ($resql) { $trackid = 'sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if ($massaction == 'createbills') { - //var_dump($_REQUEST); - print ''; - - print '
'; + print ''; if ($action != 'editdemandreason' && $usercancreate) { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 561682ba02f..0056716972b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1043,7 +1043,7 @@ if ($resql) { $moreforfilter = ''; // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1051,9 +1051,9 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $moreforfilter .= '
'; - $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $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 widthcentpercentminusx'); $moreforfilter .= '
'; } @@ -2097,7 +2097,7 @@ if ($resql) { // Note public if (!empty($arrayfields['p.note_public']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -2106,7 +2106,7 @@ if ($resql) { // Note private if (!empty($arrayfields['p.note_private']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 53b6d40d6b0..ecd647c7206 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -628,6 +628,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define remise_percent + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; @@ -1670,7 +1677,7 @@ if ($action == 'create' && $usercancreate) { // Terms of the settlement print ''; @@ -1759,10 +1766,10 @@ if ($action == 'create' && $usercancreate) { // Template to use by default print ''; print '"; @@ -1771,7 +1778,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''; print ''; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 52071b672fe..e1a08d47f3f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -302,6 +302,352 @@ if (empty($reshook)) { $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if ($massaction == 'confirm_createbills') { // Create bills from orders. + $orders = GETPOST('toselect', 'array'); + $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); + $validate_invoices = GETPOST('validate_invoices', 'int'); + + $errors = array(); + + $TFact = array(); + $TFactThird = array(); + $TFactThirdNbLines = array(); + + $nb_bills_created = 0; + $lastid= 0; + $lastref = ''; + + $db->begin(); + + foreach ($orders as $id_order) { + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) { + continue; + } + $cmd->fetch_thirdparty(); + + $objecttmp = new Facture($db); + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { + // If option "one bill per third" is set, and an invoice for this thirdparty was already created, we re-use it. + $objecttmp = $TFactThird[$cmd->socid]; + } else { + // If we want one invoice per order or if there is no first invoice yet for this thirdparty. + $objecttmp->socid = $cmd->socid; + $objecttmp->thirdparty = $cmd->thirdparty; + + $objecttmp->type = $objecttmp::TYPE_STANDARD; + $objecttmp->cond_reglement_id = !empty($cmd->cond_reglement_id) ? $cmd->cond_reglement_id : $cmd->thirdparty->cond_reglement_id; + $objecttmp->mode_reglement_id = !empty($cmd->mode_reglement_id) ? $cmd->mode_reglement_id : $cmd->thirdparty->mode_reglement_id; + + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) { + $objecttmp->ref_client = $cmd->ref_client; + } + + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($datefacture)) { + $datefacture = dol_now(); + } + + $objecttmp->date = $datefacture; + $objecttmp->origin = 'commande'; + $objecttmp->origin_id = $id_order; + + $objecttmp->array_options = $cmd->array_options; // Copy extrafields + + $res = $objecttmp->create($user); + + if ($res > 0) { + $nb_bills_created++; + $lastref = $objecttmp->ref; + $lastid = $objecttmp->id; + + $TFactThird[$cmd->socid] = $objecttmp; + $TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang + } else { + $langs->load("errors"); + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); + $error++; + } + } + + if ($objecttmp->id > 0) { + $res = $objecttmp->add_object_linked($objecttmp->origin, $id_order); + + if ($res == 0) { + $errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->errors[0]); + $error++; + } + + if (!$error) { + $lines = $cmd->lines; + if (empty($lines) && method_exists($cmd, 'fetch_lines')) { + $cmd->fetch_lines(); + $lines = $cmd->lines; + } + + $fk_parent_line = 0; + $num = count($lines); + + for ($i = 0; $i < $num; $i++) { + $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); + // If we build one invoice for several orders, we must put the ref of order on the invoice line + if (!empty($createbills_onebythird)) { + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); + } + + if ($lines[$i]->subprice < 0) { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc = $objecttmp->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); + if ($discountid > 0) { + $result = $objecttmp->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } else { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + break; + } + } else { + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + // Date start + $date_start = false; + if ($lines[$i]->date_debut_prevue) { + $date_start = $lines[$i]->date_debut_prevue; + } + if ($lines[$i]->date_debut_reel) { + $date_start = $lines[$i]->date_debut_reel; + } + if ($lines[$i]->date_start) { + $date_start = $lines[$i]->date_start; + } + //Date end + $date_end = false; + if ($lines[$i]->date_fin_prevue) { + $date_end = $lines[$i]->date_fin_prevue; + } + if ($lines[$i]->date_fin_reel) { + $date_end = $lines[$i]->date_fin_reel; + } + if ($lines[$i]->date_end) { + $date_end = $lines[$i]->date_end; + } + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; + } + + $objecttmp->context['createfromclone']; + + $rang = $lines[$i]->rang; + //there may already be rows from previous orders + if (!empty($createbills_onebythird)) + $rang = $TFactThirdNbLines[$cmd->socid]; + + $result = $objecttmp->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $rang, + $lines[$i]->special_code, + $objecttmp->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $lines[$i]->label, + $array_options, + 100, + 0, + $lines[$i]->fk_unit + ); + if ($result > 0) { + $lineid = $result; + if (!empty($createbills_onebythird)) //increment rang to keep order + $TFactThirdNbLines[$rcp->socid]++; + } else { + $lineid = 0; + $error++; + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } + } + } + + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. + + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { + $TFactThird[$cmd->socid] = $objecttmp; + } else { + $TFact[$objecttmp->id] = $objecttmp; + } + } + + // Build doc with all invoices + $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; + $toselect = array(); + + if (!$error && $validate_invoices) { + $massaction = $action = 'builddoc'; + + foreach ($TAllFact as &$objecttmp) { + $result = $objecttmp->validate($user); + if ($result <= 0) { + $error++; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + break; + } + + $id = $objecttmp->id; // For builddoc action + + // Builddoc + $donotredirect = 1; + $upload_dir = $conf->facture->dir_output; + $permissiontoadd = $user->rights->facture->creer; + + // Call action to build doc + $savobject = $object; + $object = $objecttmp; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $object = $savobject; + } + + $massaction = $action = 'confirm_createbills'; + } + + if (!$error) { + $db->commit(); + + if ($nb_bills_created == 1) { + $texttoshow = $langs->trans('BillXCreated', '{s1}'); + $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); + setEventMessages($texttoshow, null, 'mesgs'); + } else { + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + } + + // Make a redirect to avoid to bill twice if we make a refresh or back + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_orderday) { + $param .= '&search_orderday='.urlencode($search_orderday); + } + if ($search_ordermonth) { + $param .= '&search_ordermonth='.urlencode($search_ordermonth); + } + if ($search_orderyear) { + $param .= '&search_orderyear='.urlencode($search_orderyear); + } + if ($search_deliveryday) { + $param .= '&search_deliveryday='.urlencode($search_deliveryday); + } + if ($search_deliverymonth) { + $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + } + if ($search_deliveryyear) { + $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_vat != '') { + $param .= '&search_total_vat='.urlencode($search_total_vat); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($billed != '') { + $param .= '&billed='.urlencode($billed); + } + + header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); + exit; + } else { + $db->rollback(); + + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; + if (!empty($errors)) { + setEventMessages(null, $errors, 'errors'); + } else { + setEventMessages("Error", null, 'errors'); + } + $error++; + } + } } if ($action == 'validate' && $permissiontoadd) { if (GETPOST('confirm') == 'yes') { @@ -975,7 +1321,7 @@ if ($resql) { $moreforfilter = ''; // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -1944,8 +2290,8 @@ if ($resql) { // Note public if (!empty($arrayfields['c.note_public']['checked'])) { - print '
'; if (!$i) { $totalarray['nbfield']++; @@ -1954,8 +2300,8 @@ if ($resql) { // Note private if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 8ca3272dd78..495dd86f268 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -778,13 +778,14 @@ if ($action == 'create') { print ''; if ($conf->prelevement->enabled) { - print ''; + print ''; print ''; print ''; } + // TODO ICS is not used with bank transfer ! if ($conf->paymentbybanktransfer->enabled) { - print ''; + print ''; print ''; print ''; @@ -1082,12 +1083,12 @@ if ($action == 'create') { print ''; if ($conf->prelevement->enabled) { - print ''; + print ''; print ''; } if ($conf->paymentbybanktransfer->enabled) { - print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 9b9781b31a0..19b47430fad 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -587,10 +587,14 @@ foreach ($accounts as $key => $type) { // Accountancy journal if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print '"; - // Project - if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; - $langs->load('projects'); - print ''; - } - // Bank account if ($object->fk_account > 0) { print ""; } + // Project + if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { + $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; + $langs->load('projects'); + print ''; + } + // Model pdf print ""; @@ -1605,19 +1607,19 @@ if ($action == 'create') { // Lines - print ' - - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - print '
'; print $langs->trans('Source'); print ''; - print dol_escape_htmltag($obj->note_public); + print dol_string_nohtmltag($obj->note_public); print ''; - print dol_escape_htmltag($obj->note_private); + print dol_string_nohtmltag($obj->note_private); print '
'.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment'); + print img_picto('', 'payment', 'class="pictofixedwidth"'); $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print '
'.$langs->trans('DefaultModel').''; - print img_picto('', 'pdf', 'class="pictofixedwidth"'); include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); $preselected = $conf->global->COMMANDE_ADDON_PDF; + print img_picto('', 'pdf', 'class="pictofixedwidth"'); print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); print "
'.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
'; - print dol_escape_htmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_public); print ''; - print dol_escape_htmltag($obj->note_private); + print ''; + print dol_string_nohtmltag($obj->note_private); print '
'.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').''.$object->ics.'
'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').''.$object->ics_transfer.'
'.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')
'.$form->textwithpicto($langs->trans("ICS"), $langs->trans("ICS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("StandingOrder")).')').'
'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')
'.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').'
'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").''; - if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objecttmp->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + if (!empty($conf->accounting->enabled)) { + if (empty($objecttmp->fk_accountancy_journal)) { + print img_warning($langs->trans("Mandatory")); + } else { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } } else { print ''; } diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6d7f7f6010e..6300e387067 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -641,7 +641,7 @@ if (empty($reshook)) { setEventMessages($mesg, null, 'errors'); } else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice); if ($result > 0) { // Define output language and generate document @@ -1034,21 +1034,11 @@ if ($action == 'create') { // Payment mode print "
".$langs->trans("PaymentMode").""; + print img_picto('', 'payment', 'class="pictofixedwidth"'); print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1); //$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1); print "
'.$langs->trans('Project').''; - print img_picto('', 'project'); - $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); - print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; - print '
".$langs->trans('BankAccount').""; @@ -1056,10 +1046,22 @@ if ($action == 'create') { print "
'.$langs->trans('Project').''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); + print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').''; + print '
".$langs->trans('Model').""; include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = ModelePDFFactures::liste_modeles($db); + print img_picto('', 'generic', 'class="pictofixedwidth"'); print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); print "
'; + print '
'; // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a9429fbe2..0a13114fbbc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -987,6 +987,10 @@ if (empty($reshook)) { } $selectedLines = GETPOST('toselect', 'array'); + if (GETPOST('type', 'int') === '') { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + } + $db->begin(); $error = 0; @@ -1571,8 +1575,15 @@ if (empty($reshook)) { 0, 0, 0, - 0 - //,$langs->trans('Deposit') //Deprecated + 0, + '', + 0, + 100, + 0, + null, + 0, + '', + 1 ); } @@ -1739,7 +1750,10 @@ if (empty($reshook)) { $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, - $lines[$i]->fk_unit + $lines[$i]->fk_unit, + 0, + '', + 1 ); if ($result > 0) { @@ -1762,6 +1776,8 @@ if (empty($reshook)) { } } + $object->update_price(1, 'auto', 0, $mysoc); + // Now we create same links to contact than the ones found on origin object /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) @@ -1809,9 +1825,11 @@ if (empty($reshook)) { $product->fetch(GETPOST('idprod'.$i, 'int')); $startday = dol_mktime(12, 0, 0, GETPOST('date_start'.$i.'month'), GETPOST('date_start'.$i.'day'), GETPOST('date_start'.$i.'year')); $endday = dol_mktime(12, 0, 0, GETPOST('date_end'.$i.'month'), GETPOST('date_end'.$i.'day'), GETPOST('date_end'.$i.'year')); - $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); + $result = $object->addline($product->description, $product->price, price2num(GETPOST('qty'.$i), 'MS'), $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, GETPOST('idprod'.$i, 'int'), price2num(GETPOST('remise_percent'.$i), '', 2), $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit, 0, '', 1); } } + + $object->update_price(1, 'auto', 0, $mysoc); } } } @@ -1976,6 +1994,13 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); } + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { + // Define vat_rate + $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); + $remise_percent = str_replace('*', '', $remise_percent); + foreach ($object->lines as $line) { + $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice); + } } elseif ($action == 'addline' && $usercancreate) { // Add a new line $langs->load('errors'); $error = 0; @@ -3162,6 +3187,9 @@ if ($action == 'create') { $i++; } print ''; + + print ajax_combobox("fac_rec"); + // Option to reload page to retrieve customer informations. Note, this clear other input if (empty($conf->global->RELOAD_PAGE_ON_TEMPLATE_CHANGE_DISABLED)) { print ''; + if (GETPOST('mode', 'aZ09') == 'remiseforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } +} +print ''; // Fields for situation invoice if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index cf6a8220c29..187e3f5a156 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -186,6 +186,14 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->sendtoid = 0; + } elseif ($action == 'PROPAL_MODIFY') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "propal")); + + if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg = $langs->transnoentities("PropalBackToDraftInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->sendtoid = 0; } elseif ($action == 'PROPAL_SENTBYMAIL') { // Load translation files required by the page diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index 5fd339918fa..d21cdd6233f 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -73,7 +73,7 @@ class DolLogsCollector extends MessagesCollector { global $conf; - $uselogfile = getDolGlobalInt('DEBUGBAR_USE_LOGFILE'); + $uselogfile = getDolGlobalInt('DEBUGBAR_USE_LOG_FILE'); if ($uselogfile) { $this->getStorageLogs($this->path); diff --git a/htdocs/document.php b/htdocs/document.php index 7498fbb3cf6..a33708e3e77 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Pierre Morin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2022 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 @@ -163,6 +164,11 @@ if (!empty($hashp)) { $modulepart = $moduleparttocheck; $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } + $entity = $ecmfile->entity; + if ($entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); + } } else { $langs->load("errors"); accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 032ee4b534b..9f1d921691c 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -23,6 +23,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -109,10 +110,10 @@ class EmailCollector extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), - 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), - 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax150'), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'), + 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'), + 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflow125'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>91, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)'), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'), @@ -121,10 +122,10 @@ class EmailCollector extends CommonObject //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'help'=>"EmailCollectorTargetDir"), 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), - 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), + 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), - 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'csslist'=>'small'), + 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index bdd81660a12..2f0c54ef2d4 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -105,7 +105,9 @@ class ConferenceOrBoothAttendee extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"), 'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'picto'=>'agenda'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>0, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), - 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1), + 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1, 'searchall'=>1), + 'firstname' => array('type'=>'varchar(100)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), + 'lastname' => array('type'=>'varchar(100)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>32, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1, 'showoncombobox'=>'1',), 'fk_invoice' => array('type'=>'integer:Facture:compta/facture/class/facture.class.php', 'label'=>'Invoice', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>-1, 'index'=>0, 'picto'=>'bill', 'css'=>'tdoverflowmax150 maxwidth500'), @@ -126,6 +128,8 @@ class ConferenceOrBoothAttendee extends CommonObject public $fk_soc; public $fk_actioncomm; public $email; + public $firstname; + public $lastname; public $date_subscription; public $fk_invoice; public $amount; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 943205adca2..0ba93ea1c82 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -375,46 +375,52 @@ if ($projectid > 0) { print '
'; // Description - print ''; // Categories if ($conf->categorie->enabled) { - print '"; } - print '"; - print '"; - print '"; - print '"; - print '"; + + print '"; // Link to the submit vote/register page - print ''; // Link to the subscribe - 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 0d079f5dbdc..7ae586020c6 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -560,11 +560,11 @@ if ($sall) { $moreforfilter = ''; // If the user can view prospects other than his' -if ($user->rights->societe->client->voir || $socid) { +if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); $moreforfilter .= '
'; } @@ -572,7 +572,7 @@ if ($user->rights->societe->client->voir || $socid) { if ($user->rights->user->user->lire) { $moreforfilter .= '
'; $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); $moreforfilter .= $form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter .= '
'; } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c89723af2b9..c1aebe67534 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2135,7 +2135,8 @@ if ($action == 'create') { // IK if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 760c25e4db8..ab763dc8a11 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -285,7 +285,7 @@ $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."expensereport as d"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; } $sql .= ", ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php new file mode 100644 index 00000000000..f5196181cf2 --- /dev/null +++ b/htdocs/expensereport/payment/list.php @@ -0,0 +1,588 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017-2021 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 + * 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/payment/list.php +* \ingroup expensereport + * \brief Payment list for expense reports + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('expensereports', 'bills', 'banks', 'compta')); + +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist'; + +$socid = GETPOST('socid', 'int'); + +// Security check +if ($user->socid) $socid = $user->socid; + +$search_ref = GETPOST('search_ref', 'alpha'); +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_user = GETPOST('search_user', 'alpha'); +$search_payment_type = GETPOST('search_payment_type'); +$search_cheque_num = GETPOST('search_cheque_num', 'alpha'); +$search_bank_account = GETPOST('search_bank_account', 'int'); +$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x' + +$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 == -1) { + $page = 0; // If $page is not defined, or '' or -1 +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "pndf.datep"; +} + +$search_all = trim(GETPOSTISSET("search_all") ? GETPOST("search_all", 'alpha') : GETPOST('sall')); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'pndf.rowid'=>"RefPayment", + 'u.login'=>"User", + 'pndf.num_payment'=>"Numero", + 'pndf.amount'=>"Amount", +); + +$arrayfields = array( + 'pndf.rowid' =>array('label'=>"RefPayment", 'checked'=>1, 'position'=>10), + 'pndf.datep' =>array('label'=>"Date", 'checked'=>1, 'position'=>20), + 'u.login' =>array('label'=>"User", 'checked'=>1, 'position'=>30), + 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), + 'pndf.num_payment' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), + 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->banque->enabled))), + 'pndf.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), +); +$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('paymentexpensereportlist')); +$object = new PaymentExpenseReport($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($user->rights->expensereport->lire)) { + accessforbidden(); +} + + +/* + * Actions + */ + +$childids = $user->getAllChildIds(1); + +$parameters = array('socid'=>$socid); +$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)) { + 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 tests are required to be compatible with all browsers + $search_ref = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_user = ''; + $search_payment_type = ''; + $search_cheque_num = ''; + $search_bank_account = ''; + $search_amount = ''; + } +} + +/* + * View + */ + +llxHeader('', $langs->trans('ListPayment')); + +$form = new Form($db); +$formother = new FormOther($db); +$accountstatic = new Account($db); +$userstatic = new User($db); +$paymentexpensereportstatic = new PaymentExpenseReport($db); + +$sql = 'SELECT pndf.rowid, pndf.rowid as ref, pndf.datep, pndf.amount as pamount, pndf.num_payment'; +$sql .= ', u.rowid as userid, u.login, u.lastname, u.firstname'; +$sql .= ', c.code as paiement_type, c.libelle as paiement_libelle'; +$sql .= ', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal'; +$sql .= ', SUM(pndf.amount)'; + +$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport AS pndf'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport AS ndf ON ndf.rowid=pndf.fk_expensereport'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON pndf.fk_typepayment = c.id'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON u.rowid = ndf.fk_user_author'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON pndf.fk_bank = b.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + +$sql .= ' WHERE ndf.entity IN ('.getEntity("expensereport").')'; + +// 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 ndf.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n"; +} + +if ($search_ref) { + $sql .= natural_search('pndf.rowid', $search_ref); +} +if ($search_date_start) { + $sql .= " AND pndf.datep >= '" . $db->idate($search_date_start) . "'"; +} +if ($search_date_end) { + $sql .=" AND pndf.datep <= '" . $db->idate($search_date_end) . "'"; +} + +if ($search_user) { + $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); +} +if ($search_payment_type != '') { + $sql .= " AND c.code='".$db->escape($search_payment_type)."'"; +} +if ($search_cheque_num != '') { + $sql .= natural_search('pndf.num_payment', $search_cheque_num); +} +if ($search_amount) { + $sql .= natural_search('pndf.amount', $search_amount, 1); +} +if ($search_bank_account > 0) { + $sql .= ' AND b.fk_account = '.((int) $search_bank_account); +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +} + +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +$sql .= ' GROUP BY pndf.rowid, pndf.datep, pndf.amount, pndf.num_payment, u.login, u.lastname, u.firstname, c.code, c.libelle,'; +$sql .= ' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal'; + +$sql .= $db->order($sortfield, $sortorder); + +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); + +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + llxFooter(); + $db->close(); + exit; +} + +$num = $db->num_rows($resql); +$i = 0; + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} + +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); +} +if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); +} +if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); +} +if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); +} +if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); +} +if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); +} +if ($search_user) { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_payment_type) { + $param .= '&search_payment_type='.urlencode($search_payment_type); +} +if ($search_cheque_num) { + $param .= '&search_cheque_num='.urlencode($search_cheque_num); +} +if ($search_amount) { + $param .= '&search_amount='.urlencode($search_amount); +} + +if ($search_bank_account) { + $param .= '&search_bank_account='.urlencode($search_bank_account); +} + +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +print ''; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, '', '', $limit, 0, 0, 1); + +if ($search_all) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if ($moreforfilter) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if (!empty($massactionbutton)) { + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +} + +print '
'; +print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("Description").''; print nl2br($project->description); print '
'.$langs->trans("Categories").''; + print '
'.$langs->trans("Categories").''; print $form->showCategories($project->id, Categorie::TYPE_PROJECT, 1); 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 ''; 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 ''; print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; + print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid'); - print ''; + print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; + print '
'; + print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $project, $permissiontoadd, 'integer:3', '', 0, 0, 'projectid'); + print ''; + print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid'); + print "
'.$langs->trans("EventOrganizationICSLink").''; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; @@ -427,11 +433,11 @@ if ($projectid > 0) { print "
'; + print '
'; //print ''; print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage")); //print ''; - print ''; + print ''; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $project->id); $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); @@ -444,11 +450,11 @@ if ($projectid > 0) { print '
'; + print '
'; //print ''; print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; - print ''; + print ''; $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $project->id).'&type=global'; $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index ab2699187b2..be24d7b6797 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -278,7 +278,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($confOrBooth->id)) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".((int) $confOrBooth->id); } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } // Add table from hooks @@ -828,7 +828,7 @@ print '
'; - print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + $exp_tax_cat_label = dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + print $langs->trans($exp_tax_cat_label); print '
'; + +print ''; + +// Filter: Ref +if (!empty($arrayfields['pndf.rowid']['checked'])) { + print ''; +} + +// Filter: Date +if (!empty($arrayfields['pndf.datep']['checked'])) { + print ''; +} + +// Filter: Thirdparty +if (!empty($arrayfields['u.login']['checked'])) { + print ''; +} + +// Filter: Payment type +if (!empty($arrayfields['c.libelle']['checked'])) { + print ''; +} + +// Filter: Cheque number (fund transfer) +if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print ''; +} + +// Filter: Bank account +if (!empty($arrayfields['ba.label']['checked'])) { + print ''; +} + +// Filter: Amount +if (!empty($arrayfields['pndf.amount']['checked'])) { + print ''; +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Buttons +print ''; + +print ''; + +print ''; +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.rowid']['checked'])) { + print_liste_field_titre($arrayfields['pndf.rowid']['label'], $_SERVER["PHP_SELF"], 'pndf.rowid', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.datep']['checked'])) { + print_liste_field_titre($arrayfields['pndf.datep']['label'], $_SERVER["PHP_SELF"], 'pndf.datep', '', $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.lastname', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['c.libelle']['checked'])) { + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], 'c.libelle', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print_liste_field_titre($arrayfields['pndf.num_payment']['label'], $_SERVER["PHP_SELF"], "pndf.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pndf.num_payment']['tooltip']); +} +if (!empty($arrayfields['ba.label']['checked'])) { + print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); +} +if (!empty($arrayfields['pndf.amount']['checked'])) { + print_liste_field_titre($arrayfields['pndf.amount']['label'], $_SERVER["PHP_SELF"], 'pndf.amount', '', $param, '', $sortfield, $sortorder, 'right '); +} + +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +print ''; + +$checkedCount = 0; +foreach ($arrayfields as $column) { + if ($column['checked']) { + $checkedCount++; + } +} + +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) { + $objp = $db->fetch_object($resql); + + $paymentexpensereportstatic->id = $objp->rowid; + $paymentexpensereportstatic->ref = $objp->ref; + $paymentexpensereportstatic->datepaye = $objp->datep; + + $userstatic->id = $objp->userid; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + + print ''; + + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['pndf.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['pndf.datep']['checked'])) { + $dateformatforpayment = 'dayhour'; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Pyament type + if (!empty($arrayfields['c.libelle']['checked'])) { + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Cheque number (fund transfer) + if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank account + if (!empty($arrayfields['ba.label']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount + if (!empty($arrayfields['pndf.amount']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + $totalarray['pos'][$checkedCount] = 'amount'; + $totalarray['val']['amount'] += $objp->pamount; + } + + // Buttons + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + + print ''; + $i++; +} + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +print '
'; + print ''; + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + $form->select_types_paiements($search_payment_type, 'search_payment_type', '', 2, 1, 1); + print ''; + print ''; + print ''; + $form->select_comptes($search_bank_account, 'search_bank_account', 0, '', 1); + print ''; + print ''; + print ''; +print $form->showFilterAndCheckAddButtons(0); +print '
'.(($offset * $limit) + $i).''.$paymentexpensereportstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(1); + } + print ''.$payment_type.' '.dol_trunc($objp->num_payment, 32).''.$objp->num_payment.''; + if ($objp->bid) { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->iban = $objp->iban_prefix; + $accountstatic->bic = $objp->bic; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''.price($objp->pamount).'
'; +print ''; +print ''; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index ee2bf9269ce..b5e3a13f3c0 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -426,7 +426,7 @@ class Fichinter extends CommonObject $sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql .= " f.date_valid as datev,"; $sql .= " f.tms as datem,"; - $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; + $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat, f.entity as entity"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) { $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; @@ -459,6 +459,7 @@ class Fichinter extends CommonObject $this->model_pdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_contrat = $obj->fk_contrat; + $this->entity = $obj->entity; $this->user_creation = $obj->fk_user_author; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 46a9f2eee3f..9ec00d62b8e 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -149,7 +149,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -246,7 +246,7 @@ if (!empty($conf->projet->enabled)) { if (!empty($conf->contrat->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid"; } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)"; } if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3ddb1350a8b..98df5e11170 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1195,7 +1195,7 @@ if ($resql) { $moreforfilter = ''; // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 7e5746bf9bb..0aa8eb93d9d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1904,7 +1904,7 @@ if ($action == 'create') { $currency_code = $conf->currency; $societe = ''; - if (GETPOST('socid') > 0) { + if (GETPOST('socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) { @@ -3466,10 +3466,9 @@ if ($action == 'create') { // Remainder to pay print '
'; print ''; - if ($resteapayeraffiche >= 0) { - print $langs->trans('RemainderToPay'); - } else { - print $langs->trans('ExcessPaid'); + print $langs->trans('RemainderToPay'); + if ($resteapayeraffiche < 0) { + print ' ('.$langs->trans('NegativeIfExcessPaid').')'; } print ''; print '
'; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBackMulticurrency'); - } else { - print $langs->trans('ExcessPaidMulticurrency'); + print $langs->trans('RemainderToPayMulticurrency'); + if ($resteapayeraffiche < 0) { + print ' ('.$langs->trans('NegativeIfExcessPaid').')'; } print ''; print '
'; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBack'); - } else { - print $langs->trans('ExcessPaid'); + print $langs->trans('RemainderToPayBack'); + if ($resteapayeraffiche > 0) { + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } print '
'; print ''; - if ($resteapayeraffiche <= 0) { - print $langs->trans('RemainderToPayBackMulticurrency'); - } else { - print $langs->trans('ExcessPaidMulticurrency'); + print $langs->trans('RemainderToPayBackMulticurrency'); + if ($resteapayeraffiche> 0) { + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } print ''; print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans('DateInvoice'); - print ''; - print $form->selectDate('', '', '', '', '', '', 1, 1); - print '
'; - print $langs->trans('CreateOneBillByThird'); - print ''; - print $form->selectyesno('createbills_onebythird', '', 1); - print '
'; - print $langs->trans('ValidateInvoices'); - print ''; - print $form->selectyesno('validate_invoices', 1, 1); - print '
'; - - print '
'; - print '
'; - print ' '; - print ''; - print '
'; - print '
'; - } - if ($search_all) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); @@ -916,15 +877,15 @@ if ($resql) { // If the user can view prospects other than his' $moreforfilter = ''; - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'company', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth200'); + $moreforfilter .= img_picto($tmptitle, 'user', '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) { + if ($user->rights->user->user->lire) { $moreforfilter .= '
'; $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'); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index bcae536f720..efafac7f823 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -304,7 +304,7 @@ $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."holiday as cp"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)"; } $sql .= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 33c000e4475..16d8a919dbe 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -615,12 +615,13 @@ jQuery(document).ready(function() { function init_needroot() { + console.log("init_needroot force_install_noedit="); /*alert(jQuery("#db_create_database").prop("checked")); */ if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked")) { jQuery(".hideroot").show(); + if (empty($force_install_noedit)) { ?> jQuery(".needroot").removeAttr('disabled'); } diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql index 9b5d1ca5e32..b98db76b48e 100644 --- a/htdocs/install/mysql/data/llx_c_availability.sql +++ b/htdocs/install/mysql/data/llx_c_availability.sql @@ -1,6 +1,8 @@ -- Copyright (C) 2011 Philippe GRAND -- Copyright (C) 2020 Alexandre SPANGARO +-- Copyright (C) 2022 Udo Tamm, dolibit -- + -- 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 @@ -16,7 +18,12 @@ -- -- +-- WARNING +-- Do not place a comment at the end of the line, this file is parsed during +-- installation and all '--' symbols are removed. -- + +-- ATTENTION -- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors -- de l'install et tous les sigles '--' sont supprimés. -- @@ -25,9 +32,15 @@ -- Availability type -- -INSERT INTO llx_c_availability (code,label,type_duration,qty,active,position) VALUES ('AV_NOW', 'Immediate', null, 0, 1, 10); -INSERT INTO llx_c_availability (code,label,type_duration,qty,active,position) VALUES ('AV_1W', '1 week', 'w', 1, 1, 20); -INSERT INTO llx_c_availability (code,label,type_duration,qty,active,position) VALUES ('AV_2W', '2 weeks', 'w', 2, 1, 30); -INSERT INTO llx_c_availability (code,label,type_duration,qty,active,position) VALUES ('AV_3W', '3 weeks', 'w', 3, 1, 40); -INSERT INTO llx_c_availability (code,label,type_duration,qty,active,position) VALUES ('AV_4W', '4 weeks', 'w', 4, 1, 50); - +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_NOW', 'Immediate', null, 0, 1, 10); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_1W', '1 week', 'w', 1, 1, 20); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_2W', '2 weeks', 'w', 2, 1, 30); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_3W', '3 weeks', 'w', 3, 1, 40); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_4W', '4 weeks', 'w', 4, 1, 50); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_5W', '5 weeks', 'w', 5, 1, 60); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_6W', '6 weeks', 'w', 6, 1, 70); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_8W', '8 weeks', 'w', 8, 1, 80); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_10W', '10 weeks', 'w', 10, 1, 90); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_12W', '12 weeks', 'w', 12, 1, 100); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_14W', '14 weeks', 'w', 14, 1, 110); +INSERT INTO llx_c_availability (code, label, type_duration, qty, active, position) VALUES ('AV_16W', '16 weeks', 'w', 16, 1, 120); diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 4b34d3a72ac..bef32bc7fe7 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -36,7 +36,8 @@ -- VPGSQL8.2 ALTER TABLE llx_partnership ALTER COLUMN date_partnership_end DROP NOT NULL; ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging real DEFAULT NULL; -ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL; +-- VMYSQL4.3 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL USING packaging::real; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL; @@ -119,8 +120,8 @@ ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; ALTER TABLE llx_holiday ADD COLUMN date_approve DATETIME DEFAULT NULL; ALTER TABLE llx_holiday ADD COLUMN fk_user_approve integer DEFAULT NULL; -ALTER TABLE llx_ticket MODIFY COLUMN progress integer; - +-- VMYSQL4.3 ALTER TABLE llx_ticket MODIFY COLUMN progress integer; +-- VPGSQL8.2 ALTER TABLE llx_ticket MODIFY COLUMN progress integer USING progress::integer; ALTER TABLE llx_emailcollector_emailcollectoraction MODIFY COLUMN actionparam TEXT; diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 02d291feba6..89b6ff838c4 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -97,6 +97,12 @@ ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_soc (fk_type, fk_soc, ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_member (fk_type, fk_member, date_partnership_start); +-- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. +-- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer +-- into accounting will use it in priority if value is not null. The script repair.sql contains the sequence to fix datas in llx_bank. +ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; + + -- v16 UPDATE llx_cronjob set label = 'RecurringInvoicesJob' where label = 'RecurringInvoices'; @@ -328,9 +334,14 @@ ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext; DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); - ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); +ALTER TABLE llx_partnership ADD COLUMN url_to_check varchar(255); +ALTER TABLE llx_c_partnership_type ADD COLUMN keyword varchar(128); + +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN firstname varchar(100); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN lastname varchar(100); +ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN email_company varchar(128) after email; -- Stock transfers module diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 070f3a2c5da..4add688b880 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -559,6 +559,13 @@ DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; -- Sequence to fix the content of llx_bank.amount_main_currency +-- Note: amount is amount in currency of bank account +-- Note: pamount is always amount into the main currency +-- Note: pmulticurrencyamount is in currency of invoice +-- Note: amount_main_currency must be amount in main currency -- DROP TABLE tmp_bank; -- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; -- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; +-- DROP TABLE tmp_bank2; +-- CREATE TABLE tmp_bank2 SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment_supplier' INNER JOIN llx_paiementfourn as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; +-- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank2 as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_c_partnership_type.key.sql rename to htdocs/install/mysql/tables/llx_c_partnership_type-partnership.key.sql diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.sql b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql similarity index 92% rename from htdocs/install/mysql/tables/llx_c_partnership_type.sql rename to htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql index 99841f967cb..fe4dd904662 100644 --- a/htdocs/install/mysql/tables/llx_c_partnership_type.sql +++ b/htdocs/install/mysql/tables/llx_c_partnership_type-partnership.sql @@ -31,6 +31,7 @@ create table llx_c_partnership_type entity integer DEFAULT 1 NOT NULL, code varchar(32) NOT NULL, label varchar(128) NOT NULL, + keyword varchar(128), -- a keyword to check into url of partner website or a dedicated url defined into partneship record active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql index d6139f48f21..973c738a076 100644 --- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql +++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql @@ -1,4 +1,4 @@ --- Copyright (C) ---Put here your own copyright and developer email--- +-- Copyright (C) 2021-2022 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 @@ -22,7 +22,10 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee( fk_actioncomm integer, fk_project integer NOT NULL, fk_invoice integer NULL, - email varchar(100), + email varchar(128), + email_company varchar(128), + firstname varchar(100), + lastname varchar(100), date_subscription datetime, amount double DEFAULT NULL, note_public text, diff --git a/htdocs/install/mysql/tables/llx_partnership-partnership.sql b/htdocs/install/mysql/tables/llx_partnership-partnership.sql index e3a5cb37e05..8f83e2e82e5 100644 --- a/htdocs/install/mysql/tables/llx_partnership-partnership.sql +++ b/htdocs/install/mysql/tables/llx_partnership-partnership.sql @@ -34,8 +34,9 @@ CREATE TABLE llx_partnership( note_private text, note_public text, last_main_doc varchar(255), - count_last_url_check_error integer DEFAULT '0', - last_check_backlink datetime NULL, + url_to_check varchar(255), -- url to check to find a specific keyword (defined into llx_c_partnership) to keep status of partnership valid + count_last_url_check_error integer DEFAULT '0', -- last result of check of keyword into url + last_check_backlink datetime NULL, -- date of last check of keyword into url import_key varchar(14), model_pdf varchar(255) ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql new file mode 100644 index 00000000000..04a0dbb306a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.key.sql @@ -0,0 +1,27 @@ +-- 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_webhook_target ADD INDEX idx_webhook_target_rowid (rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_ref (ref); +ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_webhook_target ADD INDEX idx_webhook_target_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_webhook_target ADD UNIQUE INDEX uk_webhook_target_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_webhook_target ADD CONSTRAINT llx_webhook_target_fk_field FOREIGN KEY (fk_field) REFERENCES llx_webhook_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql new file mode 100644 index 00000000000..1e0cc0fdbac --- /dev/null +++ b/htdocs/install/mysql/tables/llx_webhook_target-webhook.sql @@ -0,0 +1,34 @@ +-- 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_webhook_target( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer DEFAULT 0 NOT NULL, + url varchar(255) NOT NULL, + trigger_codes text NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website-website.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_website.sql rename to htdocs/install/mysql/tables/llx_website-website.sql diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index c769b89f9b8..e801416d63d 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -23,7 +23,8 @@ */ -/** Terms +/** + * Terms * * DEB = Declaration d'Exchanges de Biens (FR) = Declaration of Exchange of Goods (EN) * DES = Déclaration Européenne de Services (FR) = European Declaration of Services (EN) @@ -32,7 +33,6 @@ * */ - require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php $langs->loadLangs(array("intracommreport")); +$id = GETPOST('id', 'int'); $action = GETPOST('action'); $exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB or DES $year = GETPOSTINT('year'); @@ -65,9 +66,13 @@ $formother = new FormOther($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('intracommcard', 'globalcard')); +$error = 0; + + /* * Actions */ + $parameters = array('id' => $id); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -132,6 +137,7 @@ if ($action == 'add' && $user->rights->intracommreport->write) { } } + /* * View */ @@ -151,7 +157,7 @@ if ($action == 'create') { print ''; // Label - print ''; + print ''; // Declaration print ''; print ''; print ''; diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index fa88f6f0456..b6bfd45c91a 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -125,7 +125,7 @@ $arrayfields = array( ); /* // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -217,7 +217,7 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'intracommreport as i'; -// if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."intracommreport_extrafields as ef on (i.rowid = ef.fk_object)"; +// if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."intracommreport_extrafields as ef on (i.rowid = ef.fk_object)"; $sql .= ' WHERE i.entity IN ('.getEntity('intracommreport').')'; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index fd5ff8461fe..8283da55f41 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -278,10 +278,10 @@ DescVentilExpenseReportMore=If you setup accounting account on type of expense r DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account Closure=Annual closure -DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open -OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) -AllMovementsWereRecordedAsValidated=All movements were recorded as validated -NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated +DescClosure=Consult here the number of movements by month who are not yet validated & locked +OverviewOfMovementsNotValidated=Overview of movements not validated and locked +AllMovementsWereRecordedAsValidated=All movements were recorded as validated and locked +NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated and locked ValidateMovements=Validate and lock record... DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible @@ -302,6 +302,7 @@ NotYetAccounted=Not yet transferred to accounting ShowTutorial=Show Tutorial NotReconciled=Not reconciled WarningRecordWithoutSubledgerAreExcluded=Warning, all lines without subledger account defined are filtered and excluded from this view +AccountRemovedFromCurrentChartOfAccount=Accounting account that does not exist in the current chart of accounts ## Admin BindingOptions=Binding options @@ -395,6 +396,21 @@ Range=Range of accounting account Calculated=Calculated Formula=Formula +## Reconcile +Unlettering=Unreconcile +AccountancyNoLetteringModified=No reconcile modified +AccountancyOneLetteringModifiedSuccessfully=One reconcile successfully modified +AccountancyLetteringModifiedSuccessfully=%s reconcile successfully modified +AccountancyNoUnletteringModified=No unreconcile modified +AccountancyOneUnletteringModifiedSuccessfully=One unreconcile successfully modified +AccountancyUnletteringModifiedSuccessfully=%s unreconcile successfully modified + +## Confirm box +ConfirmMassUnlettering=Bulk Unreconcile confirmation +ConfirmMassUnletteringQuestion=Are you sure you want to Unreconcile the %s selected record(s)? +ConfirmMassDeleteBookkeepingWriting=Bulk Delete confirmation +ConfirmMassDeleteBookkeepingWritingQuestion=This will delete the transaction from the accounting (all lines related to the same transaction will be deleted) Are you sure you want to delete the %s selected record(s)? + ## Error SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) @@ -407,6 +423,9 @@ Binded=Lines bound ToBind=Lines to bind UseMenuToSetBindindManualy=Lines not yet bound, use menu %s to make the binding manually SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices=Sorry this module is not compatible with the experimental feature of situation invoices +AccountancyErrorMismatchLetterCode=Mismatch in reconcile code +AccountancyErrorMismatchBalanceAmount=The balance (%s) is not equal to 0 +AccountancyErrorLetteringBookkeeping=Errors have occurred concerning the transactions: %s ## Import ImportAccountingEntries=Accounting entries diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1dc7d4e2092..69dfc6bd478 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1345,6 +1345,7 @@ TransKeyWithoutOriginalValue=You forced a new translation for the translation ke TitleNumberOfActivatedModules=Activated modules TotalNumberOfActivatedModules=Activated modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module +YouMustEnableTranslationOverwriteBefore=You must first enable translation overwriting to be allowed to replace a translation ClassNotFoundIntoPathWarning=Class %s not found in PHP path YesInSummer=Yes in summer OnlyFollowingModulesAreOpenedToExternalUsers=Note, only the following modules are available to external users (irrespective of the permissions of such users) and only if permissions are granted:
@@ -1925,7 +1926,7 @@ ConfFileMustContainCustom=Installing or building an external module from applica HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (use 'ffffff' for no highlight) HighlightLinesChecked=Highlight color of the line when it is checked (use 'ffffff' for no highlight) -UseBorderOnTable=Active border on tables +UseBorderOnTable=Show left-right borders on tables BtnActionColor=Color of the action button TextBtnActionColor=Text color of the action button TextTitleColor=Text color of Page title @@ -2066,12 +2067,24 @@ EmailcollectorOperations=Operations to do by collector EmailcollectorOperationsDesc=Operations are executed from top to bottom order MaxEmailCollectPerCollect=Max number of emails collected per collect CollectNow=Collect now -ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ? +ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s? DateLastCollectResult=Date of latest collect try DateLastcollectResultOk=Date of latest collect success LastResult=Latest result +EmailCollectorHideMailHeaders=Do not include the content of email header into the saved content of collected e-mails +EmailCollectorHideMailHeadersHelp=When enabled, e-mail headers are not added at the end of the email content that is saved as events. EmailCollectorConfirmCollectTitle=Email collect confirmation -EmailCollectorConfirmCollect=Do you want to run the collection for this collector now ? +EmailCollectorConfirmCollect=Do you want to run this collector now? +EmailCollectorExampleToCollectTicketRequestsDesc=Collect emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. Activate also Collect_Responses to collect answers of your client directly on the ticket view (you must reply from Dolibarr). +EmailCollectorExampleToCollectTicketRequests=Example collecting the ticket request (first message only) +EmailCollectorExampleToCollectAnswersFromExternalEmailSoftwareDesc=Scan your mailbox "Sent" directory to find emails that was sent as an answer of another email directly from your email software and not from Dolibarr. If such an email is found, the event of answer is recorded into Dolibarr +EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware=Example collecting e-mail answers sent from an external e-mail software +EmailCollectorExampleToCollectDolibarrAnswersDesc=Collect all emails that are an answer of an email sent from your application. An event (Module Agenda must be enabled) with the email response will be recorded at the good place. For example, if your send a commercial proposal, order, invoice or message for a ticket by email from the application, and your customer answers your email, the system will automatically catch the answer and add it into your ERP. +EmailCollectorExampleToCollectDolibarrAnswers=Example collecting all ingoing messages being answers to messages sent from Dolibarr' +EmailCollectorExampleToCollectLeadsDesc=Collect emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.
Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1. +EmailCollectorExampleToCollectLeads=Example collecting leads +EmailCollectorExampleToCollectJobCandidaturesDesc=Collect emails applying to job offers (Module Recruitment must be enabled). You can complete this collector if you want to automatically create a candidature for a job request. Note: With this initial example, the title of the candidature is generated including the email. +EmailCollectorExampleToCollectJobCandidatures=Example collecting job candidatures received by e-mail NoNewEmailToProcess=No new email (matching filters) to process NothingProcessed=Nothing done XEmailsDoneYActionsDone=%s emails qualified, %s emails successfully processed (for %s record/actions done) @@ -2143,7 +2156,7 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined -RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. +RESTRICT_ON_IP=Allow API access to only certain client IPs (wildcard not allowed, use space between values). Empty means every clients can access. IPListExample=127.0.0.1 192.168.0.2 [::1] BaseOnSabeDavVersion=Based on the library SabreDAV version NotAPublicIp=Not a public IP @@ -2234,3 +2247,8 @@ TemplateforBusinessCards=Template for a business card in different size InventorySetup= Inventory Setup ExportUseLowMemoryMode=Use a low memory mode ExportUseLowMemoryModeHelp=Use the low memory mode to execute the exec of the dump (compression is done through a pipe instead of into the PHP memory). This method does not allow to check that file is completed and error message can't be reported if it fails. +ShowQuickAddLink=Show a button to quickly add an element in top right menu +HashForPing=Hash used for ping +ReadOnlyMode=Is instance in "Read Only" mode +DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log file to trap Logs +UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended. diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index bc9c7dab537..272ec22df5c 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -45,6 +45,7 @@ CONTRACT_DELETEInDolibarr=Contract %s deleted PropalClosedSignedInDolibarr=Proposal %s signed PropalClosedRefusedInDolibarr=Proposal %s refused PropalValidatedInDolibarr=Proposal %s validated +PropalBackToDraftInDolibarr=Proposal %s go back to draft status PropalClassifiedBilledInDolibarr=Proposal %s classified billed InvoiceValidatedInDolibarr=Invoice %s validated InvoiceValidatedInDolibarrFromPos=Invoice %s validated from POS @@ -66,6 +67,7 @@ ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status ShipmentDeletedInDolibarr=Shipment %s deleted ShipmentCanceledInDolibarr=Shipment %s canceled ReceptionValidatedInDolibarr=Reception %s validated +ReceptionClassifyClosedInDolibarr=Reception %s classified closed OrderCreatedInDolibarr=Order %s created OrderValidatedInDolibarr=Order %s validated OrderDeliveredInDolibarr=Order %s classified delivered diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 9cd52930714..858e0937788 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -165,4 +165,5 @@ EmailAttendee=Attendee email EmailCompanyForInvoice=Company email (for invoice, if different of attendee email) ErrorSeveralCompaniesWithEmailContactUs=Several companies with this email has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation ErrorSeveralCompaniesWithNameContactUs=Several companies with this name has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation -NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event \ No newline at end of file +NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event +MaxNbOfAttendees=Max number of attendees diff --git a/htdocs/langs/en_US/expensereports.lang b/htdocs/langs/en_US/expensereports.lang new file mode 100644 index 00000000000..624a278b393 --- /dev/null +++ b/htdocs/langs/en_US/expensereports.lang @@ -0,0 +1 @@ +ExpenseReportPayments=Expense report payments diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b39124c7c53..530f3b6af0e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -621,6 +621,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Attached files and documents JoinMainDoc=Join main document +JoinMainDocOrLastGenerated=Send the main document or the last generated one if not found DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS @@ -1172,4 +1173,4 @@ AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? CommercialsAffected=Sales representatives affected -CommercialAffected=Sales representative affected \ No newline at end of file +CommercialAffected=Sales representative affected diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 8646c40b98f..faa2e0d0fcd 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -15,7 +15,7 @@ ErrorMemberIsAlreadyLinkedToThisThirdParty=Another member (name: %s, logi ErrorUserPermissionAllowsToLinksToItselfOnly=For security reasons, you must be granted permissions to edit all users to be able to link a member to a user that is not yours. SetLinkToUser=Link to a Dolibarr user SetLinkToThirdParty=Link to a Dolibarr third party -MembersCards=Business cards for members +MembersCards=Generation of cards for members MembersList=List of members MembersListToValid=List of draft members (to be validated) MembersListValid=List of valid members @@ -163,7 +163,7 @@ MoreActionsOnSubscription=Complementary action suggested by default when recordi MoreActionBankDirect=Create a direct entry on bank account MoreActionBankViaInvoice=Create an invoice, and a payment on bank account MoreActionInvoiceOnly=Create an invoice with no payment -LinkToGeneratedPages=Generate visit cards +LinkToGeneratedPages=Generation of business cards or address sheets LinkToGeneratedPagesDesc=This screen allows you to generate PDF files with business cards for all your members or a particular member. DocForAllMembersCards=Generate business cards for all members DocForOneMemberCards=Generate business cards for a particular member diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index df0a834e04f..416ff013219 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -52,7 +52,7 @@ LanguageFile=File for language ObjectProperties=Object Properties ConfirmDeleteProperty=Are you sure you want to delete the property %s? This will change code in PHP class but also remove column from table definition of object. NotNull=Not NULL -NotNullDesc=1=Set database to NOT NULL. -1=Allow null values and force value to NULL if empty ('' or 0). +NotNullDesc=1=Set database to NOT NULL, 0=Allow null values, -1=Allow null values by forcing value to NULL if empty ('' or 0) SearchAll=Used for 'search all' DatabaseIndex=Database index FileAlreadyExists=File %s already exists @@ -127,9 +127,9 @@ UseSpecificEditorURL = Use a specific editor URL UseSpecificFamily = Use a specific family UseSpecificAuthor = Use a specific author UseSpecificVersion = Use a specific initial version -IncludeRefGeneration=The reference of object must be generated automatically -IncludeRefGenerationHelp=Check this if you want to include code to manage the generation automatically of the reference -IncludeDocGeneration=I want to generate some documents from the object +IncludeRefGeneration=The reference of object must be generated automatically by custom numbering rules +IncludeRefGenerationHelp=Check this if you want to include code to manage the generation of the reference automatically using custom numbering rules +IncludeDocGeneration=I want to generate some documents from templates for 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 diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index f542bfab670..9c11e1cda2e 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -59,6 +59,7 @@ BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? PartnershipType=Partnership type PartnershipRefApproved=Partnership %s approved +KeywordToCheckInWebsite=If you want to check that a given keyword is present into the website of each partner, define this keyword here # # Template Mail @@ -89,4 +90,5 @@ PartnershipDraft=Draft PartnershipAccepted=Accepted PartnershipRefused=Refused PartnershipCanceled=Canceled -PartnershipManagedFor=Partners are \ No newline at end of file +PartnershipManagedFor=Partners are + diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 6b0e8117254..888f6fe5225 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -74,3 +74,5 @@ JobClosedTextCanceled=The job position is closed. ExtrafieldsJobPosition=Complementary attributes (job positions) ExtrafieldsApplication=Complementary attributes (job applications) MakeOffer=Make an offer +WeAreRecruiting=We are recruiting. This is a list of open positions to be filled... +NoPositionOpen=No positions open at the moment diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index edd54911bad..c1cfa5e9757 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -90,10 +90,10 @@ TicketPublicAccess=A public interface requiring no identification is available a TicketSetupDictionaries=The type of ticket, severity and analytic codes are configurable from dictionaries TicketParamModule=Module variable setup TicketParamMail=Email setup -TicketEmailNotificationFrom=Notification email from -TicketEmailNotificationFromHelp=Used into ticket message answer by example -TicketEmailNotificationTo=Notifications email to -TicketEmailNotificationToHelp=Send email notifications to this address. +TicketEmailNotificationFrom=Sender e-mail for ticket answers +TicketEmailNotificationFromHelp=Sender e-mail for ticket answers sent from Dolibarr +TicketEmailNotificationTo=Notify ticket creation to this e-mail address +TicketEmailNotificationToHelp=If present, this e-mail address will be notified of a ticket creation TicketNewEmailBodyLabel=Text message sent after creating a ticket TicketNewEmailBodyHelp=The text specified here will be inserted into the email confirming the creation of a new ticket from the public interface. Information on the consultation of the ticket are automatically added. TicketParamPublicInterface=Public interface setup @@ -219,12 +219,12 @@ ErrorMailRecipientIsEmptyForSendTicketMessage=Recipient is empty. No email send TicketGoIntoContactTab=Please go into "Contacts" tab to select them TicketMessageMailIntro=Introduction TicketMessageMailIntroHelp=This text is added only at the beginning of the email and will not be saved. -TicketMessageMailIntroLabelAdmin=Introduction to the message when sending email -TicketMessageMailIntroText=Hello,
A new response was sent on a ticket that you contact. Here is the message:
-TicketMessageMailIntroHelpAdmin=This text will be inserted before the text of the response to a ticket. +TicketMessageMailIntroLabelAdmin=Introduction text to all ticket answers +TicketMessageMailIntroText=Hello,
A new answer has been added to a ticket that you follow. Here is the message:
+TicketMessageMailIntroHelpAdmin=This text will be inserted before the answer when replying to a ticket from Dolibarr TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=This text is added only at the end of the email and will not be saved. -TicketMessageMailSignatureText=

Sincerely,

--

+TicketMessageMailSignatureText=Message sent by %s via Dolibarr TicketMessageMailSignatureLabelAdmin=Signature of response email TicketMessageMailSignatureHelpAdmin=This text will be inserted after the response message. TicketMessageHelp=Only this text will be saved in the message list on ticket card. @@ -289,7 +289,7 @@ TicketNewEmailBody=This is an automatic email to confirm you have registered a n TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account. TicketNewEmailBodyInfosTicket=Information for monitoring the ticket TicketNewEmailBodyInfosTrackId=Ticket tracking number: %s -TicketNewEmailBodyInfosTrackUrl=You can view the progress of the ticket by clicking the link above. +TicketNewEmailBodyInfosTrackUrl=You can view the progress of the ticket by clicking the following link TicketNewEmailBodyInfosTrackUrlCustomer=You can view the progress of the ticket in the specific interface by clicking the following link TicketCloseEmailBodyInfosTrackUrlCustomer=You can consult the history of this ticket by clicking the following link TicketEmailPleaseDoNotReplyToThisEmail=Please do not reply directly to this email! Use the link to reply into the interface. diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 888c9f52161..5bfbec87294 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -123,4 +123,8 @@ ForceUserHolidayValidator=Force leave request validator ValidatorIsSupervisorByDefault=By default, the validator is the supervisor of the user. Keep empty to keep this behaviour. UserPersonalEmail=Personal email UserPersonalMobile=Personal mobile phone -WarningNotLangOfInterface=Warning, this is the main language the user speak, not the language of the interface he choosed to see. To change the interface language visible by this user, go on tab %s \ No newline at end of file +WarningNotLangOfInterface=Warning, this is the main language the user speak, not the language of the interface he choosed to see. To change the interface language visible by this user, go on tab %s +DateLastLogin=Date last login +DatePreviousLogin=Date previous login +IPLastLogin=IP last login +IPPreviousLogin=IP previous login diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 9d145ef354d..75cee952bcd 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -137,6 +137,7 @@ SEPAFRST=SEPA FRST ExecutionDate=Execution date CreateForSepa=Create direct debit file ICS=Creditor Identifier - ICS +IDS=Debitor Identifier END_TO_END="EndToEndId" SEPA XML tag - Unique id assigned per transaction USTRD="Unstructured" SEPA XML tag ADDDAYS=Add days to Execution Date @@ -154,4 +155,5 @@ ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default ErrorICSmissing=Missing ICS in Bank account %s TotalAmountOfdirectDebitOrderDiffersFromSumOfLines=Total amount of direct debit order differs from sum of lines WarningSomeDirectDebitOrdersAlreadyExists=Warning: There is already some pending Direct Debit orders (%s) requested for an amount of %s -WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s \ No newline at end of file +WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s +UsedFor=Used for %s \ No newline at end of file diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 12778f337dd..53ff7d545b3 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -620,6 +620,7 @@ MonthVeryShort11=N MonthVeryShort12=D AttachedFiles=Fichiers et documents joints JoinMainDoc=Joindre le document principal +JoinMainDocOrLastGenerated=Joindre le document principal ou le dernier généré s'il n'a pas été trouvé DateFormatYYYYMM=YYYY-MM DateFormatYYYYMMDD=YYYY-MM-DD DateFormatYYYYMMDDHHMM=YYYY-MM-DD HH:SS diff --git a/htdocs/langs/fr_FR/ticket.lang b/htdocs/langs/fr_FR/ticket.lang index bc51a7627fd..e19871f09df 100644 --- a/htdocs/langs/fr_FR/ticket.lang +++ b/htdocs/langs/fr_FR/ticket.lang @@ -90,10 +90,10 @@ TicketPublicAccess=Une interface publique ne nécessitant aucune identification TicketSetupDictionaries=Les types de ticket, sévérité et codes analytiques sont paramétrables à partir des dictionnaires TicketParamModule=Configuration des variables du module TicketParamMail=Configuration de la messagerie -TicketEmailNotificationFrom=Email from de notification -TicketEmailNotificationFromHelp=Utilisé dans les messages de réponses des tickets par exemple -TicketEmailNotificationTo=E-mail de notification à -TicketEmailNotificationToHelp=Envoyer des notifications par e-mail à cette adresse. +TicketEmailNotificationFrom=Adresse e-mail émettrice des réponses aux tickets +TicketEmailNotificationFromHelp=Adresse e-mail émettrice des réponses aux tickets envoyées depuis Dolibarr +TicketEmailNotificationTo=Notifier cette adresse e-mail lors d'un nouveau ticket +TicketEmailNotificationToHelp=Si présente, cette adresse e-mail sera notifiée de la création d'un nouvau ticket TicketNewEmailBodyLabel=Texte du message envoyé après la création d'un ticket TicketNewEmailBodyHelp=Le texte spécifié ici sera inséré dans l'e-mail confirmant la création d'un nouveau ticket depuis l'interface publique. Les informations sur la consultation du ticket sont automatiquement ajoutées. TicketParamPublicInterface=Configuration de l'interface publique\n @@ -209,11 +209,11 @@ TicketGoIntoContactTab=Rendez-vous dans le tableau "Contacts" pour les sélectio TicketMessageMailIntro=Introduction TicketMessageMailIntroHelp=Ce texte est ajouté seulement au début de l'email et ne sera pas sauvegardé. TicketMessageMailIntroLabelAdmin=Introduction du message lors de l'envoi d'un e-mail -TicketMessageMailIntroText=Bonjour
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici le message :
+TicketMessageMailIntroText=Bonjour,
Une nouvelle réponse a été ajoutée à un ticket que vous suivez. Voici le message :
TicketMessageMailIntroHelpAdmin=Ce texte sera inséré après le message de réponse. TicketMessageMailSignature=Signature TicketMessageMailSignatureHelp=Ce texte est ajouté seulement à la fin de l'email et ne sera pas sauvegardé. -TicketMessageMailSignatureText=

Cordialement,

--

+TicketMessageMailSignatureText=Message envoyé par %s via Dolibarr TicketMessageMailSignatureLabelAdmin=Signature de l'email de réponse TicketMessageMailSignatureHelpAdmin=Ce texte sera inséré après le message de réponse. TicketMessageHelp=Seul ce texte sera sauvegardé dans la liste des messages sur la fiche ticket. @@ -271,8 +271,8 @@ TicketNewEmailBody=Ceci est un message automatique pour confirmer l'enregistreme TicketNewEmailBodyCustomer=Ceci est un email automatique pour confirmer qu'un nouveau ticket vient d'être créé dans votre compte. TicketNewEmailBodyInfosTicket=Informations pour la surveillance du ticket TicketNewEmailBodyInfosTrackId=Numéro de suivi du ticket : %s -TicketNewEmailBodyInfosTrackUrl=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-dessus. -TicketNewEmailBodyInfosTrackUrlCustomer=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-dessus. +TicketNewEmailBodyInfosTrackUrl=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-contre +TicketNewEmailBodyInfosTrackUrlCustomer=Vous pouvez voir la progression du ticket en cliquant sur le lien ci-contre TicketEmailPleaseDoNotReplyToThisEmail=Merci de ne pas répondre directement à ce courriel ! Utilisez le lien pour répondre via l'interface. TicketPublicInfoCreateTicket=Ce formulaire vous permet d'enregistrer un ticket dans notre système de gestion. TicketPublicPleaseBeAccuratelyDescribe=Veuillez décrire avec précision le problème. Fournissez le plus d'informations possibles pour nous permettre d'identifier correctement votre demande. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 59a43daac65..7e2cb072913 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -109,10 +109,11 @@ function testSqlAndScriptInject($val, $type) // We check string because some hacks try to obfuscate evil strings by inserting non printable chars. Example: 'java(ascci09)scr(ascii00)ipt' is processed like 'javascript' (whatever is place of evil ascii char) // We should use dol_string_nounprintableascii but function is not yet loaded/available // Example of valid UTF8 chars: - // utf8=utf8mb3: '\x0A', '\x0D', '\x7E' + // utf8=utf8mb3: '\x09', '\x0A', '\x0D', '\x7E' // utf8=utf8mb3: '\xE0\xA0\x80' // utf8mb4: '\xF0\x9D\x84\x9E' (but this may be refused by the database insert if pagecode is utf8=utf8mb3) - $newval = preg_replace('/[\x00-\x09\x0B-\x0C\x0E-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace + $newval = preg_replace('/[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]/u', '', $val); // /u operator makes UTF8 valid characters being ignored so are not included into the replace + // Note that $newval may also be completely empty '' when non valid UTF8 are found. if ($newval != $val) { // If $val has changed after removing non valid UTF8 chars, it means we have an evil string. @@ -1339,15 +1340,16 @@ if (!function_exists("llxHeader")) { * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) * @param string $morecssonbody More CSS on body tag. For example 'classforhorizontalscrolloftabs'. * @param string $replacemainareaby Replace call to main_area() by a print of this string - * @param int $disablenofollow Disable the "nofollow" on page + * @param int $disablenofollow Disable the "nofollow" on meta robot header + * @param int $disablenoindex Disable the "noindex" on meta robot header * @return void */ - function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '', $disablenofollow = 0) + function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '', $disablenofollow = 0, $disablenoindex = 0) { global $conf; // html header - top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow); + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow, $disablenoindex); $tmpcsstouse = 'sidebar-collapse'.($morecssonbody ? ' '.$morecssonbody : ''); // If theme MD and classic layer, we open the menulayer by default. @@ -1460,10 +1462,11 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files * @param int $disableforlogin Do not load heavy js and css for login pages - * @param int $disablenofollow Disable no follow tag + * @param int $disablenofollow Disable nofollow tag for meta robots + * @param int $disablenoindex Disable noindex tag for meta robots * @return void */ -function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disableforlogin = 0, $disablenofollow = 0) +function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0) { global $db, $conf, $langs, $user, $mysoc, $hookmanager; @@ -1494,7 +1497,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // Displays meta print ''."\n"; - print ''."\n"; // Do not index + print ''."\n"; // Do not index print ''."\n"; // Scale for mobile device print ''."\n"; if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { @@ -2348,9 +2351,7 @@ function top_menu_quickadd() $html .= ''; $html .= ' @@ -2398,7 +2399,7 @@ function printDropdownQuickadd() $items = array( 'items' => array( array( - "url" => "/societe/card.php?action=create", + "url" => "/societe/card.php?action=create&mainmenu=companies", "title" => "MenuNewThirdParty@companies", "name" => "ThirdParty@companies", "picto" => "object_company", @@ -2406,7 +2407,7 @@ function printDropdownQuickadd() "position" => 10, ), array( - "url" => "/contact/card.php?action=create", + "url" => "/contact/card.php?action=create&mainmenu=companies", "title" => "NewContactAddress@companies", "name" => "Contact@companies", "picto" => "object_contact", @@ -2414,7 +2415,7 @@ function printDropdownQuickadd() "position" => 20, ), array( - "url" => "/comm/propal/card.php?action=create", + "url" => "/comm/propal/card.php?action=create&mainmenu=commercial", "title" => "NewPropal@propal", "name" => "Proposal@propal", "picto" => "object_propal", @@ -2423,7 +2424,7 @@ function printDropdownQuickadd() ), array( - "url" => "/commande/card.php?action=create", + "url" => "/commande/card.php?action=create&mainmenu=commercial", "title" => "NewOrder@orders", "name" => "Order@orders", "picto" => "object_order", @@ -2431,7 +2432,7 @@ function printDropdownQuickadd() "position" => 40, ), array( - "url" => "/compta/facture/card.php?action=create", + "url" => "/compta/facture/card.php?action=create&mainmenu=billing", "title" => "NewBill@bills", "name" => "Bill@bills", "picto" => "object_bill", @@ -2439,7 +2440,7 @@ function printDropdownQuickadd() "position" => 50, ), array( - "url" => "/contrat/card.php?action=create", + "url" => "/contrat/card.php?action=create&mainmenu=commercial", "title" => "NewContractSubscription@contracts", "name" => "Contract@contracts", "picto" => "object_contract", @@ -2447,7 +2448,7 @@ function printDropdownQuickadd() "position" => 60, ), array( - "url" => "/supplier_proposal/card.php?action=create", + "url" => "/supplier_proposal/card.php?action=create&mainmenu=commercial", "title" => "SupplierProposalNew@supplier_proposal", "name" => "SupplierProposal@supplier_proposal", "picto" => "object_propal", @@ -2455,7 +2456,7 @@ function printDropdownQuickadd() "position" => 70, ), array( - "url" => "/fourn/commande/card.php?action=create", + "url" => "/fourn/commande/card.php?action=create&mainmenu=commercial", "title" => "NewSupplierOrderShort@orders", "name" => "SupplierOrder@orders", "picto" => "object_order", @@ -2463,7 +2464,7 @@ function printDropdownQuickadd() "position" => 80, ), array( - "url" => "/fourn/facture/card.php?action=create", + "url" => "/fourn/facture/card.php?action=create&mainmenu=billing", "title" => "NewBill@bills", "name" => "SupplierBill@bills", "picto" => "object_bill", @@ -2471,7 +2472,7 @@ function printDropdownQuickadd() "position" => 90, ), array( - "url" => "/product/card.php?action=create&type=0", + "url" => "/product/card.php?action=create&type=0&mainmenu=products", "title" => "NewProduct@products", "name" => "Product@products", "picto" => "object_product", @@ -2479,7 +2480,7 @@ function printDropdownQuickadd() "position" => 100, ), array( - "url" => "/product/card.php?action=create&type=1", + "url" => "/product/card.php?action=create&type=1&mainmenu=products", "title" => "NewService@products", "name" => "Service@products", "picto" => "object_service", @@ -2499,7 +2500,7 @@ function printDropdownQuickadd() $parameters = array(); $hook_items = $items; $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks - if (is_numeric($reshook) && is_array($hookmanager->results)) { + if (is_numeric($reshook) && !empty($hookmanager->results) && is_array($hookmanager->results)) { if ($reshook == 0) { $items['items'] = array_merge($items['items'], $hookmanager->results); // add } else { @@ -2559,9 +2560,7 @@ function top_menu_bookmark() } else { $html .= ''; print ''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 1; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter2, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 + $db->query($sql); + $order_receipt_printer2 .= ''.$line->product_label.''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 2; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + $linestoprint = 0; + + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter3, $existing); + $count = count($result); + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 + $db->query($sql); + $order_receipt_printer3 .= ''.$line->product_label.''; + } + } + if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { + $invoice->fetch($placeid); //Reload object before send to printer + $printer->orderprinter = 3; + echo ""; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed + $db->query($sql); + $invoice->fetch($placeid); //Reload object after set lines as printed + } + + $sectionwithinvoicelink = ''; + if ($action == "valid" || $action == "history" || $action == 'creditnote') { + $sectionwithinvoicelink .= ''."\n"; + $sectionwithinvoicelink .= ''; + $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; + } else { + if ($invoice->paye) { + $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; } else { - $order_receipt_printer1 .= $line->description; + $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); } - $order_receipt_printer1 .= ''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 1; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter2, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='2' where rowid=".$line->id; //Set to print on printer 2 - $db->query($sql); - $order_receipt_printer2 .= ''.$line->product_label.''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 2; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed - $linestoprint = 0; - - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; - } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter3, $existing); - $count = count($result); - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3 - $db->query($sql); - $order_receipt_printer3 .= ''.$line->product_label.''; - } - } - if (($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") && $linestoprint > 0) { - $invoice->fetch($placeid); //Reload object before send to printer - $printer->orderprinter = 3; - echo ""; - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed - $db->query($sql); - $invoice->fetch($placeid); //Reload object after set lines as printed -} - -$sectionwithinvoicelink = ''; -if ($action == "valid" || $action == "history" || $action == 'creditnote') { - $sectionwithinvoicelink .= ''."\n"; - $sectionwithinvoicelink .= ''; - $sectionwithinvoicelink .= $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $sectionwithinvoicelink .= $langs->trans('RemainToPay').': '.price($remaintopay, 1, $langs, 1, -1, -1, $conf->currency).''; - } else { - if ($invoice->paye) { - $sectionwithinvoicelink .= ''.$langs->trans("Paid").''; + } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { + $sectionwithinvoicelink .= ' '; } else { - $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); + $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { + $sectionwithinvoicelink .= ' '; + } + if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { + $sectionwithinvoicelink .= ' '; + } } - } - $sectionwithinvoicelink .= '
'; - if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { - if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; + if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { + $sectionwithinvoicelink .= ' '; } - } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { - $sectionwithinvoicelink .= ' '; - } else { - $sectionwithinvoicelink .= ' '; - if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) { - $sectionwithinvoicelink .= ' '; - } - if (getDolGlobalString('TAKEPOS_GIFT_RECEIPT')) { - $sectionwithinvoicelink .= ' '; - } - } - if (getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE') && $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { - $sectionwithinvoicelink .= ' '; - } - if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { - $sectionwithinvoicelink .= ''; + if ($remaintopay <= 0 && getDolGlobalString('TAKEPOS_AUTO_PRINT_TICKETS')) { + $sectionwithinvoicelink .= ''; + } } } - /* * View */ diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 2bb2f61375b..6ca9ad67b1f 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -96,8 +96,6 @@ button.dropdown-item.global-search-item { box-shadow: 0 6px 12px rgba(0,0,0,.175); } .dropdown-menu { - border-color: #eee; - position: absolute; top: 100%; left: 0; @@ -112,7 +110,6 @@ button.dropdown-item.global-search-item { background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; - border: 1px solid #ccc; border: 1px solid rgba(0,0,0,.15); border-radius: 4px; -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); @@ -200,7 +197,7 @@ button.dropdown-item.global-search-item { } div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown, div#topmenu-quickadd-dropdown { - global->THEME_TOPMENU_DISABLE_IMAGE)) { ?> + line-height: 46px; } @@ -239,26 +236,28 @@ a.top-menu-dropdown-link { clear: both; } -.dropdown-menu > .bookmark-footer{ +.dropdown-menu > .bookmark-footer { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } -.dropdown-menu > .user-body, .dropdown-body{ +.dropdown-menu > .user-body, .dropdown-body { padding: 15px; border-bottom: 1px solid #f4f4f4; border-top: 1px solid #dddddd; white-space: normal; } -.dropdown-menu > .bookmark-body, .dropdown-body{ +.dropdown-menu > .bookmark-body, .dropdown-body { overflow-y: auto; max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 110px) ; white-space: normal; } +#topmenu-quickadd-dropdown .dropdown-menu > .bookmark-body, #topmenu-quickadd-dropdown .dropdown-body, #topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 200px) ; @@ -290,7 +289,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -301,6 +300,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; @@ -500,8 +503,19 @@ div.quickaddblock:focus { right: 0; } + #topmenu-quickadd-dropdown .dropdown-menu { + min-width: 220px; + max-width: 235px; + } #topmenu-bookmark-dropdown .dropdown-menu { - min-width: 280px; + min-width: 220px; max-width: 360px; } + + .dropdown-menu { + border: none; + -webkit-box-shadow: none; + box-shadow: none; + } + } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 9a940d9e1a9..ff6fe3c4fb8 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -13,7 +13,7 @@ --colorbacktitle1: rgb(); --colorbacktabcard1: rgb(); --colorbacktabactive: rgb(); - --colorbacklinepair1: rgb(); + --colorbacklineimpair1: rgb(); --colorbacklineimpair2: rgb(); --colorbacklinepair1: rgb(); --colorbacklinepair2: rgb(); @@ -78,6 +78,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --colortexttitle: rgb(220,220,220); --colortext: rgb(220,220,220); --colortextlink: #4390dc; + --colortexttitlelink: #4390dc; --colortextbackhmenu: rgb(220,220,220); --colortextbackvmenu: rgb(220,220,220); --tooltipfontcolor : rgb(220,220,220); @@ -389,6 +390,7 @@ input.buttonpaymentstripe { .logopublicpayment #dolpaymentlogo { max-height: 100px; max-width: 320px; + image-rendering: -webkit-optimize-contrast; /* better rendering on public page header */ } a.butStatus { @@ -1666,21 +1668,6 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select width: 175px; } - .logopublicpayment #dolpaymentlogo { - max-width: 260px; - } - #tablepublicpayment { - width: auto !important; - } - .poweredbypublicpayment { - float: unset !important; - top: unset !important; - bottom: 8px; - position: relative !important; - } - .poweredbyimg { - width: 48px; - } input.buttonpayment, button.buttonpayment, div.buttonpayment { min-width: 270px; } @@ -1832,9 +1819,9 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select } */ - input.buttonpayment { + input.buttonpayment { min-width: 300px; - } + } } .linkobject { cursor: pointer; } @@ -1969,6 +1956,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after, #mainmenutd_menu::after { content: unset !important; @@ -2600,8 +2588,7 @@ button.ui-button.ui-corner-all.ui-widget:focus { /* For mainmenu, we always load the img */ div.mainmenu.menu { - background-image: url(); - + } #mainmenutd_menu a.tmenuimage { display: unset; @@ -2615,6 +2602,38 @@ a.tmenuimage:hover{ } +/* To show text of top menu on hover only (THEME_TOPMENU_DISABLE_IMAGE == 2) */ + + +.tmenulabel:not(.menuhider), .tmenulabel:not(.menuhider):before { + display: none; +} +a.tmenuimage:not(.menuhider), a.tmenuimage:not(.menuhider):before, +div.tmenuimage:not(.menuhider), div.tmenuimage:not(.menuhider):before, +span.tmenuimage:not(.menuhider), span.tmenuimage:not(.menuhider):before { + font-size: 1.3em; + margin-top: 10px !important; +} + + +.tmenudiv:hover .tmenulabel:not(.menuhider), .tmenudiv:hover .tmenulabel:not(.menuhider):before { + display: initial !important; +} +.tmenudiv:hover .tmenuimage:not(.menuhider), .tmenudiv:hover .tmenuimage:not(.menuhider):before { + font-size: 1.1em !important; + margin-top: 0px !important; +} + + +li.tmenu:hover .tmenulabel:not(.menuhider), li.tmenu:hover .tmenulabel:not(.menuhider):before { + display: initial !important; +} +li.tmenu:hover .tmenuimage:not(.menuhider), li.tmenu:hover .tmenuimage:not(.menuhider):before { + font-size: 1.1em !important; + margin-top: 0px !important; +} + + /* Do not load menu img for other if hidden to save bandwidth */ @@ -5967,6 +5986,12 @@ span.select2.select2-container.select2-container--default { border-right: none; } +span.select2.select2-container.select2-container--default { + global->THEME_SHOW_BORDER_ON_INPUT)) { ?> + //border-bottom: solid 1px var(--inputbordercolor); + +} + input.select2-input { border-bottom: none ! important; } @@ -5985,7 +6010,7 @@ input.select2-input { border: none; } .select2-container--focus span.select2-selection.select2-selection--single { - border-bottom: 1px solid #666 !important; + border-bottom: 1px solid var(--inputbordercolor) !important; border-bottom-left-radius: 0; border-bottom-right-radius: 0; } @@ -5996,14 +6021,14 @@ input.select2-input { background-color: var(--colorbackvmenu1); } .select2-container--default .select2-selection--single { - background-color: var(--colorbackbody); + background-color: var(--inputbackgroundcolor); } #blockvmenusearch .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--colortextbackvmenu); } .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--colortext); - /* background-color: var(--colorbackvmenu1); */ + /* background-color: var(--inputbackgroundcolor); */ } .select2-default { color: #999 !important; @@ -7262,6 +7287,24 @@ div.clipboardCPValue.hidewithsize { } td.widthpictotitle { width: 30px; } + + .logopublicpayment #dolpaymentlogo { + max-width: 260px; + } + #tablepublicpayment { + width: auto !important; + border: none !important; + } + .poweredbypublicpayment { + float: unset !important; + top: unset !important; + /* bottom: 8px; */ + right: -10px !important; + position: relative !important; + } + .poweredbyimg { + width: 48px; + } } @media only screen and (max-width: 1024px) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 8e4df027809..2d33a716692 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -21,7 +21,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { display: block; position: relative; min-height: 90px; - /* background: #fff; */ + background: var(--colorbacklineimpair2); width: 100%; box-shadow: 1px 1px 15px rgba(192, 192, 192, 0.2); border-radius: 2px; @@ -88,7 +88,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { text-align: center; font-size: 2.8em; line-height: 90px; - background: rgba(0, 0, 0, 0.08) !important; + background: var(--colorbacktitle1) !important; } .info-box-module .info-box-icon { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index dc94669d54f..40a03a0db5b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -276,7 +276,7 @@ $heightmenu = 50; /* height of top menu, part with image */ $heightmenu2 = 49; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 180; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $disableimages = 1; $maxwidthloginblock = $maxwidthloginblock + 50; $minwidthtmenu = 0; } diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index a6bffa753f5..c56590d7bfa 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -21,20 +21,26 @@ button.dropdown-item.global-search-item { } -#topmenu-bookmark-dropdown a.login-dropdown-a { +#topmenu-quickadd-dropdown a.login-dropdown-a, #topmenu-bookmark-dropdown a.login-dropdown-a { color: #fff; } +div#topmenu-quickadd-dropdown { + position: fixed; + : 65px; + top: 0px; +} div#topmenu-bookmark-dropdown { position: fixed; - right: 20px; + : 20px; top: 0px; } + #topmenu-login-dropdown .dropdown-toggle:after { display: none; } -#topmenu-bookmark-dropdown .dropdown-menu { +#topmenu-quickadd-dropdown .dropdown-menu, #topmenu-bookmark-dropdown .dropdown-menu { min-width: 300px; max-width: 360px; } @@ -43,8 +49,8 @@ button.dropdown-item.global-search-item { outline: none; } -.open>.dropdown-search, .open>.dropdown-bookmark, .open>.dropdown-menu{ - display: block; +.open>.dropdown-search, .open>.dropdown-quickadd, .open>.dropdown-bookmark, .open>.dropdown-menu{ + display: block !important; } .dropdown-search { @@ -194,8 +200,8 @@ button.dropdown-item.global-search-item { max-width: 100%; } -div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown { - line-height: 46px; +div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown { + line-height: px; } a.top-menu-dropdown-link { padding: 8px; @@ -215,7 +221,7 @@ a.top-menu-dropdown-link { } .dropdown-menu > .user-header{ - background: rgb(); + background: rgb(--colorbackhmenu1); } @@ -238,6 +244,7 @@ a.top-menu-dropdown-link { border-top: 1px solid #f0f0f0; background-color: #f9f9f9; padding: 10px; + text-align: start; } @@ -255,7 +262,8 @@ a.top-menu-dropdown-link { max-height: calc(90vh - 110px) ; white-space: normal; } -#topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body{ +#topmenu-quickadd-dropdown .dropdown-menu > .bookmark-body, #topmenu-quickadd-dropdown .dropdown-body, +#topmenu-bookmark-dropdown .dropdown-menu > .bookmark-body, #topmenu-bookmark-dropdown .dropdown-body { max-height: 60vh ; /* fallback for browsers without support for calc() */ max-height: calc(90vh - 200px) ; } @@ -277,7 +285,7 @@ a.top-menu-dropdown-link { } -#topmenu-login-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown { +#topmenu-login-dropdown, #topmenu-quickadd-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown { padding: 0 5px 0 5px; } #topmenu-login-dropdown a:hover{ @@ -286,7 +294,7 @@ a.top-menu-dropdown-link { #topmenuloginmoreinfo-btn, #topmenulogincompanyinfo-btn { display: block; - text-align: right; + text-align: start; color:#666; cursor: pointer; } @@ -297,6 +305,10 @@ a.top-menu-dropdown-link { font-size: 0.95em; } +a.dropdown-item { + text-align: start; +} + .button-top-menu-dropdown { display: inline-block; padding: 6px 12px; @@ -417,10 +429,18 @@ a.top-menu-dropdown-link { /* smartphone */ @media only screen and (max-width: 767px) { + #topmenu-quickadd-dropdown .dropdown-menu { + min-width: 220px; + max-width: 235px; + } + #topmenu-bookmark-dropdown .dropdown-menu { + min-width: 220px; + max-width: 360px; + } + #topmenu-bookmark-dropdown a.login-dropdown-a { color: #000; } - #topmenu-bookmark-dropdown .dropdown-menu { width: 230px; } diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 1ea21ac44d1..8ffd6fc3f93 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -133,7 +133,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { display: block; position: relative; min-height: 90px; - background: #fff; + background: var(--colorbacklineimpair2); width: 100%; /* box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); */ border-radius: 2px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5ebeb73261e..60d7bae21cd 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -359,7 +359,7 @@ body { color: rgb(); font-size: ; - line-height: 1.3; + line-height: 1.4; font-family: ; margin-top: 0; margin-bottom: 0; @@ -584,6 +584,7 @@ input.buttonpaymentstripe { } .logopublicpayment #dolpaymentlogo { max-height: 100px; + image-rendering: -webkit-optimize-contrast; /* better rendering on public page header */ } a.butStatus { padding-left: 5px; @@ -1747,9 +1748,6 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select width: 175px; } - .poweredbyimg { - width: 48px; - } input.buttonpayment, button.buttonpayment, div.buttonpayment { min-width: 270px; } @@ -2270,6 +2268,7 @@ div.nopadding { } td.nobordernopadding.widthpictotitle.col-picto { + color: #bbb; opacity: 0.9; } .pictotitle { @@ -2279,6 +2278,9 @@ td.nobordernopadding.widthpictotitle.col-picto { .pictoobjectwidth { width: 14px; } +span.widthpictotitle { + font-size: 1.3em; +} .table-list-of-attached-files .col-picto, .table-list-of-links .col-picto { opacity: 0.7 !important; font-size: 1em; @@ -2436,7 +2438,7 @@ $heightmenu = 48; /* height of top menu, part with image */ $heightmenu2 = 48; /* height of top menu, ârt with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { +if (getDolGlobalInt('THEME_TOPMENU_DISABLE_IMAGE') == 1) { $heightmenu = 30; $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu = 0; } ?> @@ -2621,98 +2623,21 @@ a.tmenuimage:focus, .mainmenu.topmenuimage:focus { outline: none; } -/* Do not load menu img if hidden to save bandwidth */ - - - - div.mainmenu.home{ - background-image: url(); background-position-x: center; } -div.mainmenu.billing { - background-image: url(); -} - -div.mainmenu.accountancy { - background-image: url(); -} - -div.mainmenu.agenda { - background-image: url(); -} - -div.mainmenu.bank { - background-image: url(); -} - -div.mainmenu.cashdesk { - background-image: url(); -} - -div.mainmenu.takepos { - background-image: url(); -} - -div.mainmenu.companies { - background-image: url(); -} - -div.mainmenu.commercial { - background-image: url(); -} - -div.mainmenu.ecm { - background-image: url(); -} - -div.mainmenu.externalsite { - background-image: url(); -} - -div.mainmenu.ftp { - background-image: url(); -} - -div.mainmenu.hrm { - background-image: url(); -} - -div.mainmenu.members { - background-image: url(); -} - div.mainmenu.menu { - background-image: url(); top: 10px; left: 1px; } -div.mainmenu.products { - background-image: url(); -} -div.mainmenu.mrp { - background-image: url(); -} -div.mainmenu.project { - background-image: url(); -} - -div.mainmenu.ticket { - background-image: url(); -} - -div.mainmenu.tools { - background-image: url(); -} - -div.mainmenu.website { - background-image: url(); -} +/* Do not load menu img if hidden to save bandwidth */ + + 'name of class for div') @@ -3160,6 +3085,7 @@ div.blockvmenulogo object-fit: contain; width: inherit; height: inherit; + image-rendering: -webkit-optimize-contrast; } #mainmenutd_companylogo::after { content: unset; @@ -3964,10 +3890,10 @@ table.hidepaginationnext .paginationnext { /* Prepare to remove class pair - impair .noborder > tbody > tr:nth-child(even) td { - background: linear-gradient(to bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpai2) 85%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 85%, var(--colorbacklineimpair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -3976,10 +3902,10 @@ table.hidepaginationnext .paginationnext { } .noborder > tbody > tr:nth-child(odd) td { - background: linear-gradient(to bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -4034,10 +3960,10 @@ ul.noborder li:nth-child(odd):not(.liste_titre) { } .impair, .nohover .impair:hover, tr.impair td.nohover { - background: var(--colorbacklineimpair1); + background: var(--colorbacklineimpair2); } #GanttChartDIV { - background-color: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } .oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover, .tagtr.oddeven { @@ -4055,12 +3981,12 @@ table.dataTable tr.oddeven { /* For no hover style */ td.oddeven, table.nohover tr.impair, table.nohover tr.pair, table.nohover tr.impair td, table.nohover tr.pair td, tr.nohover td, form.nohover, form.nohover:hover { - background-color: var(--colorbacklineimpair1) !important; - background: var(--colorbacklineimpair1) !important; + background-color: var(--colorbacklineimpair2) !important; + background: var(--colorbacklineimpair2) !important; } td.evenodd, tr.nohoverpair td, #trlinefordates td { - background-color: var(--colorbacklinepair1) !important; - background: var(--colorbacklinepair1) !important; + background-color: var(--colorbacklinepair2) !important; + background: var(--colorbacklinepair2) !important; } .trforbreak td { font-weight: bold; @@ -4273,10 +4199,10 @@ div .tdtop { div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { - background: linear-gradient(to bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); } .noborder > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .noborder .tagtr:nth-child(even):not(:last-of-type) .oddeven.tagtd:not(.liste_titre) @@ -7149,6 +7075,23 @@ div.clipboardCPValue.hidewithsize { margin: 0 0 0 -8px !important; } + .logopublicpayment #dolpaymentlogo { + max-width: 260px; + } + #tablepublicpayment { + width: auto !important; + border: none !important; + } + .poweredbypublicpayment { + float: unset !important; + top: unset !important; + /* bottom: 8px; */ + right: -10px !important; + position: relative !important; + } + .poweredbyimg { + width: 48px; + } } @media only screen and (max-width: 1024px) @@ -7349,10 +7292,7 @@ if (is_object($db)) { background: #ddd; }​ -div#topmenu-bookmark-dropdown { - position: fixed; - right: 20px; -} + /* Must be at end */ div.flot-text .flot-tick-label .tickLabel, .fa-color-unset { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 84e45c2dad0..d63fa68dbfb 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -756,7 +756,7 @@ class Ticket extends CommonObject $sql .= $this->db->plimit($limit + 1, $offset); } - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -829,7 +829,7 @@ class Ticket extends CommonObject return $num; } else { $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::fetch_all ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::fetchAll ".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fe59f002baa..4ec919358e1 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -656,9 +656,12 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; + $holiday->fk_type = $objp->fk_type; $holiday->statut = $objp->status; - $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $holiday->status = $objp->status; + + $nbopenedday = num_open_day($db->jdate($objp->date_debut, 'gmt'), $db->jdate($objp->date_fin, 'gmt'), 0, 1, $objp->halfday); print ''; print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Declaration")."\n"; @@ -164,8 +170,8 @@ if ($action == 'create') { print $langs->trans("AnalysisPeriod"); print ''; - print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle '); - print $formother->select_year($year ? date('Y') : $year, 'year', 0, 3, 3); + print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle ', true); + print $formother->selectyear($year ? date('Y') : $year, 'year', 0, 3, 3, 0, 0, '', '', true); print '
'; - print $perm[1]; + print $langs->trans($perm[1]); print ''; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index eeca8b77358..fe92596d228 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -177,7 +177,7 @@ if ($action == 'updateMask') { $file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { $filefound = 1; - $classname = "pdf_".$modele; + $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } @@ -188,7 +188,7 @@ if ($action == 'updateMask') { $module = new $classname($db); if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mymodule-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); return; } else { setEventMessages($module->error, null, 'errors'); @@ -701,7 +701,8 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Preview print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; + $newname = preg_replace('/_'.preg_quote(strtolower($myTmpObjectKey), '/').'/', '', $name); + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 288fd88eae6..f5e1a18abff 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -975,8 +975,8 @@ class MyObject extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index b1caea730f9..d843687157a 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -222,6 +222,8 @@ class modMyModule extends DolibarrModules 'tabrowid'=>array("rowid", "rowid", "rowid"), // Condition to show each dictionary 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) + // Help tooltip for each fields of the dictionary + 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp'))) ); */ diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index e3117d88303..d75f69a47f5 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -33,6 +33,11 @@ function myobjectPrepareHead($object) $langs->load("mymodule@mymodule"); + $showtabofpagecontact = 1; + $showtabofpagenote = 1; + $showtabofpagedocument = 1; + $showtabofpageagenda = 1; + $h = 0; $head = array(); @@ -41,40 +46,53 @@ function myobjectPrepareHead($object) $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { - $nbNote = 0; - if (!empty($object->note_private)) { - $nbNote++; - } - if (!empty($object->note_public)) { - $nbNote++; - } - $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) { - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); - } - $head[$h][2] = 'note'; + if ($showtabofpagecontact) { + $head[$h][0] = dol_buildpath("/mymodule/myobject_contact.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Contacts"); + $head[$h][2] = 'contact'; $h++; } - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->mymodule->dir_output."/myobject/".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("/mymodule/myobject_document.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) { - $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + if ($showtabofpagenote) { + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { + $nbNote = 0; + if (!empty($object->note_private)) { + $nbNote++; + } + if (!empty($object->note_public)) { + $nbNote++; + } + $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) { + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + } + $head[$h][2] = 'note'; + $h++; + } } - $head[$h][2] = 'document'; - $h++; - $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Events"); - $head[$h][2] = 'agenda'; - $h++; + if ($showtabofpagedocument) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->mymodule->dir_output."/myobject/".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("/mymodule/myobject_document.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles + $nbLinks) > 0) { + $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + } + $head[$h][2] = 'document'; + $h++; + } + + if ($showtabofpageagenda) { + $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Events"); + $head[$h][2] = 'agenda'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 0ecd42bda26..8771ad0f9b6 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -88,6 +88,9 @@ require_once __DIR__.'/class/myobject.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + $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 ? @@ -99,8 +102,6 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $mode = GETPOST('mode', 'aZ'); -$id = GETPOST('id', 'int'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -378,8 +379,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; @@ -536,8 +541,12 @@ if (!empty($moreforfilter)) { } $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) : ''); +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, 'left'); // This also change content of $arrayfields +} else { + $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"; @@ -546,6 +555,13 @@ print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -562,7 +578,7 @@ foreach ($object->fields as $key => $val) { if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $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, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } 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')); @@ -591,10 +607,12 @@ print $hookmanager->resPrint; print '
'; }*/ // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; $totalarray = array(); @@ -603,6 +621,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -614,6 +635,7 @@ foreach ($object->fields as $key => $val) { } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label 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"; $totalarray['nbfield']++; @@ -630,7 +652,9 @@ print $hookmanager->resPrint; $totalarray['nbfield']++; }*/ // Action column -print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} $totalarray['nbfield']++; print ''."\n"; @@ -676,6 +700,18 @@ while ($i < $imaxinloop) { // Show here line of result $j = 0; print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -696,7 +732,11 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { @@ -732,15 +772,17 @@ while ($i < $imaxinloop) { print ''; }*/ // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index b05abe3fd40..b0fafc9e357 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -90,7 +90,7 @@ foreach ($arrayfields as $key => $val) { } } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b673856d124..7d7d6a65d14 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -119,9 +119,10 @@ class Partnership extends CommonObject 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), - 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), + 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), + 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), // fk_member and fk_soc are added into constructor ); diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 0f4aa61f621..2eaa8cc5dd2 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -309,7 +309,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($managedfor == 'member') { @@ -640,7 +640,7 @@ 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 diff --git a/htdocs/product/card.php b/htdocs/product/card.php index efa14b1e582..eb292e8c7f0 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -173,7 +173,7 @@ if ($object->id > 0) { restrictedArea($user, 'service', $object->id, 'product&product', '', ''); } } else { - restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + restrictedArea($user, 'produit|service', 0, 'product&product', '', '', $fieldtype); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -1564,8 +1564,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Quality control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''; - print ''; + print ''; + print ''; } // Other attributes @@ -2611,19 +2611,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Custom code if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) { - print ''; + print ''; // Origin country code print ''; + print ''; } // Quality Control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''.$object->lifetime.''; + print ''; print ''; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e44aef221f6..8ab2c4bae79 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -189,6 +189,7 @@ class Products extends DolibarrApi $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql .= " FROM ".$this->db->prefix()."product as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields AS ef ON ef.fk_object = t.rowid"; // So we will be able to filter on extrafields if ($category > 0) { $sql .= ", ".$this->db->prefix()."categorie_product as c"; } @@ -217,6 +218,7 @@ class Products extends DolibarrApi // Show only services $sql .= " AND t.fk_product_type = 1"; } + // Add sql filters if ($sqlfilters) { $errormessage = ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 84cc2454c21..5bcde058907 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1802,7 +1802,17 @@ class Product extends CommonObject */ public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) { - global $conf, $db; + global $conf, $db, $hookmanager, $action; + + // Call hook if any + if (is_object($hookmanager)) { + $parameters = array('thirdparty_seller'=>$thirdparty_seller, 'thirdparty_buyer' => $thirdparty_buyer, 'pqp' => $pqp); + // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('getSellPrice', $parameters, $this, $action); + if ($reshook > 0) { + return $hookmanager->resArray; + } + } // Update if prices fields are defined $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 81300d6bac8..80823c7ba5a 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -306,9 +306,14 @@ class Inventory extends CommonObject $inventoryline->fk_warehouse = $obj->fk_warehouse; $inventoryline->fk_product = $obj->fk_product; $inventoryline->batch = $obj->batch; - $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty $inventoryline->datec = dol_now(); + if ($conf->productbatch->enabled) { + $inventoryline->qty_stock = ($obj->batch ? $obj->qty : $obj->reel); // If there is batch detail, we take qty for batch, else global qty + } else { + $inventoryline->qty_stock = $obj->reel; + } + $resultline = $inventoryline->create($user); if ($resultline <= 0) { $this->error = $inventoryline->error; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 204c6539c29..5351c55334e 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1115,11 +1115,12 @@ if ($object->id > 0) { print ''; - 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 58f5546216f..764272a135f 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -505,7 +505,7 @@ 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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++; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 3624f80187d..2ab5a836c51 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -4,7 +4,7 @@ * Copyright (C) 2013-2015 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2017 Ferran Marcet - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2022 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 @@ -86,7 +86,7 @@ $type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; $langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('consumptionthirdparty')); +$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); /* diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c1165641b03..5884679950f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -249,7 +249,7 @@ $arrayfields = array( 's.idprof6'=>array('label'=>"ProfId6Short", 'position'=>45, 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntraShort", 'position'=>50, 'checked'=>0), 'customerorsupplier'=>array('label'=>'NatureOfThirdParty', 'position'=>61, 'checked'=>1), - 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'position'=>62, 'checked'=>$checkprospectlevel), + 's.fk_prospectlevel'=>array('label'=>"ProspectLevel", 'position'=>62, 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'position'=>63, 'checked'=>$checkstcomm), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>64, 'checked'=>0), 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -876,7 +876,7 @@ if ($user->rights->societe->creer) { $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToDisabled"); } if ($user->rights->societe->creer) { - $arrayofmassactions['presetcommercial'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); + $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { $arrayofmassactions = array(); @@ -1648,7 +1648,7 @@ while ($i < min($num, $limit)) { $titlealt = $val['label']; } if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''.img_action($titlealt, $val['code'], $val['picto']).''; } } print ''; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index bc93d72d60e..974b3d9b891 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -273,7 +273,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/, $/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX."societe_account as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($objectwebsiteaccount->ismultientitymanaged == 1) { @@ -468,7 +468,7 @@ 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index ad35c8f9914..55fdaf6f413 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -318,7 +318,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql .= ', '.MAIN_DB_PREFIX.'supplier_proposal as sp'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (sp.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { @@ -573,10 +573,10 @@ if ($resql) { $arrayofmassactions = array( 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'presend'=>img_picto('', 'email',, 'class="pictofixedwidth"').' '.$langs->trans("SendByMail"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if ($user->rights->supplier_proposal->supprimer) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').' '.$langs->trans("Delete"); + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); @@ -620,7 +620,7 @@ if ($resql) { $moreforfilter = ''; // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); @@ -628,7 +628,7 @@ if ($resql) { $moreforfilter .= '
'; } // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) { + if ($user->rights->user->user->lire) { $moreforfilter .= '
'; $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 widthcentpercentminusx'); diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index e631776490a..849c5c56481 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -392,7 +392,7 @@ if (!empty($conf->barcode->enabled)) { print '
\n"; } diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index a3bcc04b5c8..5168c370592 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -48,13 +48,15 @@ $category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'sup $action = GETPOST('action', 'aZ09'); $term = GETPOST('term', 'alpha'); $id = GETPOST('id', 'int'); +$search_start = GETPOST('search_start', 'int'); +$search_limit = GETPOST('search_limit', 'int'); if (empty($user->rights->takepos->run)) { accessforbidden(); } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('takeposproductsearch')); +$hookmanager->initHooks(array('takeposproductsearch')); // new context for product search hooks /* * View @@ -69,13 +71,22 @@ if ($action == 'getProducts') { if ($result > 0) { $prods = $object->getObjectsInCateg("product", 0, 0, 0, getDolGlobalString('TAKEPOS_SORTPRODUCTFIELD'), 'ASC'); // Removed properties we don't need + $res = array(); if (is_array($prods) && count($prods) > 0) { foreach ($prods as $prod) { + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { + // remove products without stock + $prod->load_stock('nobatch,novirtual'); + if ($prod->stock_warehouse[getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])]->real <= 0) { + continue; + } + } unset($prod->fields); unset($prod->db); + $res[] = $prod; } } - echo json_encode($prods); + echo json_encode($res); } else { echo 'Failed to load category with id='.$category; } @@ -111,8 +122,8 @@ if ($action == 'getProducts') { } } - if (!empty($conf->barcode->enabled) && !empty($conf->global->TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT)) { - $barcode_rules = $conf->global->TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT; + $barcode_rules = getDolGlobalString('TAKEPOS_BARCODE_RULE_TO_INSERT_PRODUCT'); + if (!empty($conf->barcode->enabled) && !empty($barcode_rules)) { $barcode_rules_list = array(); // get barcode rules @@ -208,29 +219,50 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; + $sql = 'SELECT p.rowid, p.ref, p.label, p.tosell, p.tobuy, p.barcode, p.price' ; + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { + $sql .= ', ps.reel'; + } + // Add fields from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); + if ($reshook >= 0) { + $sql .= $hookmanager->resPrint; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps'; + $sql .= ' ON (p.rowid = ps.fk_product'; + $sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt("CASHDESK_ID_WAREHOUSE".$_SESSION['takeposterminal'])); + } // Add tables from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTables', $parameters); + if ($reshook >= 0) { + $sql .= $hookmanager->resPrint; + } $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 ('.$db->sanitize($filteroncategids).'))'; } $sql .= ' AND tosell = 1'; + if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) { + $sql .= ' AND ps.reel > 0'; + } $sql .= natural_search(array('ref', 'label', 'barcode'), $term); // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); + if ($reshook >= 0) { + $sql .= $hookmanager->resPrint; + } + + // load only one page of products + $sql.= $db->plimit($search_limit, $search_start); $resql = $db->query($sql); if ($resql) { @@ -254,7 +286,7 @@ if ($action == 'getProducts') { } } - $rows[] = array( + $row = array( 'rowid' => $obj->rowid, 'ref' => $obj->ref, 'label' => $obj->label, @@ -267,6 +299,20 @@ if ($action == 'getProducts') { 'qty' => 1, //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); + // Add entries to row from hooks + $parameters=array(); + $parameters['row'] = $row; + $parameters['obj'] = $obj; + + $reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters); + if ($reshook > 0) { + // replace + $row = $hookmanager->resArray; + } else { + // add + $rows[] = $hookmanager->resArray; + } + $rows[] = $row; } echo json_encode($rows); } else { diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index ba85c111bcd..45130981876 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -311,7 +311,7 @@ table.postablelines tr td { .posinvoiceline td { height: 40px !important; - background-color: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } .postablelines td.linecolht { diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index b23907b64f1..244386a8180 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -232,7 +232,7 @@ function PrintCategories(first) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[parseInt(i)+parseInt(first)]['label']); + $("#catdesc"+i).html(categories[parseInt(i)+parseInt(first)]['label']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).data("rowid",categories[parseInt(i)+parseInt(first)]['rowid']); $("#catdiv"+i).attr('class', 'wrapper'); @@ -266,7 +266,7 @@ function MoreCategories(moreorless) { continue; } $("#catdivdesc"+i).show(); - $("#catdesc"+i).text(categories[i+( * pagecategories)]['label']); + $("#catdesc"+i).html(categories[i+( * pagecategories)]['label']); $("#catimg"+i).attr("src","genimg/index.php?query=cat&id="+categories[i+( * pagecategories)]['rowid']); $("#catdiv"+i).data("rowid",categories[i+( * pagecategories)]['rowid']); $("#catwatermark"+i).show(); @@ -295,8 +295,8 @@ function LoadProducts(position, issubcat) { jQuery.each(subcategories, function(i, val) { if (currentcat==val.fk_parent) { $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(val.label); - $("#probutton"+ishow).text(val.label); + $("#prodesc"+ishow).html(val.label); + $("#probutton"+ishow).html(val.label); $("#probutton"+ishow).show(); $("#proprice"+ishow).attr("class", "hidden"); $("#proprice"+ishow).html(""); @@ -343,13 +343,13 @@ function LoadProducts(position, issubcat) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);'; } else { - echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);'; } echo '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; } else { echo '$("#probutton"+ishow).show();'; - echo '$("#probutton"+ishow).text(data[parseInt(idata)][\'label\']);'; + echo '$("#probutton"+ishow).html(data[parseInt(idata)][\'label\']);'; } ?> if (data[parseInt(idata)]['price_formated']) { @@ -361,6 +361,13 @@ function LoadProducts(position, issubcat) { $("#prodiv"+ishow).attr("class","wrapper2"); $("#prowatermark"+ishow).hide(); ishow++; //Next product to show after print data product + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> } //console.log("Hide the prowatermark for ishow="+ishow); idata++; //Next data everytime @@ -372,6 +379,9 @@ function LoadProducts(position, issubcat) { function MoreProducts(moreorless) { console.log("MoreProducts"); + + if ($('#search_pagination').val() != '') return Search2('', moreorless); + var maxproduct = ; if (moreorless=="more"){ @@ -414,9 +424,9 @@ function MoreProducts(moreorless) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?> $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); - $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#prodesc"+ishow).html(data[parseInt(idata)]['label']); - $("#probutton"+ishow).text(data[parseInt(idata)]['label']); + $("#probutton"+ishow).html(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { $("#proprice"+ishow).attr("class", "productprice"); @@ -556,12 +566,20 @@ function New() { * @param {int} keyCodeForEnter Key code for "enter" * return {void} */ -function Search2(keyCodeForEnter) { +function Search2(keyCodeForEnter, moreorless) { console.log("Search2 Call ajax search to replace products keyCodeForEnter="+keyCodeForEnter); + var search_term = $('#search').val(); + var search_start = 0; + var search_limit = ; + if (moreorless != null) { + search_term = $('#search_pagination').val(); + search_start = $('#search_start_'+moreorless).val(); + } + var search = false; var eventKeyCode = window.event.keyCode; - if (typeof keyCodeForEnter === 'undefined' || eventKeyCode == keyCodeForEnter) { + if (keyCodeForEnter == '' || eventKeyCode == keyCodeForEnter) { search = true; } @@ -576,7 +594,8 @@ function Search2(keyCodeForEnter) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); - $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + $('#search').val(), function (data) { + var nbsearchresults = 0; + $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + search_term + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prodesc" + i).text(""); @@ -597,10 +616,10 @@ function Search2(keyCodeForEnter) { if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { ?> $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); - $("#prodesc" + i).text(data[i]['label']); + $("#prodesc" + i).html(data[i]['label']); $("#prodivdesc" + i).show(); - $("#probutton" + i).text(data[i]['label']); + $("#probutton" + i).html(data[i]['label']); $("#probutton" + i).show(); if (data[i]['price_formated']) { $("#proprice" + i).attr("class", "productprice"); @@ -615,6 +634,16 @@ function Search2(keyCodeForEnter) { } $("#prodiv" + i).data("rowid", data[i]['rowid']); $("#prodiv" + i).data("iscat", 0); + + executeHooks('completeJSProductDisplay', $parameters); + print $hookmanager->resPrint; + ?> + + nbsearchresults++; } }).always(function (data) { // If there is only 1 answer @@ -639,6 +668,24 @@ function Search2(keyCodeForEnter) { } else ClearSearch(); } + // memorize search_term and start for pagination + $("#search_pagination").val($("#search").val()); + if (search_start == 0) { + $("#prodiv span").hide(); + } + else { + $("#prodiv span").show(); + var search_start_less = Math.max(0, parseInt(search_start) - parseInt()); + $("#search_start_less").val(search_start_less); + } + if (nbsearchresults != ) { + $("#prodiv span").hide(); + } + else { + $("#prodiv span").show(); + var search_start_more = parseInt(search_start) + parseInt(); + $("#search_start_more").val(search_start_more); + } }); }, 500); // 500ms delay } @@ -915,7 +962,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index de780d92a64..3a55d82b8ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -49,6 +49,8 @@ if (!defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE')) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager->initHooks(array('takeposinvoice')); global $mysoc; @@ -168,11 +170,6 @@ if ($invoice->socid > 0) { $soc->fetch(getDolGlobalString("$constforcompanyid")); } - -/* - * Actions - */ - // Change the currency of invoice if it was modified if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercurrency"])) { if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) { @@ -180,730 +177,738 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } +/* + * Actions + */ -// Action to record a payment on a TakePOS invoice -if ($action == 'valid' && $user->rights->facture->creer) { - $bankaccount = 0; - $error = 0; +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $invoice, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { - $bankaccount = GETPOST('accountid', 'int'); - } else { - if ($pay == 'LIQ') { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility - } elseif ($pay == "CHQ") { - $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility +if (empty($reshook)) { + // Action to record a payment on a TakePOS invoice + if ($action == 'valid' && $user->rights->facture->creer) { + $bankaccount = 0; + $error = 0; + + if (!empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { + $bankaccount = GETPOST('accountid', 'int'); } else { - $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = $conf->global->$accountname; + if ($pay == 'LIQ') { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility + } elseif ($pay == "CHQ") { + $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility + } else { + $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; + $bankaccount = $conf->global->$accountname; + } } - } - if ($bankaccount <= 0 && $pay != "delayed") { - $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); - $error++; - } + if ($bankaccount <= 0 && $pay != "delayed") { + $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); + $error++; + } - $now = dol_now(); - $res = 0; + $now = dol_now(); + $res = 0; - $invoice = new Facture($db); - $invoice->fetch($placeid); + $invoice = new Facture($db); + $invoice->fetch($placeid); - if ($invoice->total_ttc < 0) { - $invoice->type = $invoice::TYPE_CREDIT_NOTE; + if ($invoice->total_ttc < 0) { + $invoice->type = $invoice::TYPE_CREDIT_NOTE; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; - $sql .= " fk_soc = ".((int) $invoice->socid); - $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; - $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; - $sql .= " ORDER BY rowid DESC"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; + $sql .= " fk_soc = ".((int) $invoice->socid); + $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; + $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; + $sql .= " ORDER BY rowid DESC"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $fk_source = $obj->rowid; - if ($fk_source == null) { + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $fk_source = $obj->rowid; + if ($fk_source == null) { + fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); + } + } else { fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); } - } else { - fail($langs->transnoentitiesnoconv("NoPreviousBillForCustomer")); - } - $invoice->fk_facture_source = $fk_source; - $invoice->update($user); - } - - //$sav_FACTURE_ADDON = ''; - //if (!empty($conf->global->TAKEPOS_ADDON)) { - // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; - // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; - // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; - //} - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if ($error) { - dol_htmloutput_errors($errormsg, null, 1); - } elseif ($invoice->statut != Facture::STATUS_DRAFT) { - //If invoice is validated but it is not fully paid is not error and make the payment - if ($invoice->getRemainToPay() > 0) { - $res = 1; - } else { - dol_syslog("Sale already validated"); - dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); - } - } elseif (count($invoice->lines) == 0) { - $error++; - dol_syslog('Sale without lines'); - dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); - } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $invoice->validate($user); - if ($res < 0) { - $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - } - - // Restore save values - //if (!empty($sav_FACTURE_ADDON)) - //{ - // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; - //} - - // Add the payment - if (!$error && $res >= 0) { - $remaintopay = $invoice->getRemainToPay(); - if ($remaintopay > 0) { - $payment = new Paiement($db); - $payment->datepaye = $now; - $payment->fk_account = $bankaccount; - $payment->amounts[$invoice->id] = $amountofpayment; - if ($pay == 'LIQ') { - $payment->pos_change = price2num(GETPOST('excess', 'alpha')); - } - - // If user has not used change control, add total invoice payment - // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay - if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { - $payment->amounts[$invoice->id] = $remaintopay; - } - - $payment->paiementid = $paiementid; - $payment->num_payment = $invoice->ref; - - if ($pay != "delayed") { - $payment->create($user); - $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded - } + $invoice->fk_facture_source = $fk_source; + $invoice->update($user); } - if ($remaintopay == 0) { - dol_syslog("Invoice is paid, so we set it to status Paid"); - $result = $invoice->setPaid($user); - if ($result > 0) { - $invoice->paye = 1; - } - // set payment method - $invoice->setPaymentMethods($paiementid); - } else { - dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); - } - } else { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } -} + //$sav_FACTURE_ADDON = ''; + //if (!empty($conf->global->TAKEPOS_ADDON)) { + // $sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON; + // if ($conf->global->TAKEPOS_ADDON == "terminal") $conf->global->FACTURE_ADDON = $conf->global->{'TAKEPOS_ADDON'.$_SESSION["takeposterminal"]}; + // else $conf->global->FACTURE_ADDON = $conf->global->TAKEPOS_ADDON; + //} -if ($action == 'creditnote' && $user->rights->facture->creer) { - $creditnote = new Facture($db); - $creditnote->socid = $invoice->socid; - $creditnote->date = dol_now(); - $creditnote->module_source = 'takepos'; - $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $creditnote->type = Facture::TYPE_CREDIT_NOTE; - $creditnote->fk_facture_source = $placeid; - $creditnote->remise_absolue = $invoice->remise_absolue; - $creditnote->remise_percent = $invoice->remise_percent; - $creditnote->create($user); - - foreach ($invoice->lines as $line) { - // Extrafields - if (method_exists($line, 'fetch_optionals')) { - // load extrafields - $line->fetch_optionals(); - } - // Reset fk_parent_line for no child products and special product - if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { - $fk_parent_line = 0; - } - if ($invoice->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($invoice->tab_previous_situation_invoice)) { - // search the last standard invoice in cycle and the possible credit note between this last and invoice - // TODO Move this out of loop of $invoice->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } - - $maxPrevSituationPercent = 0; - foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if ($prevLine->id == $source_fk_prev_id) { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } - - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { - if ($prevLine->fk_prev_id == $source_fk_prev_id) { - $maxPrevSituationPercent = $prevLine->situation_percent; - - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; - - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } - - // prorata - $line->situation_percent += $maxPrevSituationPercent; - - //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } - } - - $line->fk_facture = $creditnote->id; - $line->fk_parent_line = $fk_parent_line; - - $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht = -$line->total_ht; - $line->total_tva = -$line->total_tva; - $line->total_ttc = -$line->total_ttc; - $line->total_localtax1 = -$line->total_localtax1; - $line->total_localtax2 = -$line->total_localtax2; - - $line->multicurrency_subprice = -$line->multicurrency_subprice; - $line->multicurrency_total_ht = -$line->multicurrency_total_ht; - $line->multicurrency_total_tva = -$line->multicurrency_total_tva; - $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked - - $creditnote->lines[] = $line; // insert new line in current object - - // Defined the new fk_parent_line - if ($result > 0 && $line->product_type == 9) { - $fk_parent_line = $result; - } - } - $creditnote->update_price(1); - - $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { - $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; - $conf->global->STOCK_CALCULATE_ON_BILL = 1; - $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); - $batch_rule = 0; - if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; - $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; - } - $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); - $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; - } else { - $res = $creditnote->validate($user); - } -} - -if ($action == 'history' || $action == 'creditnote') { - if ($action == 'creditnote') { - $placeid = $creditnote->id; - } else { - $placeid = (int) GETPOST('placeid', 'int'); - } - $invoice = new Facture($db); - $invoice->fetch($placeid); -} - -if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = getDolGlobalString("$constforcompanyid"); - $invoice->date = dol_now(); - $invoice->module_source = 'takepos'; - $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; - $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; - - if ($invoice->socid <= 0) { - $langs->load('errors'); - dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); - } else { - $placeid = $invoice->create($user); - if ($placeid < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); - $db->query($sql); - } -} - -if ($action == "addline") { - $prod = new Product($db); - $prod->fetch($idproduct); - - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - - $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; - $price = $datapriceofproduct['pu_ht']; - $price_ttc = $datapriceofproduct['pu_ttc']; - //$price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; - $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $cat = new Categorie($db); - $categories = $cat->containing($idproduct, 'product'); - $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); - if ($found !== false) { // If this product is a supplement - $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - if ($row[0] == null) { - $parent_line = $selectedline; + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if ($error) { + dol_htmloutput_errors($errormsg, null, 1); + } elseif ($invoice->statut != Facture::STATUS_DRAFT) { + //If invoice is validated but it is not fully paid is not error and make the payment + if ($invoice->getRemainToPay() > 0) { + $res = 1; } else { - $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } + } elseif (count($invoice->lines) == 0) { + $error++; + dol_syslog('Sale without lines'); + dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); + } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $invoice->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $invoice->validate($user); + if ($res < 0) { + $error++; + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); } } - } - $idoflineadded = 0; - // Group if enabled. Skip group if line already sent to the printer - if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { - foreach ($invoice->lines as $line) { - if ($line->product_ref == $prod->ref) { - if ($line->special_code==4) continue; // If this line is sended to printer create new line - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - if ($result < 0) { - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); - } else { - $idoflineadded = $line->id; + // Restore save values + //if (!empty($sav_FACTURE_ADDON)) + //{ + // $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON; + //} + + // Add the payment + if (!$error && $res >= 0) { + $remaintopay = $invoice->getRemainToPay(); + if ($remaintopay > 0) { + $payment = new Paiement($db); + $payment->datepaye = $now; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; + if ($pay == 'LIQ') { + $payment->pos_change = price2num(GETPOST('excess', 'alpha')); } - break; + + // If user has not used change control, add total invoice payment + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment > $remaintopay) { + $payment->amounts[$invoice->id] = $remaintopay; + } + + $payment->paiementid = $paiementid; + $payment->num_payment = $invoice->ref; + + if ($pay != "delayed") { + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded + } + } + + if ($remaintopay == 0) { + dol_syslog("Invoice is paid, so we set it to status Paid"); + $result = $invoice->setPaid($user); + if ($result > 0) { + $invoice->paye = 1; + } + // set payment method + $invoice->setPaymentMethods($paiementid); + } else { + dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay); + } + } else { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + } + + if ($action == 'creditnote' && $user->rights->facture->creer) { + $creditnote = new Facture($db); + $creditnote->socid = $invoice->socid; + $creditnote->date = dol_now(); + $creditnote->module_source = 'takepos'; + $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $creditnote->type = Facture::TYPE_CREDIT_NOTE; + $creditnote->fk_facture_source = $placeid; + $creditnote->remise_absolue = $invoice->remise_absolue; + $creditnote->remise_percent = $invoice->remise_percent; + $creditnote->create($user); + + foreach ($invoice->lines as $line) { + // Extrafields + if (method_exists($line, 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } + if ($invoice->type == Facture::TYPE_SITUATION) { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + if (!empty($invoice->tab_previous_situation_invoice)) { + // search the last standard invoice in cycle and the possible credit note between this last and invoice + // TODO Move this out of loop of $invoice->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($invoice->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } + + $maxPrevSituationPercent = 0; + foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { + if ($prevLine->id == $source_fk_prev_id) { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } + + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($invoice->tab_previous_situation_invoice[$index]->lines as $prevLine) { + if ($prevLine->fk_prev_id == $source_fk_prev_id) { + $maxPrevSituationPercent = $prevLine->situation_percent; + + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; + + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } + + // prorata + $line->situation_percent += $maxPrevSituationPercent; + + //print 'New line based on invoice id '.$invoice->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + } + } + + $line->fk_facture = $creditnote->id; + $line->fk_parent_line = $fk_parent_line; + + $line->subprice = -$line->subprice; // invert price for object + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + + $creditnote->lines[] = $line; // insert new line in current object + + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; } } - } - if ($idoflineadded <= 0) { - $invoice->fetch_thirdparty(); - $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); - if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { - $CUSTOMER_DISPLAY_line1 = $prod->label; - $CUSTOMER_DISPLAY_line2 = price($price_ttc); + $creditnote->update_price(1); + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { + $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; + $conf->global->STOCK_CALCULATE_ON_BILL = 1; + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey); + $batch_rule = 0; + if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST; + } + $res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule); + $conf->global->STOCK_CALCULATE_ON_BILL = $savconst; + } else { + $res = $creditnote->validate($user); } } - $invoice->fetch($placeid); -} - -if ($action == "freezone") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - $tva_tx = GETPOST('tva_tx', 'alpha'); - if ($tva_tx != '') { - if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); + if ($action == 'history' || $action == 'creditnote') { + if ($action == 'creditnote') { + $placeid = $creditnote->id; + } else { + $placeid = (int) GETPOST('placeid', 'int'); } - } else { - $tva_tx = get_default_tva($mysoc, $customer); - } - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); - $invoice->fetch($placeid); -} - -if ($action == "addnote") { - $desc = GETPOST('addnote', 'alpha'); - if ($idline==0) { - $invoice->update_note($desc, '_public'); - } else foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } - } - $invoice->fetch($placeid); -} - -if ($action == "deleteline") { - if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. - $invoice->deleteline($idline); - $invoice->fetch($placeid); - } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; - $resql = $db->query($sql); - $row = $db->fetch_array($resql); - $deletelineid = $row[0]; - $invoice->deleteline($deletelineid); + $invoice = new Facture($db); $invoice->fetch($placeid); } - if (count($invoice->lines) == 0) { - $invoice->delete($user); - header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); - exit; + + if (($action == "addline" || $action == "freezone") && $placeid == 0) { + $invoice->socid = getDolGlobalString("$constforcompanyid"); + $invoice->date = dol_now(); + $invoice->module_source = 'takepos'; + $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; + $invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity; + + if ($invoice->socid <= 0) { + $langs->load('errors'); + dol_htmloutput_errors($langs->trans("ErrorModuleSetupNotComplete", "TakePos"), null, 1); + } else { + $placeid = $invoice->create($user); + if ($placeid < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); + $db->query($sql); + } } -} -// Action to delete or discard an invoice -if ($action == "delete") { - // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. - if ($placeid > 0) { - $result = $invoice->fetch($placeid); + if ($action == "addline") { + $prod = new Product($db); + $prod->fetch($idproduct); - if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { - $db->begin(); + $customer = new Societe($db); + $customer->fetch($invoice->socid); - // We delete the lines - $resdeletelines = 1; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + + $qty = GETPOSTISSET('qty') ? GETPOST('qty', 'int') : 1; + $price = $datapriceofproduct['pu_ht']; + $price_ttc = $datapriceofproduct['pu_ttc']; + //$price_min = $datapriceofproduct['price_min']; + $price_base_type = $datapriceofproduct['price_base_type']; + $tva_tx = $datapriceofproduct['tva_tx']; + $tva_npr = $datapriceofproduct['tva_npr']; + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + if (!empty($conf->global->TAKEPOS_SUPPLEMENTS)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $cat = new Categorie($db); + $categories = $cat->containing($idproduct, 'product'); + $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); + if ($found !== false) { // If this product is a supplement + $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + if ($row[0] == null) { + $parent_line = $selectedline; + } else { + $parent_line = $row[0]; //If the parent line is already a supplement, add the supplement to the main product + } + } + } + + $idoflineadded = 0; + // Group if enabled. Skip group if line already sent to the printer + if (!empty($conf->global->TAKEPOS_GROUP_SAME_PRODUCT) && $line->special_code != "4") { foreach ($invoice->lines as $line) { - $tmpres = $invoice->deleteline($line->id); - if ($tmpres < 0) { - $resdeletelines = 0; + if ($line->product_ref == $prod->ref) { + if ($line->special_code==4) continue; // If this line is sended to printer create new line + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty + $qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if ($result < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } else { + $idoflineadded = $line->id; + } break; } } - - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; - $sql .= " datec = '".$db->idate(dol_now())."'"; - $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; - $resql1 = $db->query($sql); - - if ($resdeletelines && $resql1) { - $db->commit(); - } else { - $db->rollback(); + } + if ($idoflineadded <= 0) { + $invoice->fetch_thirdparty(); + $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', 0, 100, '', null, 0); + if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { + $CUSTOMER_DISPLAY_line1 = $prod->label; + $CUSTOMER_DISPLAY_line2 = price($price_ttc); } + } + $invoice->fetch($placeid); + } + + if ($action == "freezone") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); + + $tva_tx = GETPOST('tva_tx', 'alpha'); + if ($tva_tx != '') { + if (!preg_match('/\((.*)\)/', $tva_tx)) { + $tva_tx = price2num($tva_tx); + } + } else { + $tva_tx = get_default_tva($mysoc, $customer); + } + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $invoice->fetch($placeid); + } + + if ($action == "addnote") { + $desc = GETPOST('addnote', 'alpha'); + if ($idline==0) { + $invoice->update_note($desc, '_public'); + } else foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $result = $invoice->updateline($line->id, $desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + $invoice->fetch($placeid); + } + + if ($action == "deleteline") { + if ($idline > 0 and $placeid > 0) { // If invoice exists and line selected. To avoid errors if deleted from another device or no line selected. + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } elseif ($placeid > 0) { // If invoice exists but no line selected, proceed to delete last line. + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + $deletelineid = $row[0]; + $invoice->deleteline($deletelineid); $invoice->fetch($placeid); } + if (count($invoice->lines) == 0) { + $invoice->delete($user); + header("Location: ".DOL_URL_ROOT."/takepos/invoice.php"); + exit; + } } -} -if ($action == "updateqty") { - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + // Action to delete or discard an invoice + if ($action == "delete") { + // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. + if ($placeid > 0) { + $result = $invoice->fetch($placeid); + + if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { + $db->begin(); + + // We delete the lines + $resdeletelines = 1; + foreach ($invoice->lines as $line) { + $tmpres = $invoice->deleteline($line->id); + if ($tmpres < 0) { + $resdeletelines = 0; + break; + } + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $sql .= " SET fk_soc = ".((int) $conf->global->$varforconst).", "; + $sql .= " datec = '".$db->idate(dol_now())."'"; + $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; + $resql1 = $db->query($sql); + + if ($resdeletelines && $resql1) { + $db->commit(); + } else { + $db->rollback(); + } + + $invoice->fetch($placeid); } } } - $invoice->fetch($placeid); -} - -if ($action == "updateprice") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - $prod = new Product($db); - $prod->fetch($line->fk_product); - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); - //Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + if ($action == "updateqty") { + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); - } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } + + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} + if ($action == "updateprice") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); -if ($action == "updatereduction") { - $customer = new Societe($db); - $customer->fetch($invoice->socid); - - foreach ($invoice->lines as $line) { - if ($line->id == $idline) { - dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); - - $prod = new Product($db); - $prod->fetch($line->fk_product); - - $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); - - $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); - - // Check min price - if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { - echo $langs->trans("CantBeLessThanMinPrice"); - } else { - if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { - dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + $prod = new Product($db); + $prod->fetch($line->fk_product); + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); + //Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } else { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } } } } + + // Reload data + $invoice->fetch($placeid); } - // Reload data - $invoice->fetch($placeid); -} elseif ($action == 'update_reduction_global') { - foreach ($invoice->lines as $line) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); - } + if ($action == "updatereduction") { + $customer = new Societe($db); + $customer->fetch($invoice->socid); - $invoice->fetch($placeid); -} + foreach ($invoice->lines as $line) { + if ($line->id == $idline) { + dol_syslog("updatereduction Process line ".$line->id.' to apply discount of '.$number.'%'); -if ($action == "order" and $placeid != 0) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { - require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; - $printer = new dolReceiptPrinter($db); - } + $prod = new Product($db); + $prod->fetch($line->fk_product); - $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $row = $db->fetch_object($resql); - $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -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 ''.$obj->anotherfield.''; - 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; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + 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 ''; + print '
'.$langs->trans("LifeTime").'
'.$langs->trans("QCFrequency").'
'.$langs->trans("LifeTime").'
'.$langs->trans("QCFrequency").'
'.$langs->trans("CustomCode").''.$object->customcode.'
'.$langs->trans("CustomCode").''.$object->customcode.'
'.$langs->trans("Origin").''.getCountry($object->country_id, 0, $db); if (!empty($object->state_id)) { print ' - '.getState($object->state_id, 0, $db); } - print '
'.$langs->trans("LifeTime").'
'.$langs->trans("LifeTime").''.$object->lifetime.'
'.$langs->trans("QCFrequency").''.$object->qc_frequency.'
'; print price($pmp_valuation_real); print ''; $totalExpectedValuation += $pmp_valuation; $totalRealValuation += $pmp_valuation_real; } + + print ''; if ($obj->fk_movement > 0) { $stockmovment = new MouvementStock($db); $stockmovment->fetch($obj->fk_movement); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index ebe8f0552ce..abcc5f7da42 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -449,7 +449,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c840ff3438a..4066e164cc9 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -95,6 +95,10 @@ if ($year && $month && $day) { $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' } +$daytoparsegmt = dol_now('gmt'); +if ($yearofday && $monthofday && $dayofday) $daytoparsegmt = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday, 'gmt'); // xxxofday is value of day after submit action 'addtime' +elseif ($year && $month && $day) $daytoparsegmt = dol_mktime(0, 0, 0, $month, $day, $year, 'gmt'); // this are value submited after submit of action 'submitdateselect' + if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; $search_usertoprocessid = $usertoprocess->id; @@ -619,6 +623,11 @@ $numendworkingday = 0; $numstartworkingday = 0; // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { @@ -631,7 +640,7 @@ $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code); +$test = num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code); if ($test) { $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 591abb44181..768a23a7b9a 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -98,7 +98,7 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; @@ -509,6 +509,11 @@ $numendworkingday = 0; $numstartworkingday = 0; // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { @@ -519,25 +524,18 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - - // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow - //$tmparray = dol_getdate($dayinloop); - //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - //print dol_print_date($dayinloop, 'dayhour').' '; - //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; - //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; + $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day - $test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code); + $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) { $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } } -//var_dump($isavailable); @@ -669,13 +667,7 @@ if (!empty($arrayfields['timeconsumed']['checked'])) { } 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'); - /*print $dayinloopfromfirstdaytoshow; - print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour', 'gmt'); - print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour'); - print dol_print_date($dayinloopfromfirstdaytoshow, '%a', 'gmt'); - print dol_print_date($dayinloopfromfirstdaytoshow, '%a'); - print '
';*/ + $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. $cssweekend = 'weekend'; diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index adef0826992..37a2bb246ce 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -766,6 +766,7 @@ $form = new Form($db); print '
'; print ''; print ''; +print ''; print ''; print ''; @@ -788,7 +789,7 @@ if (!$conf->use_javascript_ajax) { ); print $form->selectarray("activate_PROJECT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->PROJECT_USE_SEARCH_TO_SELECT); print '"; } print ''; @@ -799,7 +800,7 @@ print ''; print ''; print ''; @@ -818,7 +819,7 @@ print ''; print ''; print ''; print '
'; - print ''; + print ''; print "
'.$langs->trans("AllowToSelectProjectFromOtherCompany").''; print ' '; print $form->textwithpicto('', $langs->trans('AllowToLinkFromOtherCompany')); -print ''; +print ''; print '
'.$langs->trans("TimesheetPreventAfterFollowingMonths").''; print ' '; -print ''; +print ''; print '
'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 510d7e23e62..98f2fed52b4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -150,6 +150,11 @@ class Project extends CommonObject */ public $price_booth; + /** + * @var float Max attendees + */ + public $max_attendees; + public $statuts_short; public $statuts_long; @@ -248,6 +253,7 @@ class Project extends CommonObject 'accept_booth_suggestions' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>147), 'price_registration' =>array('type'=>'double(24,8)', 'label'=>'PriceOfRegistration', 'enabled'=>1, 'visible'=>-1, 'position'=>148), 'price_booth' =>array('type'=>'double(24,8)', 'label'=>'PriceOfBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>149), + 'max_attendees' =>array('type'=>'integer', 'label'=>'MaxNbOfAttendees', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), @@ -372,6 +378,7 @@ class Project extends CommonObject $sql .= ", accept_booth_suggestions"; $sql .= ", price_registration"; $sql .= ", price_booth"; + $sql .= ", max_attendees"; $sql .= ", email_msgid"; $sql .= ", note_private"; $sql .= ", note_public"; @@ -399,6 +406,7 @@ class Project extends CommonObject $sql .= ", ".($this->accept_booth_suggestions ? 1 : 0); $sql .= ", ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : 'null'); $sql .= ", ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : 'null'); + $sql .= ", ".(strcmp($this->max_attendees, '') ? ((int) $this->max_attendees) : 'null'); $sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null'); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null'); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null'); @@ -509,6 +517,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 .= ", max_attendees = ".(strcmp($this->max_attendees, '') ? price2num($this->max_attendees) : "null"); $sql .= ", entity = ".((int) $this->entity); $sql .= " WHERE rowid = ".((int) $this->id); @@ -595,7 +604,7 @@ class Project extends CommonObject $sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,"; $sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,"; $sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,"; - $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth"; + $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth, max_attendees"; $sql .= " FROM ".MAIN_DB_PREFIX."projet"; if (!empty($id)) { $sql .= " WHERE rowid = ".((int) $id); @@ -653,6 +662,7 @@ class Project extends CommonObject $this->accept_booth_suggestions = (int) $obj->accept_booth_suggestions; $this->price_registration = $obj->price_registration; $this->price_booth = $obj->price_booth; + $this->max_attendees = $obj->max_attendees; $this->email_msgid = $obj->email_msgid; $this->db->free($resql); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b254ac2b26f..6ec329c41f4 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -226,7 +226,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -830,7 +830,7 @@ $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form- $moreforfilter .= ''; // If the user can view thirdparties other than his' -if ($user->rights->societe->client->voir || $socid) { +if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index d71cd9bca56..6d9e44c3799 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -185,7 +185,7 @@ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 1b8e116092f..4374ffb2d37 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1149,8 +1149,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Form to convert time spent into invoice if ($massaction == 'generateinvoice') { - print ''; - if ($projectstatic->thirdparty->id > 0) { print ''; print ''; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 0ee6fa10bc7..43ee8889131 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1271,17 +1271,21 @@ if ($ispaymentok) { // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; // Email to send for Event organization registration - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$object->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfRegistrationWasReceived"); } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -1300,7 +1304,7 @@ if ($ispaymentok) { if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + dol_syslog("Failed to send EMail to ".$sendto.' - '.$mailfile->error, LOG_ERR, 0, '_payment'); } } } @@ -1456,14 +1460,18 @@ if ($ispaymentok) { // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, ''); + $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH; // Email sent after registration for a Booth + + if (!empty($idoftemplatetouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1, ''); } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; + } else { + $subject = '['.$booth->ref.' - '.$outputlangs->trans("NewRegistration").']'; + $msg = $outputlangs->trans("OrganizationEventPaymentOfBoothWasReceived"); } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 1736deef246..ce30306eb2f 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -47,10 +47,19 @@ $langs->loadLangs(array("companies", "other", "recruitment")); // Get parameters $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); -$email = GETPOST('email', 'alpha'); $backtopage = ''; -$ref = GETPOST('ref', 'alpha'); +// 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; if (GETPOST('btn_view')) { unset($_SESSION['email_customer']); @@ -61,15 +70,6 @@ if (isset($_SESSION['email_customer'])) { $object = new RecruitmentJobPosition($db); -if (!$action) { - if (!$ref) { - print $langs->trans('ErrorBadParameters')." - ref missing"; - exit; - } else { - $object->fetch('', $ref); - } -} - // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -111,7 +111,7 @@ $arrayofjs = array(); $arrayofcss = array(); $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; -llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1); +llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); print ''."\n"; @@ -151,8 +151,7 @@ if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumb if ($urllogo) { print '
'; print '
'; - print ''; + print ''; print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { print ''; @@ -167,10 +166,130 @@ if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { } -// TODO List of jobs -print '
'; -print $langs->trans("FeatureNotYetAvailable"); +$results = $object->fetchAll($sortfield, $sortorder, 0, 0, array('status' => 1)); +if (is_array($results)) { + if (empty($results)) { + print '
'; + print $langs->trans("NoPositionOpen"); + } else { + print '


'; + print ''.$langs->trans("WeAreRecruiting").''; + print '


'; + print '
'; + + foreach ($results as $job) { + $object = $job; + + print '
'."\n"; + + // Output introduction text + $text = ''; + if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) { + $reg = array(); + if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) { + $text .= $langs->trans($reg[1])."
\n"; + } else { + $text .= $conf->global->RECRUITMENT_NEWFORM_TEXT."
\n"; + } + $text = ''."\n"; + } + if (empty($text)) { + $text .= ''."\n"; + $text .= ''."\n"; + } + print $text; + + // Output payment summary form + print ''."\n"; + + print '

'.$text.'

'.$langs->trans("JobOfferToBeFilled", $mysoc->name); + $text .= '   -   '.$mysoc->name.''; + $text .= '   -   '.dol_print_date($object->date_creation).''; + $text .= '

'.$object->label.'

'; + + print '
'; + print '
'.$langs->trans("ThisIsInformationOnJobPosition").' :
'."\n"; + + $error = 0; + $found = true; + + print '
'; + + // Label + print $langs->trans("Label").' : '; + print ''.dol_escape_htmltag($object->label).'
'; + + // Date + print $langs->trans("DateExpected").' : '; + print ''; + if ($object->date_planned > $now) { + print dol_print_date($object->date_planned, 'day'); + } else { + print $langs->trans("ASAP"); + } + print '
'; + + // Remuneration + print $langs->trans("Remuneration").' : '; + print ''; + print dol_escape_htmltag($object->remuneration_suggested); + print '
'; + + // Contact + $tmpuser = new User($db); + $tmpuser->fetch($object->fk_user_recruiter); + + print $langs->trans("ContactForRecruitment").' : '; + $emailforcontact = $object->email_recruiter; + if (empty($emailforcontact)) { + $emailforcontact = $tmpuser->email; + if (empty($emailforcontact)) { + $emailforcontact = $mysoc->email; + } + } + print ''; + print $tmpuser->getFullName(-1); + print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); + print ''; + print '
'; + + if ($object->status == RecruitmentJobPosition::STATUS_RECRUITED) { + print info_admin($langs->trans("JobClosedTextCandidateFound"), 0, 0, 0, 'warning'); + } + if ($object->status == RecruitmentJobPosition::STATUS_CANCELED) { + print info_admin($langs->trans("JobClosedTextCanceled"), 0, 0, 0, 'warning'); + } + + print '
'; + + // Description + + $text = $object->description; + print $text; + print ''; + + print '
'."\n"; + print "\n"; + + + if ($action != 'dosubmit') { + if ($found && !$error) { // We are in a management option and no error + } else { + dol_print_error_email('ERRORNEWONLINESIGN'); + } + } else { + // Print + } + + print '
'."\n"; + + print '



'."\n"; + } + } +} else { + dol_print_error($db, $object->error, $object->errors); +} print ''."\n"; print '
'."\n"; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index d105632abe8..97997830150 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -177,7 +177,7 @@ $arrayofjs = array(); $arrayofcss = array(); $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; -llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1); +llxHeader($head, $langs->trans("PositionToBeFilled"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); print ''."\n"; @@ -217,8 +217,7 @@ if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumb if ($urllogo) { print '
'; print '
'; - print ''; + print ''; print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { print ''; @@ -233,12 +232,12 @@ if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { } -print ''."\n"; +print '
'."\n"; // Output introduction text $text = ''; if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) { - $langs->load("recruitment"); + $reg = array(); if (preg_match('/^\((.*)\)$/', $conf->global->RECRUITMENT_NEWFORM_TEXT, $reg)) { $text .= $langs->trans($reg[1])."
\n"; } else { @@ -249,9 +248,9 @@ if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) { if (empty($text)) { $text .= ''."\n"; - $text .= ''."\n"; + $text .= ''."\n"; } print $text; @@ -300,7 +299,7 @@ if (empty($emailforcontact)) { } print ''; print $tmpuser->getFullName(-1); -print ' - '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 1); +print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); print ''; print '
'; @@ -335,6 +334,7 @@ if ($action != 'dosubmit') { print ''."\n"; print '

'.$langs->trans("JobOfferToBeFilled", $mysoc->name); $text .= '   -   '.$mysoc->name.''; - $text .= '   -   '.dol_print_date($object->date_creation); + $text .= '   -   '.dol_print_date($object->date_creation).''; $text .= '

'.$object->label.'


'.$object->label.'


'."\n"; + print ''."\n"; print '
'."\n"; print '
'; diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 51424d9277e..371789edc62 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -264,11 +264,11 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'

'; $message .= $infos_new_ticket; - $message .= $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText'); + $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name)); $sendto = GETPOST('email', 'alpha'); - $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>'; $replyto = $from; $sendtocc = ''; $deliveryreceipt = 0; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 1a3c0c3babd..22b5fb2aba3 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -249,7 +249,7 @@ if ($action == "view_ticketlist") { ); // Extra fields - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') { $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' =>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3) && $extrafields->attributes[$object->table_element]['perms'][$key]); @@ -342,7 +342,7 @@ if ($action == "view_ticketlist") { $sql .= " t.tms,"; $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label"; // Add fields for extrafields - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($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 : ''); } @@ -655,7 +655,7 @@ if ($action == "view_ticketlist") { } // Extra fields - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($arrayfields["ef.".$key]['checked'])) { print 'entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/styles.css.php'; } else { - $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; + $original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference diff --git a/htdocs/public/website/styles.css.php b/htdocs/public/website/styles.css.php index a0002b5380b..73cbed73dbd 100644 --- a/htdocs/public/website/styles.css.php +++ b/htdocs/public/website/styles.css.php @@ -122,7 +122,7 @@ if (empty($pageid)) // Security: Delete string ../ into $original_file global $dolibarr_main_data_root; -$original_file = $dolibarr_main_data_root.'/website/'.$website.'/styles.css.php'; +$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/styles.css.php'; // Find the subdirectory name as the reference $refname = basename(dirname($original_file)."/"); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 8575c84c026..b3b039c2f68 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -166,6 +166,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } if (empty($reshook)) { + // Mass actions + $objectclass = 'Reception'; + $objectlabel = 'Receptions'; + $permissiontoread = $user->rights->reception->lire; + $permissiontoadd = $user->rights->reception->creer; + $permissiontodelete = $user->rights->reception->supprimer; + $uploaddir = $conf->reception->multidir_output[$conf->entity]; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + if ($massaction == 'confirm_createbills') { $receptions = GETPOST('toselect', 'array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); diff --git a/htdocs/recruitment/admin/setup.php b/htdocs/recruitment/admin/setup.php index 6091da86b09..30434b207fc 100644 --- a/htdocs/recruitment/admin/setup.php +++ b/htdocs/recruitment/admin/setup.php @@ -120,10 +120,10 @@ if ($action == 'updateMask') { $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/mymodule/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/recruitment/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { $filefound = 1; - $classname = "pdf_".$modele; + $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } @@ -134,7 +134,7 @@ if ($action == 'updateMask') { $module = new $classname($db); if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=recruitment-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); return; } else { setEventMessages($module->error, null, 'errors'); @@ -501,7 +501,8 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Preview print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'generic').''; + $newname = preg_replace('/_'.preg_quote(strtolower($myTmpObjectKey), '/').'/', '', $name); + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index e93e9af1178..77b5b5b21ae 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, 'picto'=>'recruitmentjobposition', 'css'=>'maxwidth500'), + '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', 'csslist'=>'minwidth125'), '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,), 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 50e978aceab..cc215a855ff 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 @@ -919,7 +919,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php index 3d3b59a9253..28e6128452d 100644 --- a/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php +++ b/htdocs/recruitment/lib/recruitment_recruitmentjobposition.lib.php @@ -41,12 +41,23 @@ function recruitmentjobpositionPrepareHead($object) $head[$h][2] = 'card'; $h++; - if ($conf->global->MAIN_FEATURES_LEVEL >= 1) { - $head[$h][0] = dol_buildpath("/recruitment/recruitmentjobposition_applications.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Candidatures"); - $head[$h][2] = 'candidatures'; - $h++; + $head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_list.php", 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("Candidatures"); + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature WHERE fk_recruitmentjobposition = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $nCandidature = $obj->nb; + if ($nCandidature > 0) { + $head[$h][1] .= ''.$nCandidature.''; + } + } + } else { + dol_print_error($db); } + $head[$h][2] = 'candidatures'; + $h++; if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 9cc259c21e1..74a48994f71 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -23,36 +23,7 @@ */ // 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 '../main.inc.php'; 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'; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 42145f66c43..eca3a497e61 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -42,36 +42,7 @@ // 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 '../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'; diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index 792b413b5e4..22e011daf42 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -23,36 +23,7 @@ */ // 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 '../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'; diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 05cf56636ea..2f3c73c16c4 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -1,6 +1,5 @@ - * 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 @@ -42,42 +41,14 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$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 '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load recruitment libraries -require_once __DIR__.'/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -85,17 +56,19 @@ require_once __DIR__.'/class/recruitmentcandidature.class.php'; // Load translation files required by the page $langs->loadLangs(array("recruitment", "other")); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + $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') : 'recruitmentcandidaturelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : ((empty($id) && empty($ref)) ? 'recruitmentcandidaturelist' : 'recruitmentjobposition_candidature'); // 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'); +$mode = GETPOST('mode', 'aZ'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -103,8 +76,9 @@ $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')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $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; @@ -123,10 +97,10 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition. } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "DESC"; } // Initialize array of search criterias @@ -136,6 +110,10 @@ 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" @@ -146,23 +124,33 @@ foreach ($object->fields as $key => $val) { } } -// Definition of fields for list +// 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 = dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1, 1, '1'); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), - 'position'=>$val['position'] + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' ); } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +// Load object +$jobposition = new RecruitmentJobPosition($db); +if ($id > 0 || !empty($ref)) { + $jobposition->fetch($id, $ref); + $id = $jobposition->id; +} + +//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -174,7 +162,12 @@ $permissiontodelete = $user->rights->recruitment->recruitmentjobposition->delete //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'); +if ($jobposition->id > 0) { + $isdraft = (($jobposition->status == $jobposition::STATUS_DRAFT) ? 1 : 0); + $result = restrictedArea($user, 'recruitment', $jobposition->id, 'recruitment_recruitmentjobposition', 'recruitmentjobposition', '', 'rowid', $isdraft); +} else { + $result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandidature', 'recruitmentjobposition'); +} @@ -183,7 +176,8 @@ $result = restrictedArea($user, 'recruitment', 0, 'recruitment_recruitmentcandid */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -203,8 +197,12 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -232,6 +230,8 @@ $now = dol_now(); //$help_url="EN:Module_RecruitmentCandidature|FR:Module_RecruitmentCandidature_FR|ES:Módulo_RecruitmentCandidature"; $help_url = ''; $title = $langs->trans('ListOfCandidatures'); +$morejs = array(); +$morecss = array(); // Build and execute select @@ -241,7 +241,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks @@ -253,29 +253,50 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (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 ($key == 'status' && $search[$key] == -1) { - continue; - } - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') { - $search[$key] = ''; + 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) || !empty($object->fields[$key]['arrayofkeyval'])) { + if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search("t.".$db->escape($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.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t.".$db->escape($columnName)." <= '" . $db->idate($search[$key])."'"; + } + } } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } } if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } +if (!empty($id)) { + $sql .= " AND t.fk_recruitmentjobposition = ".((int) $id); +} //$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'; @@ -286,9 +307,8 @@ $sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY "; -foreach ($object->fields as $key => $val) -{ - $sql .= "t.".$key.", "; +foreach ($object->fields as $key => $val) { + $sql .= "t.".$db->escape($key).", "; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -298,40 +318,39 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); */ -$sql .= $db->order($sortfield, $sortorder); - // 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; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + 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); @@ -344,11 +363,152 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); + + +// Part to show record + +if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $savobject = $object; + + $object = $jobposition; + + $res = $object->fetch_optionals(); + + $head = recruitmentjobpositionPrepareHead($object); + print dol_get_fiche_head($head, 'candidatures', $langs->trans("RecruitmentCandidatures"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRecruitmentJobPosition'), $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 = 'description'; // We change column just after 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(); + + print '
'; + + $object = $savobject; +} + $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($id)) { + $param .= '&id='.urlencode($id); +} +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -358,9 +518,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -369,6 +531,10 @@ if ($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( @@ -396,8 +562,10 @@ print ''; print ''; //print ''; print ''; +print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.((int) $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); @@ -446,23 +614,34 @@ print ''; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $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') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; @@ -482,12 +661,14 @@ print $searchpicto; print ''; print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $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'))) { @@ -508,7 +689,8 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $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 getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +$totalarray['nbfield']++; print ''."\n"; @@ -526,9 +708,11 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -537,73 +721,89 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != '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); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $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 == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $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 ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; + } $i++; } @@ -619,7 +819,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index ead2df3c973..d35edaa3b91 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -23,36 +23,7 @@ */ // 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 '../main.inc.php'; dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 3f9e76d4dcf..45c84005743 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -23,36 +23,7 @@ */ // 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 '../main.inc.php'; 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'; diff --git a/htdocs/recruitment/recruitmentjobposition_applications.php b/htdocs/recruitment/recruitmentjobposition_applications.php index 4295ce73284..c6e462161ed 100644 --- a/htdocs/recruitment/recruitmentjobposition_applications.php +++ b/htdocs/recruitment/recruitmentjobposition_applications.php @@ -195,92 +195,16 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); -$title = $langs->trans("PositionToBeFilled"); +$title = $langs->trans("JobPositionApplications"); $help_url = ''; llxHeader('', $title, $help_url); -// Part to create -if ($action == 'create') { - print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto); - - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - // Set some default values - if (!GETPOSTISSET('fk_user_recruiter')) { - $_POST['fk_user_recruiter'] = $user->id; - } - - print dol_get_fiche_head(array(), ''); - - print '
'; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); + } 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 '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { print ''; } print '
'; + print '
'; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + // Output Kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + 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($object->id, $arrayofselected)) { - $selected = 1; + // 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 ($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").'
'.$langs->trans("NoRecordFound").'
'."\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 $form->buttonsSaveCancel("Create"); - - print ''; - - //dol_set_focus('input[name="ref"]'); -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("PositionToBeFilled"), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - 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 $form->buttonsSaveCancel(); - - print '
'; -} - // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals(); diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index ab065411ac0..27b58bad651 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -42,36 +42,7 @@ // 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 '../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'; @@ -220,8 +191,6 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index e9615777ade..e3e79a5482e 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -23,36 +23,7 @@ */ // 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 '../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'; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 3bf5fb94073..50eca44baf3 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -1,6 +1,5 @@ - * 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 @@ -42,42 +41,12 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$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 '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment_recruitmentjobposition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load recruitment libraries -require_once __DIR__.'/class/recruitmentjobposition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); @@ -125,11 +94,10 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // 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. + $sortfield = "t.ref"; } if (!$sortorder) { - $sortorder = "ASC"; + $sortorder = "DESC"; } // Initialize array of search criterias @@ -171,6 +139,9 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields['nbapplications'] = array('type'=>'integer', 'label'=>'Applications', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index 2645980f7bb..883f5612b97 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -23,36 +23,7 @@ */ // 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 '../main.inc.php'; dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); dol_include_once('/recruitment/lib/recruitment_recruitmentjobposition.lib.php'); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 8ea35d43c33..da99b2f2e97 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -480,7 +480,7 @@ class Dolresource extends CommonObject * @param array $filter filter output * @return int <0 if KO, >0 if OK */ - public function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = '') + public function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = '') { // phpcs:enable global $conf; @@ -497,7 +497,7 @@ class Dolresource extends CommonObject $sql .= " t.fk_code_type_resource,"; $sql .= " t.tms,"; // Add fields from extrafields - if (!empty($extrafields->attributes[$this->table_element]['label'])) { + if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['label'])) { foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); } @@ -559,183 +559,6 @@ class Dolresource extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all_resources($sortorder, $sortfield, $limit, $offset, $filter = '') - { - // phpcs:enable - global $conf; - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.resource_id,"; - $sql .= " t.resource_type,"; - $sql .= " t.element_id,"; - $sql .= " t.element_type,"; - $sql .= " t.busy,"; - $sql .= " t.mandatory,"; - $sql .= " t.fk_user_create,"; - $sql .= " t.tms"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - - //Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= " AND ".$key." = '".$this->db->idate($value)."'"; - } else { - $sql .= " AND ".$key." LIKE '%".$this->db->escape($value)."%'"; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - $sql .= $this->db->plimit($limit + 1, $offset); - } - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->resource_id = $obj->resource_id; - $line->resource_type = $obj->resource_type; - $line->element_id = $obj->element_id; - $line->element_type = $obj->element_type; - $line->busy = $obj->busy; - $line->mandatory = $obj->mandatory; - $line->fk_user_create = $obj->fk_user_create; - - if ($obj->resource_id && $obj->resource_type) { - $line->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type); - } - if ($obj->element_id && $obj->element_type) { - $line->objelement = fetchObjectByElement($obj->element_id, $obj->element_type); - } - $this->lines[] = $line; - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load all objects into $this->lines - * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int <0 if KO, >0 if OK - */ - public function fetch_all_used($sortorder, $sortfield, $limit, $offset = 1, $filter = '') - { - // phpcs:enable - global $conf; - - if (!$sortorder) { - $sortorder = "ASC"; - } - if (!$sortfield) { - $sortfield = "t.rowid"; - } - - $sql = "SELECT "; - $sql .= " t.rowid,"; - $sql .= " t.resource_id,"; - $sql .= " t.resource_type,"; - $sql .= " t.element_id,"; - $sql .= " t.element_type,"; - $sql .= " t.busy,"; - $sql .= " t.mandatory,"; - $sql .= " t.fk_user_create,"; - $sql .= " t.tms"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'element_resources as t '; - $sql .= " WHERE t.entity IN (".getEntity('resource').")"; - - //Manage filter - if (!empty($filter)) { - foreach ($filter as $key => $value) { - if (strpos($key, 'date')) { - $sql .= " AND ".$key." = '".$this->db->idate($value)."'"; - } else { - $sql .= " AND ".$key." LIKE '%".$this->db->escape($value)."%'"; - } - } - } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - $sql .= $this->db->plimit($limit + 1, $offset); - } - dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - $this->lines = array(); - while ($obj = $this->db->fetch_object($resql)) { - $line = new Dolresource($this->db); - $line->id = $obj->rowid; - $line->resource_id = $obj->resource_id; - $line->resource_type = $obj->resource_type; - $line->element_id = $obj->element_id; - $line->element_type = $obj->element_type; - $line->busy = $obj->busy; - $line->mandatory = $obj->mandatory; - $line->fk_user_create = $obj->fk_user_create; - - $this->lines[] = fetchObjectByElement($obj->resource_id, $obj->resource_type); - } - $this->db->free($resql); - } - return $num; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch all resources available, declared by modules - * Load available resource in array $this->available_resources - * - * @return int number of available resources declared by modules - * @deprecated, remplaced by hook getElementResources - * @see getElementResources() - */ - public function fetch_all_available() - { - // phpcs:enable - global $conf; - - if (!empty($conf->modules_parts['resources'])) { - $this->available_resources = (array) $conf->modules_parts['resources']; - - return count($this->available_resources); - } - return 0; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update element resource into database diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index a541dfab700..705c3a70788 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php"; /** - * Classe permettant la gestion des formulaire du module resource + * Class to manage forms for the module resource * * \remarks Utilisation: $formresource = new FormResource($db) * \remarks $formplace->proprietes=1 ou chaine ou tableau de valeurs @@ -89,9 +89,9 @@ class FormResource $resourcestat = new Dolresource($this->db); - $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, 0, $filter); + $resources_used = $resourcestat->fetchAll('ASC', 't.rowid', $limit, 0, $filter); - if (!is_array($selected)) { + if (!empty($selected) && !is_array($selected)) { $selected = array($selected); } @@ -130,13 +130,14 @@ class FormResource $label .= ' ('.$langs->trans($resourceclass).')'; } - if ((is_object($selected[0]) && $selected[0]->id == $resourcestat->lines[$i]->id) || (!is_object($selected[0]) && in_array($resourcestat->lines[$i]->id, $selected))) { + // Test if entry is the first element of $selected. + if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->id == $resourcestat->lines[$i]->id) || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($resourcestat->lines[$i]->id, $selected))) { $out .= ''; } else { $out .= ''; } - array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label)); + array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->id, 'label'=>$label)); $i++; if (($i % 10) == 0) { diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 97d55c7bb33..382503ed430 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -199,7 +199,7 @@ print ''; print ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $ret = $object->fetch_all('', '', 0, 0, $filter); + $ret = $object->fetchAll('', '', 0, 0, $filter); if ($ret == -1) { dol_print_error($db, $object->error); exit; @@ -209,7 +209,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } // Load object list -$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset, $filter); +$ret = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); if ($ret == -1) { dol_print_error($db, $object->error); exit; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 76236bb88aa..08e850c259a 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -164,9 +164,9 @@ class PaymentSalary extends CommonObject $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " VALUES (".((int) $conf->entity).", ".((int) $this->chid).", '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 4f7ea9d777c..957e76ac440 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -506,7 +506,7 @@ print '
'; print $form->textwithpicto($langs->trans("TakeposBarcodeRuleToInsertProduct"), $langs->trans("TakeposBarcodeRuleToInsertProductDesc")); print ''; - print ''; + print ''; print "
'; - $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; - $order_receipt_printer1 = ""; - $order_receipt_printer2 = ""; - $order_receipt_printer3 = ""; - $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); - $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); - $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); - $linestoprint = 0; - foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { - continue; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); + $price_min = $datapriceofproduct['price_min']; + $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); + + $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); + + // Check min price + if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { + echo $langs->trans("CantBeLessThanMinPrice"); + } else { + if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { + dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } else { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + } + } } - $c = new Categorie($db); - $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); - $result = array_intersect($catsprinter1, $existing); - $count = count($result); - if (!$line->fk_product) { - $count++; // Print Free-text item (Unassigned printer) to Printer 1 + + // Reload data + $invoice->fetch($placeid); + } elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } - if ($count > 0) { - $linestoprint++; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 - $db->query($sql); - $order_receipt_printer1 .= '
'; - if ($line->fk_product) { - $order_receipt_printer1 .= $line->product_label; + + $invoice->fetch($placeid); + } + + if ($action == "order" and $placeid != 0) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; + $printer = new dolReceiptPrinter($db); + } + + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $resql = $db->query($sql); + $row = $db->fetch_object($resql); + $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; + $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; + $order_receipt_printer1 = ""; + $order_receipt_printer2 = ""; + $order_receipt_printer3 = ""; + $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); + $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); + $linestoprint = 0; + foreach ($invoice->lines as $line) { + if ($line->special_code == "4") { + continue; + } + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter1, $existing); + $count = count($result); + if (!$line->fk_product) { + $count++; // Print Free-text item (Unassigned printer) to Printer 1 + } + if ($count > 0) { + $linestoprint++; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='1' where rowid=".$line->id; //Set to print on printer 1 + $db->query($sql); + $order_receipt_printer1 .= '
'; + if ($line->fk_product) { + $order_receipt_printer1 .= $line->product_label; + } else { + $order_receipt_printer1 .= $line->description; + } + $order_receipt_printer1 .= ''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer1 .= '
'.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer2 .= '
'.$line->qty; + if (!empty($line->array_options['options_order_notes'])) { + $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; + } + $order_receipt_printer3 .= '
'.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer1 .= "
(".$line->array_options['options_order_notes'].")"; + } + $sectionwithinvoicelink .= '
'; + if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { + if (getDolGlobalString('TAKEPOS_PRINT_SERVER') && filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { + $sectionwithinvoicelink .= ' '; + } else { + $sectionwithinvoicelink .= ' '; } - $order_receipt_printer1 .= '
'.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer2 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer2 .= '
'.$line->qty; - if (!empty($line->array_options['options_order_notes'])) { - $order_receipt_printer3 .= "
(".$line->array_options['options_order_notes'].")"; - } - $order_receipt_printer3 .= '
'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f01820f93e9..9e50dd2c47d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -275,6 +275,8 @@ class User extends CommonObject public $datelastlogin; public $datepreviouslogin; + public $iplastlogin; + public $ippreviouslogin; public $datestartvalidity; public $dateendvalidity; @@ -435,6 +437,8 @@ class User extends CommonObject $sql .= " u.tms as datem,"; $sql .= " u.datelastlogin as datel,"; $sql .= " u.datepreviouslogin as datep,"; + $sql .= " u.iplastlogin,"; + $sql .= " u.ippreviouslogin,"; $sql .= " u.datelastpassvalidation,"; $sql .= " u.datestartvalidity,"; $sql .= " u.dateendvalidity,"; @@ -562,6 +566,8 @@ class User extends CommonObject $this->datem = $this->db->jdate($obj->datem); $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); + $this->iplastlogin = $obj->iplastlogin; + $this->ippreviouslogin = $obj->ippreviouslogin; $this->datestartvalidity = $this->db->jdate($obj->datestartvalidity); $this->dateendvalidity = $this->db->jdate($obj->dateendvalidity); @@ -2111,9 +2117,13 @@ class User extends CommonObject // phpcs:enable $now = dol_now(); + $userremoteip = getUserRemoteIP(); + $sql = "UPDATE ".$this->db->prefix()."user SET"; $sql .= " datepreviouslogin = datelastlogin,"; + $sql .= " ippreviouslogin = iplastlogin,"; $sql .= " datelastlogin = '".$this->db->idate($now)."',"; + $sql .= " iplastlogin = '".$this->db->escape($userremoteip)."',"; $sql .= " tms = tms"; // La date de derniere modif doit changer sauf pour la mise a jour de date de derniere connexion $sql .= " WHERE rowid = ".((int) $this->id); @@ -2122,6 +2132,8 @@ class User extends CommonObject if ($resql) { $this->datepreviouslogin = $this->datelastlogin; $this->datelastlogin = $now; + $this->ippreviouslogin = $this->iplastlogin; + $this->iplastlogin = $userremoteip; return 1; } else { $this->error = $this->db->lasterror().' sql='.$sql; @@ -3116,7 +3128,9 @@ class User extends CommonObject $this->datem = $now; $this->datelastlogin = $now; + $this->iplastlogin = '127.0.0.1'; $this->datepreviouslogin = $now; + $this->ippreviouslogin = '127.0.0.1'; $this->statut = 1; $this->entity = 1; @@ -3734,7 +3748,7 @@ class User extends CommonObject */ public function findUserIdByEmail($email) { - if ($this->findUserIdByEmailCache[$email]) { + if (isset($this->findUserIdByEmailCache[$email])) { return $this->findUserIdByEmailCache[$email]; } diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 04fa0035418..bf8bd407093 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -92,7 +92,7 @@ if (!$user->rights->user->user->lire && !$user->admin) { if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } diff --git a/htdocs/user/list.php b/htdocs/user/list.php index cd87e286225..422d36d791f 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -203,7 +203,7 @@ $childids = $user->getAllChildIds(1); if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -345,7 +345,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; -if (key_exists('label', $extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (u.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; @@ -551,7 +551,7 @@ if ($permissiontoadd) { if ($permissiontoadd) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } -//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').' '.$langs->trans("Delete"); +//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 950db09bb4b..33e3055e084 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -240,7 +240,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -//if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +//if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { // $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; //} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination2val AS pac2v ON pac2v.fk_prod_attr = t.rowid"; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 50272789948..2bcb3a17121 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -587,6 +587,8 @@ class Website extends CommonObject */ public function delete(User $user, $notrigger = false) { + global $conf; + dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; @@ -618,7 +620,7 @@ class Website extends CommonObject } if (!$error && !empty($this->ref)) { - $pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref; + $pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref; dol_delete_dir_recursive($pathofwebsite); } @@ -678,8 +680,8 @@ class Website extends CommonObject $oldidforhome = $object->fk_default_home; $oldref = $object->ref; - $pathofwebsiteold = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($oldref); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($newref); + $pathofwebsiteold = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($oldref); + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($newref); dol_delete_dir_recursive($pathofwebsitenew); $fileindex = $pathofwebsitenew.'/index.php'; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index db9e1e035e7..5e611053f9b 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -642,7 +642,7 @@ class WebsitePage extends CommonObject if ($result > 0) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.'/website/'.$websiteobj->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websiteobj->ref; $filealias = $pathofwebsite.'/'.$this->pageurl.'.php'; $filetpl = $pathofwebsite.'/page'.$this->id.'.tpl.php'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1deca350864..bbac606a67e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -226,7 +226,7 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco global $dolibarr_main_data_root; -$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; +$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; @@ -2010,7 +2010,7 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || $tmpwebsite = new Website($db); if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$tmpwebsite->ref; } else { $tmpwebsite = $object; } @@ -2620,7 +2620,7 @@ if (!GETPOST('hide_websitemenu')) { if ($websitekey) { $virtualurl = ''; - $dataroot = DOL_DATA_ROOT.'/website/'.$websitekey; + $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; if (!empty($object->virtualhost)) { $virtualurl = $object->virtualhost; } @@ -3389,7 +3389,7 @@ if ($action == 'editcss') { // VirtualHost print '
'; - $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/{s1}'.$websitekey.'{s2}'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/{s1}'.$websitekey.'{s2}'); $htmltext = str_replace(array('{s1}', '{s2}'), array('', ''), $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); @@ -3583,7 +3583,7 @@ if ($action == 'createsite') { print '
'; $htmltext = $langs->trans("SetHereVirtualHost", '{s1}'); - $htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/website/websiteref', $htmltext); + $htmltext = str_replace('{s1}', DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref', $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}'); diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index af622481e28..df6d697f73f 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -852,6 +852,8 @@ class Workstation extends CommonObject //$langs->load("workstation"); $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv('Disabled'); $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv('Enabled'); } $statusType = 'status'.$status; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 900a1964800..37f24a38437 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -448,7 +448,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Clone if ($permissiontoadd) { - print ''.$langs->trans("ToClone").''."\n"; + print ''.$langs->trans("ToClone").''."\n"; } diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 0d17232c9db..540f6bc9c6b 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -42,6 +42,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'workstationlist'; // 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') +$mode = GETPOST('mode', 'aZ'); $id = GETPOST('id', 'int'); @@ -51,8 +52,9 @@ $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')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $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; @@ -108,13 +110,13 @@ $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, 1, '1'); + $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, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], - 'help' => empty($val['help']) ? '' : $val['help'] + 'help'=> isset($val['help']) ? $val['help'] : '' ); } } @@ -127,6 +129,7 @@ $arrayfields['wug.fk_usergroup'] = array( 'help' => empty($val['help']) ? '' : $val['help'] ); +/* disabled because adding resources to workstation seems not yet available in GUI $arrayfields['wr.fk_resource'] = array( 'label'=>$langs->trans('Resources'), 'checked'=>(($visible < 0) ? 0 : 1), @@ -134,6 +137,7 @@ $arrayfields['wr.fk_resource'] = array( 'position'=>1001, 'help' => empty($val['help']) ? '' : $val['help'] ); +*/ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -180,8 +184,8 @@ if (empty($reshook)) { $search[$key.'_dtend'] = ''; } } - $groups=$resources=array(); - $toselect = ''; + $groups = $resources=array(); + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -207,8 +211,8 @@ $formresource = new FormResource($db); $now = dol_now(); -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); $help_url = 'EN:Module_Workstation'; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); $morejs = array(); $morecss = array(); @@ -220,7 +224,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks @@ -229,7 +233,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if (!empty($groups)) { @@ -260,17 +264,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($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])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -300,47 +304,49 @@ $sql .= $hookmanager->resPrint; $sql.= " GROUP BY "; foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; + $sql .= "t.".$db->escape($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.', ' : ''); + 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); -//print $sql; // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + /* This old and fast method to get and count full list returns all record so use a high amount of memory. */ $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; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + 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); @@ -358,6 +364,9 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhoriz $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -367,9 +376,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -407,9 +418,12 @@ print ''; print ''; print ''; +print ''; print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/workstation/workstation_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/workstation/workstation_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -459,24 +473,22 @@ print ''; foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $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') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -517,6 +535,8 @@ print $searchpicto; print ''; print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- @@ -529,11 +549,12 @@ foreach ($object->fields as $key => $val) { $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') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $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"; + $totalarray['nbfield']++; } } @@ -550,17 +571,18 @@ if (!empty($arrayfields['wr.fk_resource']['checked'])) { // 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); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $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 getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +$totalarray['nbfield']++; 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) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && 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 @@ -572,8 +594,10 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$savnbfield = $totalarray['nbfield']; +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -581,116 +605,133 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); + $object->usergroups = WorkstationUserGroup::getAllGroupsOfWorkstation($obj->rowid); $object->resources = WorkstationResource::getAllResourcesOfWorkstation($obj->rowid); - // Show here line of result - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - 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); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $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 == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; } } - } - if (!empty($arrayfields['wug.fk_usergroup']['checked'])) { - $toprint = array(); - $cssforli = ''; - if (count($object->usergroups) >= 4) { - $cssforli = 'tdoverflowmax60'; - } elseif (count($object->usergroups) >= 2) { - $cssforli = 'tdoverflowmax80'; - } - foreach ($object->usergroups as $id_group) { - $g = new UserGroup($db); - $g->fetch($id_group); - $toprint[] = '
  • ' . $g->getNomUrl(1, '', 0, 'categtextwhite') . '
  • '; + if (!empty($arrayfields['wug.fk_usergroup']['checked'])) { + $toprint = array(); + $cssforli = ''; + if (count($object->usergroups) >= 4) { + $cssforli = 'tdoverflowmax60'; + } elseif (count($object->usergroups) >= 2) { + $cssforli = 'tdoverflowmax80'; + } + foreach ($object->usergroups as $id_group) { + $g = new UserGroup($db); + $g->fetch($id_group); + $toprint[] = '
  • ' . $g->getNomUrl(1, '', 0, 'categtextwhite') . '
  • '; + } + + print '
    '; } - print ''; + } + + // 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 (!empty($arrayfields['wr.fk_resource']['checked'])) { - $toprint = array(); - $cssforli = ''; - if (count($object->resources) >= 4) { - $cssforli = 'tdoverflowmax60'; - } elseif (count($object->resources) >= 2) { - $cssforli = 'tdoverflowmax80'; - } - foreach ($object->resources as $id_resource) { - $r = new Dolresource($db); - $r->fetch($id_resource); - $toprint[] = '
  • ' . $r->getNomUrl(1, '', '', 0, 'categtextwhite') . '
  • '; + if (!$i) { + $totalarray['nbfield']++; } - print ''; + print ''."\n"; } - // 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++; } @@ -705,7 +746,7 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 699e9fd89f0..c6ccc3b01a0 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -204,7 +204,7 @@ class UserTest extends PHPUnit\Framework\TestCase $newlocalobject=new User($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); - $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','trackid')), array()); // Actual, Expected + $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','iplastlogin','ippreviouslogin','trackid')), array()); // Actual, Expected return $localobject; }
    '; 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 ''; + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $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, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); } 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')); @@ -484,6 +496,12 @@ foreach ($object->fields as $key => $val) { print '
    '; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
    '; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
    '; + print '
    '; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + // Output Kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
    '; + print '
    '; + print '
      ' . implode(' ', $toprint) . '
    '; + print '
    '; - print '
      ' . implode(' ', $toprint) . '
    '; + if (!empty($arrayfields['wr.fk_resource']['checked'])) { + $toprint = array(); + $cssforli = ''; + if (count($object->resources) >= 4) { + $cssforli = 'tdoverflowmax60'; + } elseif (count($object->resources) >= 2) { + $cssforli = 'tdoverflowmax80'; + } + foreach ($object->resources as $id_resource) { + $r = new Dolresource($db); + $r->fetch($id_resource); + $toprint[] = '
  • ' . $r->getNomUrl(1, '', '', 0, 'categtextwhite') . '
  • '; + } + + print '
    '; + print '
      ' . implode(' ', $toprint) . '
    '; + 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 ''; - print '
      ' . implode(' ', $toprint) . '
    '; - 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").'
    '.$langs->trans("NoRecordFound").'