diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 68fe9de68d6..d7463d62172 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,8 +26,9 @@ Default **language here is english**. So please prepare your contributions in en 1. [Fork](https://help.github.com/articles/fork-a-repo) the [GitHub repository](https://github.com/Dolibarr/dolibarr). 2. Clone your fork. 3. Choose a branch(See the [Branches](#branches) section below). -4. Commit and push your changes. -5. [Make a pull request](https://help.github.com/articles/creating-a-pull-request). +4. Read our developer documentation on the [Dolibarr Wiki](https://wiki.dolibarr.org/index.php?title=Developer_documentation). +5. Commit and push your changes. +6. [Make a pull request](https://help.github.com/articles/creating-a-pull-request). ### Branches diff --git a/.travis.yml b/.travis.yml index b48a3667bb0..5d7eb7a1678 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,7 @@ jobs: php: nightly env: DB=mysql - stage: PHP Dev - if: type = push AND branch = 14.0 + if: type = push AND branch = 15.0 php: nightly env: DB=mysql @@ -411,6 +411,12 @@ script: php upgrade.php 13.0.0 14.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade13001400.log php upgrade2.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-2.log php step5.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-3.log + php upgrade.php 14.0.0 15.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade14001500.log + php upgrade2.php 14.0.0 15.0.0 > $TRAVIS_BUILD_DIR/upgrade14001500-2.log + php step5.php 14.0.0 15.0.0 > $TRAVIS_BUILD_DIR/upgrade14001500-3.log + php upgrade.php 15.0.0 16.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade15001600.log + php upgrade2.php 15.0.0 16.0.0 > $TRAVIS_BUILD_DIR/upgrade15001600-2.log + php step5.php 15.0.0 16.0.0 > $TRAVIS_BUILD_DIR/upgrade15001600-3.log ls -alrt $TRAVIS_BUILD_DIR/ - | diff --git a/ChangeLog b/ChangeLog index 8c52db8af69..a8211da486a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -138,6 +138,8 @@ NEW: Hidden option API_DISABLE_COMPRESSION is now visible in API setup page. NEW: Add hook printUnderHeaderPDFline on invoice PDF templates (can be used for example to add a barcode or more information on header of invoices). Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field + into forms will be broken. The security token field is expected since Dolibarr v9 but a lot of external modules did not implement it). * Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. * Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. * The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). diff --git a/README.md b/README.md index b0f7a2c3761..4e120a4cb91 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net/) [![GitHub release](https://img.shields.io/github/v/release/Dolibarr/dolibarr)](https://github.com/Dolibarr/dolibarr) +[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5521/badge)](https://bestpractices.coreinfrastructure.org/projects/5521) Dolibarr ERP & CRM is a modern software package that helps manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). diff --git a/SECURITY.md b/SECURITY.md index 9c28e2874b9..4e7e5fa933a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,13 +6,14 @@ This file contains some policies about the security reports on Dolibarr ERP CRM | Version | Supported | | ---------- | ---------------------- | -| <= 14.0.1 | :x: | -| >= 14.0.2+ | :white_check_mark: except CSRF attacks| +| <= 14.0.4 | :x: | +| >= 14.0.5+ | :white_check_mark: except CSRF attacks| | >= develop | :white_check_mark: | ## Reporting a Vulnerability -To report a vulnerability, please use GitHub security advisory at [https://github.com/Dolibarr/dolibarr/security/advisories/new](https://github.com/Dolibarr/dolibarr/security/advisories/new) (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) +To report a vulnerability, for a private report, please use GitHub security advisory at [https://github.com/Dolibarr/dolibarr/security/advisories/new](https://github.com/Dolibarr/dolibarr/security/advisories/new) (if you have permissions). +Alternatively send an email to security@dolibarr.org (for everybody) ## Hunting vulnerabilities on Dolibarr diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 8af707c4626..7f000290e1c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -58,8 +58,8 @@ $listoffset = GETPOST('listoffset', 'alpha'); $listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000; $active = 1; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8503f3acfd6..847891c949b 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -80,8 +80,8 @@ if (empty($accounting_product_mode)) { } $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", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 29a0171fe08..a563b653ac1 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -48,8 +48,8 @@ $socid = GETPOSTINT("socid"); // if ($user->socid) $socid=$user->socid; $limit = GETPOSTISSET('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == - 1) { $page = 0; @@ -157,7 +157,7 @@ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; $sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; -$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; +$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; /* if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index d62a1e9fc25..5c315bee9fc 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -48,8 +48,8 @@ $socid = GETPOSTINT("socid"); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == - 1) { $page = 0; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index a42439b1597..a4dcac8c1ad 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + /** * Class to manage accounting accounts */ @@ -566,7 +567,7 @@ class AccountingAccount extends CommonObject /** * Information on record * - * @param int $id of record + * @param int $id ID of record * @return void */ public function info($id) @@ -850,8 +851,8 @@ class AccountingAccount extends CommonObject // Level 3 (define $code_t): Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { - if (!empty($buyer->code_compta)) { - $code_t = $buyer->code_compta; + if (!empty($buyer->code_compta_product)) { + $code_t = $buyer->code_compta_product; $suggestedid = $accountingAccount['thirdparty']; $suggestedaccountingaccountfor = 'thridparty'; } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 42fb42b89fa..e96cf9e0997 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2114,15 +2114,26 @@ class BookKeepingLine public $montant; /** - * @var float Amount + * @var float Amount */ public $amount; + /** + * @var float Multicurrency amount + */ + public $multicurrency_amount; + + /** + * @var float Multicurrency code + */ + public $multicurrency_code; + /** * @var string Sens */ public $sens; public $lettering_code; + public $date_lettering; /** * @var int ID @@ -2153,4 +2164,9 @@ class BookKeepingLine * @var integer|string $date_validation; */ public $date_validation; + + /** + * @var integer|string $date_lim_reglement; + */ + public $date_lim_reglement; } diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index b7ec854fd7c..7ce226f99d8 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -153,9 +153,9 @@ if ($action == 'validatehistory') { $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " spe.accountancy_code_sell as company_code_sell"; + $sql .= " spe.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty } else { - $sql .= " s.accountancy_code_sell as company_code_sell"; + $sql .= " s.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty } $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; @@ -215,7 +215,7 @@ if ($action == 'validatehistory') { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta = $objp->company_code_sell; + $thirdpartystatic->code_compta_product = $objp->company_code_sell; // The accounting account for product stored on thirdparty object (for level3 suggestion) $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 582877d3599..56f904e79ef 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -539,13 +539,14 @@ if ($result) { $thirdpartystatic->client = $objp->client; $thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta = $objp->code_compta_client; // For backward compatibility $thirdpartystatic->code_compta_client = $objp->code_compta_client; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta_company = $objp->company_code_sell; + $thirdpartystatic->code_compta_product = $objp->company_code_sell; // The accounting account for product stored on thirdparty object (for level3 suggestion) $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 51c9e66cebe..70434a470f1 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -211,7 +211,7 @@ if ($action == 'validatehistory') { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta = $objp->company_code_sell; + $thirdpartystatic->code_compta_product = $objp->company_code_buy; // The accounting account for product stored on thirdparty object (for level3 suggestion) $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -230,7 +230,7 @@ if ($action == 'validatehistory') { $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - $facture_static->datef = $objp->datef; + $facture_static->date = $objp->datef; $facture_static_det->id = $objp->rowid; $facture_static_det->total_ht = $objp->total_ht; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index f88c1dd8ccc..6364ce914c6 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -547,7 +547,7 @@ if ($result) { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta_company = $objp->company_code_buy; + $thirdpartystatic->code_compta_product = $objp->company_code_buy; // The accounting account for product stored on thirdparty object (for level3 suggestion) $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 4b59039d313..cb942ba3176 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -39,8 +39,8 @@ $langs->loadLangs(array("companies", "members")); $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('rowid', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d7d72f70540..a2e3779d52b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -949,7 +949,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print load_fiche_titre($langs->trans("NewMember"), '', $object->picto); if ($conf->use_javascript_ajax) { - print "\n".''; print ''; } - print ''; + print ''; print ' '; print ''; print ''; @@ -1664,7 +1663,7 @@ if ($resql) { } } - // Action edit/delete + // Action edit/delete and select print ''; // Transaction reconciliated or edit link if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) { // If line not conciliated and account can be conciliated @@ -1692,19 +1691,14 @@ if ($resql) { print ''; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } // 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($obj->rowid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; } print ''; if (!$i) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 9f000786b7f..5d2bb71109b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1060,19 +1060,19 @@ if ($action == 'create') { // IBAN print ''.$langs->trans($ibankey).''; - print ''; + print ''; print ''.$langs->trans($bickey).''; - print ''; + print ''; if ($conf->prelevement->enabled) { print ''.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')'; - print ''; + print ''; } if ($conf->paymentbybanktransfer->enabled) { print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'; - print ''; + print ''; } print ''.$langs->trans("BankAccountDomiciliation").''; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 389c8195f37..78d45beadf3 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -50,8 +50,8 @@ if ($user->socid) { // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index ea656141639..6815a8d664b 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -79,8 +79,8 @@ if (!$allowed) { $diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 87fd36c498f..3417f05c817 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -78,8 +78,8 @@ if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid)) $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $pageplusone = GETPOST("pageplusone", 'int'); if ($pageplusone) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index fec2d025c7a..bbec4f23fc6 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -77,8 +77,8 @@ if (empty($search_datev_end)) { $search_datev_end = GETPOST("search_datev_end", 'int'); } -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 2f3004ae1d6..149710c975b 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -46,8 +46,8 @@ $smonth = (GETPOSTISSET('closemonth') ?GETPOST('closemonth', 'int') : dol_print_ $sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($now, "%d")); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index be7c88c0a1a..07c1176b9d2 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -62,8 +62,8 @@ if (!$year) { $search_account = GETPOST('search_account', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index b39364690a6..bc1d3790280 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -45,8 +45,8 @@ $langs->load("companies"); $mode = GETPOST("mode"); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index d588b7bff80..8af897378f5 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -38,8 +38,8 @@ if ($user->socid) { $result = restrictedArea($user, 'deplacement', '', ''); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index e7593406ad6..9f92cecc4a7 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -45,8 +45,8 @@ $search_ref = GETPOST('search_ref', 'int'); $search_name = GETPOST('search_name', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); // $search_amount=GETPOST('search_amount','alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 2e6ac4b6174..a76332197bc 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -71,8 +71,8 @@ $year_date_when = GETPOST('year_date_when'); $month_date_when = GETPOST('month_date_when'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c7376f961f8..ec8e2864451 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -264,6 +264,8 @@ if (empty($reshook)) { $result = $object->deleteline(GETPOST('lineid', 'int')); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; @@ -2889,6 +2891,7 @@ if ($action == 'create') { } $currency_code = $conf->currency; + $fk_account = 0; // Load objectsrc $remise_absolue = 0; @@ -3619,7 +3622,7 @@ if ($action == 'create') { // Bank Account if (!empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; - $fk_account = GETPOST('fk_account', 'int'); + $fk_account = GETPOSTISSET('fk_account') ? GETPOST('fk_account', 'int') : $fk_account; print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 19f70554637..047a66a78b9 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -470,11 +470,23 @@ class FactureRec extends CommonInvoice $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql .= " fk_soc = ".((int) $this->fk_soc); + $sql .= " entity = ".((int) $this->entity).","; + $sql .= " titre = '".$this->db->escape($this->title)."',"; + $sql .= " suspended = ".((int) $this->suspended).","; + $sql .= " fk_soc = ".((int) $this->socid).","; + $sql .= " total_tva = ".((float) $this->total_tva).","; + $sql .= " localtax1 = ".((float) $this->localtax1).","; + $sql .= " localtax2 = ".((float) $this->localtax2).","; + $sql .= " total_ht = ".((float) $this->total_ht).","; + $sql .= " total_ttc = ".((float) $this->total_ttc).","; + $sql .= " remise_percent = ".((float) $this->remise_percent); // TODO Add missing fields $sql .= " WHERE rowid = ".((int) $this->id); + $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { if (!$error) { @@ -498,7 +510,7 @@ class FactureRec extends CommonInvoice } else { $this->error = $this->db->lasterror(); $this->db->rollback(); - return -2; + return -1; } } @@ -531,9 +543,9 @@ class FactureRec extends CommonInvoice //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; if ($rowid) { - $sql .= ' AND f.rowid='.((int) $rowid); + $sql .= ' AND f.rowid = '.((int) $rowid); } elseif ($ref) { - $sql .= " AND f.titre='".$this->db->escape($ref)."'"; + $sql .= " AND f.titre = '".$this->db->escape($ref)."'"; } else { $sql .= ' AND f.rowid = 0'; } @@ -2130,6 +2142,7 @@ class FactureLigneRec extends CommonInvoiceLine $this->db->begin(); dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { if (!$error) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4f72b5a14a3..74d08ddef2a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4263,10 +4263,10 @@ class Facture extends CommonInvoice $clause = " WHERE"; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total_ht"; + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin, f.fk_statut, f.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON f.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; } @@ -4304,6 +4304,7 @@ class Facture extends CommonInvoice } } + $this->db->free($resql); return $response; } else { dol_print_error($this->db); @@ -5688,22 +5689,25 @@ class FactureLigne extends CommonInvoiceLine } /** - * Delete line in database - * TODO Add param User $user and notrigger (see skeleton) + * Delete line in database * - * @return int <0 if KO, >0 if OK + * @param User $tmpuser User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ - public function delete() + public function delete($tmpuser = null, $notrigger = false) { global $user; $this->db->begin(); // Call trigger - $result = $this->call_trigger('LINEBILL_DELETE', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; + if (empty($notrigger)) { + $result = $this->call_trigger('LINEBILL_DELETE', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } } // End call triggers @@ -5715,7 +5719,7 @@ class FactureLigne extends CommonInvoiceLine } $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->rowid); - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if ($this->db->query($sql)) { $this->db->commit(); return 1; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 89a67e75cb7..6eb05a16922 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -50,8 +50,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index d785ccbce93..a07d95094dd 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -96,8 +96,8 @@ $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5a0adb02d4a..c244229c5f8 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -147,8 +147,8 @@ if ($option == 'late') { $filtre = GETPOST('filtre', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$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; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index cf0fb079fcb..635727233d3 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -48,7 +48,7 @@ $paymentnum = GETPOST('num_paiement', 'alpha'); $socid = GETPOST('socid', 'int'); $sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'alpha'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $amounts = array(); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index ab6f0f5e574..93fdd415513 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -295,7 +295,7 @@ print ''; if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) { - dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; $bordereau = new RemiseCheque($db); $bordereau->fetch($bankline->fk_bordereau); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index f4d6c9e2686..d12caf36bbe 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -45,8 +45,8 @@ $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 0d928cf188f..3732e76b880 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -71,8 +71,8 @@ $search_amount = GETPOST("search_amount", 'alpha'); // alpha because we must be $search_status = GETPOST('search_status', 'intcomma'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -340,7 +340,6 @@ print ''; print ''; print ''; print ''; -print ''; print ''; print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index fb9809bd9f2..3812d72f405 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -439,6 +439,8 @@ if ($id > 0 || $ref) { } if ($num > 0) { + $total = price2num($total, 'MT'); + print ''; print ''.$langs->trans("Total").''; print ' '; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index c786c007988..e5697ab3cb3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1483,7 +1483,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1599,7 +1599,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1849,16 +1849,16 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1900,16 +1900,16 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; @@ -2072,16 +2072,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2096,11 +2096,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS.'').$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2138,16 +2138,16 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2162,11 +2162,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2300,4 +2300,78 @@ class BonPrelevement extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param string $mode Mode 'direct_debit' or 'credit_transfer' + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + */ + public function load_board($user, $mode) + { + // phpcs:enable + global $conf, $langs; + + if ($user->socid) { + return -1; // protection pour eviter appel par utilisateur externe + } + + /* + if ($mode == 'direct_debit') { + $sql = "SELECT b.rowid, f.datedue as datefin"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.entity IN (".getEntity('facture').")"; + $sql .= " AND f.total_ttc > 0"; + } else { + $sql = "SELECT b.rowid, f.datedue as datefin"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql .= " WHERE f.entity IN (".getEntity('facture_fourn').")"; + $sql .= " AND f.total_ttc > 0"; + } + + $resql = $this->db->query($sql); + if ($resql) { + $langs->load("banks"); + $now = dol_now(); + + $response = new WorkboardResponse(); + if ($mode == 'direct_debit') { + $response->warning_delay = $conf->prelevement->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("PendingDirectDebitToComplete"); + $response->labelShort = $langs->trans("PendingDirectDebitToCompleteShort"); + $response->url = DOL_URL_ROOT.'/compta/prelevement/index.php?leftmenu=checks&mainmenu=bank'; + } else { + $response->warning_delay = $conf->paymentbybanktransfer->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("PendingCreditTransferToComplete"); + $response->labelShort = $langs->trans("PendingCreditTransferToCompleteShort"); + $response->url = DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php?leftmenu=checks&mainmenu=bank'; + } + $response->img = img_object('', "payment"); + + while ($obj = $this->db->fetch_object($resql)) { + $response->nbtodo++; + + if ($this->db->jdate($obj->datefin) < ($now - $conf->withdraw->warning_delay)) { + $response->nbtodolate++; + } + } + + $response->nbtodo = 0; + $response->nbtodolate = 0; + // Return workboard only if quantity is not 0 + if ($response->nbtodo) { + return $response; + } else { + return 0; + } + } else { + dol_print_error($this->db); + $this->error = $this->db->error(); + return -1; + } + */ + return 0; + } } diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 5ac0c07ede7..86f1bcf583c 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -49,8 +49,8 @@ $search_societe = GETPOST('search_societe', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 3d05a17611c..342360bd454 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -52,8 +52,8 @@ $date_endyear = GETPOST('date_endyear', 'int'); $showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes'; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 66800c4d449..6918b2c84ee 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -47,8 +47,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index f5a60dc1380..8d63e52256e 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -68,14 +68,13 @@ $search_date_limit_endyear = GETPOST('search_date_limit_endyear', 'int'); $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear); $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear); $search_project_ref = GETPOST('search_project_ref', 'alpha'); -$search_project = GETPOST('search_project', 'alpha'); $search_users = GETPOST('search_users'); $search_type = GETPOST('search_type', 'int'); $search_account = GETPOST('search_account', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -176,7 +175,6 @@ if (empty($reshook)) { $search_date_limit_start = ''; $search_date_limit_end = ''; $search_project_ref = ''; - $search_project = ''; $search_users = ''; $search_type = ''; $search_account = ''; @@ -231,7 +229,7 @@ if (!empty($conf->projet->enabled)) { } } if (!empty($search_users)) { - $sql .= ' AND cs.fk_user IN('.implode(', ', $search_users).')'; + $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')'; } if (!empty($search_type) && $search_type > 0) { $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type); @@ -455,7 +453,7 @@ if (!empty($arrayfields['cs.periode']['checked'])) { // Filter: Project ref if (!empty($arrayfields['p.ref']['checked'])) { print ''; - print ''; + print ''; print ''; } @@ -657,7 +655,9 @@ while ($i < min($num, $limit)) { // Type if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { print ''; - if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + if (!empty($obj->payment_code)) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + } print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index f5bdf0db353..f5cbcc47502 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -50,8 +50,8 @@ $year = GETPOST("year", 'int'); $search_sc_type = GETPOST('search_sc_type', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 021bffe40b4..084516c52df 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -52,8 +52,8 @@ if (GETPOST("modecompta")) { $modecompta = GETPOST("modecompta"); } -$sortorder = GETPOST("sortorder", 'aZ09'); -$sortfield = GETPOST("sortfield", 'aZ09'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'aZ09comma'); if (!$sortorder) { $sortorder = "asc"; } diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 8e3169f1e8c..35d5028e938 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -51,8 +51,8 @@ if (GETPOST("modecompta")) { $modecompta = GETPOST("modecompta"); } -$sortorder = GETPOST("sortorder", 'aZ09'); -$sortfield = GETPOST("sortfield", 'aZ09'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'aZ09comma'); if (!$sortorder) { $sortorder = "asc"; } diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 10f7956c6b7..76dbc56beef 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -44,8 +44,8 @@ if (GETPOST("modecompta")) { $modecompta = GETPOST("modecompta"); } -$sortorder = GETPOST("sortorder", 'aZ09'); -$sortfield = GETPOST("sortfield", 'aZ09'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'aZ09comma'); if (!$sortorder) { $sortorder = "asc"; } diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 4e92325a323..f36383ad94b 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -36,8 +36,8 @@ if (GETPOST("modecompta")) { $modecompta = GETPOST("modecompta"); } -$sortorder = GETPOST("sortorder", 'aZ09'); -$sortfield = GETPOST("sortfield", 'aZ09'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'aZ09comma'); if (!$sortorder) { $sortorder = "asc"; } diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 0ea8418381d..0be2df11190 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -38,8 +38,8 @@ if (GETPOST("modecompta")) { $modecompta = GETPOST("modecompta"); } -$sortorder = GETPOST("sortorder", 'aZ09'); -$sortfield = GETPOST("sortfield", 'aZ09'); +$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'aZ09comma'); if (!$sortorder) { $sortorder = "asc"; } diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 67de87d0c21..a0573cf2812 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -48,8 +48,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 8c12dbfd704..f1731420852 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -56,8 +56,8 @@ $search_amount = GETPOST('search_amount', 'alpha'); $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); if (empty($page) || $page == -1) { diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 57e70e70a3d..488882c2649 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -46,8 +46,8 @@ if (!$year && $mode != 'tvaonly') { } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 293c4f11aa3..0eed6ba6219 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -88,8 +88,8 @@ if ($user->socid) { $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; @@ -212,7 +212,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 45923910633..bd0d694eb57 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -532,6 +532,8 @@ if (empty($reshook)) { * View */ +$form = new Form($db); +$formcompany = new FormCompany($db); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { @@ -540,9 +542,6 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $c $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -$form = new Form($db); -$formcompany = new FormCompany($db); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $objsoc = new Societe($db); @@ -1284,7 +1283,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($object->socid); // Thirdparty @@ -1462,14 +1465,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } print ''; - print ''; - print $langs->trans("VCard").''; - print ''; - print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); - print $langs->trans("Download"); - print ''; - print ''; - print ""; print '
'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index bc3441a6dc2..00cbfc4158a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1395,14 +1395,14 @@ class Contact extends CommonObject * @param string $moreparam Add more param into URL * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0, $morecss = '') { global $conf, $langs, $hookmanager; $result = ''; $label = ''; - if (!empty($this->photo) && class_exists('Form')) { $label .= '
'; $label .= Form::showphoto('contact', $this, 0, 40, 0, 'photoref', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. @@ -1454,7 +1454,7 @@ class Contact extends CommonObject $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('contactdao')); @@ -1476,7 +1476,7 @@ class Contact extends CommonObject $result .= $linkstart; if ($withpicto) { if ($withpicto == -2) { - $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; + $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; } else { $result .= img_object(($notooltip ? '' : $label), ( $this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index c7013d5570f..631bf932640 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -47,8 +47,8 @@ $socid = $object->thirdparty->id; // Sort & Order fields $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; @@ -122,7 +122,11 @@ print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses" $linkback = ''.$langs->trans("BackToList").''; -$morehtmlref = '
'; +$morehtmlref = ''; +$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); +$morehtmlref .= ''; + +$morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc->fetch($socid); // Thirdparty diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 1870e7b8d9c..3fac8adea15 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -51,8 +51,8 @@ if (!empty($canvas)) { // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; @@ -130,7 +130,11 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 7c722d31211..a3bfb861b0f 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -96,7 +96,11 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 285f71cae48..e90f8b46bd0 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -215,7 +215,11 @@ if ($action == 'edit') { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref .= ''; + + $morehtmlref .= '
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index eeeccddd671..edb54631786 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -57,8 +57,8 @@ if ($user->socid) { $result = restrictedArea($user, 'contrat', $id, ''); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index b4cf2fc1fbf..953fd0002d2 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -55,8 +55,8 @@ $result = restrictedArea($user, 'contrat', $id); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index ed980f9e86e..e6446e3585b 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -79,8 +79,8 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 31621ba420a..39dfe336a31 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -39,8 +39,8 @@ $optioncss = GETPOST('optioncss', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index bbbc95a19c5..a5efb52e787 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -170,8 +170,10 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto $event['code'] = $obj->code; $event['label'] = $obj->label; $event['location'] = $obj->location; - $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); - $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); + $event['reminder_date_formated_tzserver'] = dol_print_date($db->jdate($obj->dateremind), 'standard', 'tzserver'); + $event['event_date_start_formated_tzserver'] = dol_print_date($db->jdate($obj->datep), 'standard', 'tzserver'); + $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard', 'tzuser'); + $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard', 'tzuser'); $eventfound[$obj->id_agenda] = $event; } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index b9d3494d00b..14862f3cf43 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -94,12 +94,12 @@ class box_produits_alerte_stock extends ModeleBoxes $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0"; + $sql .= " AND p.seuil_stock_alerte > 0"; if (empty($user->rights->produit->lire)) { - $sql .= ' AND p.fk_product_type != 0'; + $sql .= ' AND p.fk_product_type <> 0'; } if (empty($user->rights->service->lire)) { - $sql .= ' AND p.fk_product_type != 1'; + $sql .= ' AND p.fk_product_type <> 1'; } // Add where from hooks if (is_object($hookmanager)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7de04ab0d14..029ac6cbfc1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3694,23 +3694,23 @@ abstract class CommonObject /** * Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into * this->linkedObjectsIds array + - * this->linkedObjects array if $loadalsoobjects = 1 + * this->linkedObjects array if $loadalsoobjects = 1 or $loadalsoobjects = type * Possible usage for parameters: * - all parameters empty -> we look all link to current object (current object can be source or target) - * - source id+type -> will get target list linked to source - * - target id+type -> will get source list linked to target - * - source id+type + target type -> will get target list of the type - * - target id+type + target source -> will get source list of the type + * - source id+type -> will get list of targets linked to source + * - target id+type -> will get list of sources linked to target + * - source id+type + target type -> will get list of targets of the type linked to source + * - target id+type + source type -> will get list of sources of the type linked to target * - * @param int $sourceid Object source id (if not defined, id of object) - * @param string $sourcetype Object source type (if not defined, element name of object) - * @param int $targetid Object target id (if not defined, id of object) - * @param string $targettype Object target type (if not defined, elemennt name of object) - * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided - * @param int $alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type. - * @param string $orderby SQL 'ORDER BY' clause - * @param int $loadalsoobjects Load also array this->linkedObjects (Use 0 to increase performances) - * @return int <0 if KO, >0 if OK + * @param int $sourceid Object source id (if not defined, id of object) + * @param string $sourcetype Object source type (if not defined, element name of object) + * @param int $targetid Object target id (if not defined, id of object) + * @param string $targettype Object target type (if not defined, element name of object) + * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided + * @param int $alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type. + * @param string $orderby SQL 'ORDER BY' clause + * @param int|string $loadalsoobjects Load also array this->linkedObjects. Use 0 to increase performances, Use 1 to load all, Use value of type ('facture', 'facturerec', ...) to load only a type of object. + * @return int <0 if KO, >0 if OK * @see add_object_linked(), updateObjectLinked(), deleteObjectLinked() */ public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) @@ -3892,10 +3892,9 @@ abstract class CommonObject $module = 'mrp'; } - - // Here $module, $classfile and $classname are set + // Here $module, $classfile and $classname are set, we can use them. if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) { - if ($loadalsoobjects) { + if ($loadalsoobjects && (is_numeric($loadalsoobjects) || ($loadalsoobjects === $objecttype))) { dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); if (class_exists($classname)) { @@ -6110,6 +6109,7 @@ abstract class CommonObject } $sql .= ")"; + $resql = $this->db->query($sql); if (!$resql) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 184b97a3c98..4c0ec1ff5a5 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1947,8 +1947,8 @@ class ExtraFields if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) { continue; } - if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') { - //when unticking boolean field, it's not set in POST + + if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) { continue; } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index d1b1e08710e..a40ec3e30c3 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -111,7 +111,7 @@ class HookManager if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) { // We instantiate action class only if initialized hook is handled by module // Include actions class overwriting hooks - if (empty($this->hooks[$context][$module]) || !is_object($this->hooks[$context][$module])) { // If set to an object value, class was already loaded + if (empty($this->hooks[$context][$module]) || !is_object($this->hooks[$context][$module])) { // If set to an object value, class was already loaded so we do nothing. $path = '/'.$module.'/class/'; $actionfile = 'actions_'.$module.'.class.php'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index de8c4519a22..88fca7b536a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3120,7 +3120,7 @@ class Form $sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock,"; $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; - $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; + $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name,"; $sql .= " pfp.supplier_reputation"; // if we use supplier description of the products if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { @@ -3275,7 +3275,7 @@ class Form $optlabel = $objp->ref; if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) { - $optlabel .= ' ('.$objp->ref_fourn.')'; + $optlabel .= ' ('.$objp->ref_fourn.')'; } if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) { $optlabel .= ' ('.$outbarcode.')'; @@ -3416,7 +3416,6 @@ class Form $opt .= "\n"; - // Add new entry // "key" value of json key array is used by jQuery automatically as selected value. Example: 'type' = product or service, 'price_ht' = unit price without tax // "label" value of json key array is used by jQuery automatically as text for combo box @@ -3427,7 +3426,11 @@ class Form 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, - 'price_ht'=>price2num($objp->unitprice, 'MT'), + 'price_qty_ht'=>price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty + 'price_unit_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price + 'price_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price (for compatibility) + 'tva_tx'=>$objp->tva_tx, + 'default_vat_code'=>$objp->default_vat_code, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, @@ -3662,7 +3665,7 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Charge dans cache la liste des délais de livraison possibles + * Load int a cache property th elist of possible delivery delays. * * @return int Nb of lines loaded, <0 if KO */ @@ -3671,7 +3674,7 @@ class Form // phpcs:enable global $langs; - $num = count($this->cache_availability); + $num = count($this->cache_availability); // TODO Use $conf->cache['availability'] instead of $this->cache_availability if ($num > 0) { return 0; // Cache already loaded } @@ -3755,7 +3758,7 @@ class Form { global $langs; - $num = count($this->cache_demand_reason); + $num = count($this->cache_demand_reason); // TODO Use $conf->cache['input_reason'] instead of $this->cache_demand_reason if ($num > 0) { return 0; // Cache already loaded } @@ -3851,7 +3854,7 @@ class Form // phpcs:enable global $langs; - $num = count($this->cache_types_paiements); + $num = count($this->cache_types_paiements); // TODO Use $conf->cache['payment_mode'] instead of $this->cache_types_paiements if ($num > 0) { return $num; // Cache already loaded } @@ -4092,7 +4095,7 @@ class Form // phpcs:enable global $langs; - $num = count($this->cache_transport_mode); + $num = count($this->cache_transport_mode); // TODO Use $conf->cache['payment_mode'] instead of $this->cache_transport_mode if ($num > 0) { return $num; // Cache already loaded } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index d4f4779a606..f5502426b00 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -352,7 +352,7 @@ class FormActions * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. * @param string $htmlname Name of select field * @param string $excludetype A type to exclude ('systemauto', 'system', '') - * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" + * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual", -2=Combined line is disabled (not implemented yet) * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value * @param int $multiselect 1=Allow multiselect of action type * @param int $nooutput 1=No output @@ -373,7 +373,7 @@ class FormActions $caction = new CActionComm($this->db); // Suggest a list with manual events or all auto events - $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot, '', 0); // If we use param 'all' instead of 'code', there is no group by include in answer but the key 'type' of answer array contains the key for the group by. if (empty($multiselect)) { // Add empty line at start only if no multiselect array_unshift($arraylist, ' '); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 80a9c75dffc..7ceca2f373b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1569,6 +1569,7 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 25ab99bfe01..4f5557279f4 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -215,7 +215,7 @@ class FormSetup $out = ''; $out .= ''; $out .= ''; - $out .= ' '; + $out .= ' '; $out .= ' '; $out .= ''; $out .= ''; @@ -353,7 +353,8 @@ class FormSetup */ $item = new FormSetupItem($confKey); - $item->setTypeFromTypeString($params['type']); + // need to be ignored from scrutinizer setTypeFromTypeString was created as deprecated to incite developper to use object oriented usage + /** @scrutinizer ignore-deprecated */ $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; @@ -560,13 +561,16 @@ class FormSetupItem /** @var string $helpText */ public $helpText = ''; - /** @var string $value */ + /** @var string $fieldValue */ public $fieldValue; + /** @var array $fieldAttr fields attribute only for compatible fields like input text */ + public $fieldAttr; + /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */ public $fieldOverride = false; - /** @var bool|string set this var to override field output */ + /** @var bool|string set this var to override field input */ public $fieldInputOverride = false; /** @var bool|string set this var to override field output */ @@ -583,6 +587,7 @@ class FormSetupItem /** * TODO each type must have setAs{type} method to help configuration * And set var as protected when its done configuration must be done by method + * this is important for retrocompatibility of futures versions * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ protected $type = 'string'; @@ -594,13 +599,19 @@ class FormSetupItem /** * Constructor * - * @param $confKey the conf key used in database + * @param string $confKey the conf key used in database */ public function __construct($confKey) { - global $langs, $db, $conf; + global $langs, $db, $conf, $form; $this->db = $db; - $this->form = new Form($this->db); + + if (!empty($form) && is_object($form) && get_class($form) == 'Form') { // the form class has a cache inside so I am using it to optimize + $this->form = $form; + } else { + $this->form = new Form($this->db); + } + $this->langs = $langs; $this->entity = $conf->entity; @@ -700,6 +711,10 @@ class FormSetupItem return $this->fieldInputOverride; } + $this->fieldAttr['name'] = $this->confKey; + $this->fieldAttr['id'] = 'setup-'.$this->confKey; + $this->fieldAttr['value'] = $this->fieldValue; + $out = ''; if ($this->type == 'title') { @@ -726,7 +741,9 @@ class FormSetupItem $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } } else { - $out.= ''; + if (empty($this->fieldAttr)) { $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass); } + + $out.= 'fieldAttr).' />'; } return $out; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index eaf4804b213..f69dcb2874d 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -249,7 +249,7 @@ class Link extends CommonObject $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll num=".((int) $num), LOG_DEBUG); if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) { $link = new Link($this->db); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index c092690a505..f881447cd67 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -555,9 +555,9 @@ class Translate * Return translated value of key for special keys ("Currency...", "Civility...", ...). * Search in lang file, then into database. Key must be any complete entry into lang file: CurrencyEUR, ... * If not found, return key. - * The string return is not formated (translated with transnoentitiesnoconv) - * NOTE: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey), if you modify this function, - * check that getLabelFromKey is not called with same value than input. + * The string return is not formated (translated with transnoentitiesnoconv). + * NOTE: To avoid infinite loop (getLabelFromKey->transnoentities->getTradFromKey->getLabelFromKey), if you modify this function, + * check that getLabelFromKey is never called with the same value than $key. * * @param string $key Key to translate * @return string Translated string (translated with transnoentitiesnoconv) @@ -585,7 +585,7 @@ class Translate $newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label'); } elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg)) { // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method - //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); + //$newstr=$this->getLabelFromKey($db,$reg[1],'llx_c_input_reason','code','label'); } /* Disabled. There is too many cases where translation of $newstr is not defined is normal (like when output with setEventMessage an already translated string) @@ -945,9 +945,9 @@ class Translate * * @param DoliDB $db Database handler * @param string $key Translation key to get label (key in language file) - * @param string $tablename Table name without prefix - * @param string $fieldkey Field for key - * @param string $fieldlabel Field for label + * @param string $tablename Table name without prefix. This value must always be a hardcoded string and not a value coming from user input. + * @param string $fieldkey Field for key. This value must always be a hardcoded string and not a value coming from user input. + * @param string $fieldlabel Field for label. This value must always be a hardcoded string and not a value coming from user input. * @param string $keyforselect Use another value than the translation key for the where into select * @param int $filteronentity Use a filter on entity * @return string Label in UTF8 (but without entities) @@ -959,10 +959,15 @@ class Translate if ($key == '') { return ''; } + // Test should be useless because the 3 variables are never set from user input but we keep it in case of. + if (preg_match('/[^0-9A-Z_]/i', $tablename) || preg_match('/[^0-9A-Z_]/i', $fieldkey) || preg_match('/[^0-9A-Z_]/i', $fieldlabel)) { + $this->error = 'Bad value for parameter tablename, fieldkey or fieldlabel'; + return -1; + } //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit; - // Check if a translation is available (this can call getTradFromKey) + // Check if a translation is available (Note: this can call getTradFromKey that can call getLabelFromKey) $tmp = $this->transnoentitiesnoconv($key); if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString') { return $tmp; // Found in language array @@ -973,6 +978,7 @@ class Translate return $this->cache_labels[$tablename][$key]; // Found in cache } + // Not found in loaded language file nor in cache. So we will take the label into database. $sql = "SELECT ".$fieldlabel." as label"; $sql .= " FROM ".MAIN_DB_PREFIX.$tablename; $sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'"; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index e081c59b14b..b408985a92d 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -399,21 +399,23 @@ class Utils if ($execmethod == 2) { // With this method, there is no way to get the return code, only output $handlein = popen($fullcommandclear, 'r'); $i = 0; - while (!feof($handlein)) { - $i++; // output line number - $read = fgets($handlein); - // Exclude warning line we don't want - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) { - continue; - } - fwrite($handle, $read); - if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) { - $ok = 1; - } elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) { - $ok = 1; + if ($handlein) { + while (!feof($handlein)) { + $i++; // output line number + $read = fgets($handlein); + // Exclude warning line we don't want + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) { + continue; + } + fwrite($handle, $read); + if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) { + $ok = 1; + } elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) { + $ok = 1; + } } + pclose($handlein); } - pclose($handlein); } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index daa5f657549..fdbb755637a 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -62,6 +62,9 @@ abstract class DoliDB implements Database /** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $lasterrno; + /** @var string If we need to set a prefix specific to the database so it can be reused (when defined instead of MAIN_DB_PREFIX) to forge requests */ + public $prefix_db; + /** @var bool Status */ public $ok; /** @var string */ diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 77b0416956b..597031945f1 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -121,12 +121,13 @@ print ' display: none; } - a.alilevel0 { + a.alilevel0, span.spanlilevel0 { background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important; background-repeat: no-repeat !important; background-position-x: 10px; background-position-y: 16px; padding: 1em 15px 1em 40px; + display: block; } li.lilevel0 font.vsmenudisabled { background-repeat: no-repeat !important; diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index f4a4e59526a..af5952f6026 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -64,7 +64,7 @@ print "jQuery(document).ready(function () {\n"; //print " console.log('referrer=".dol_escape_js($_SERVER['HTTP_REFERER'])."');\n"; print ' var nowtime = Date.now();'; -print ' var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined +print ' var time_auto_update = '.max(1, getDolGlobalInt('MAIN_BROWSER_NOTIFICATION_FREQUENCY')).';'."\n"; // Always defined print ' var time_js_next_test;'."\n"; ?> diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index e806d9b5957..448677002df 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -240,6 +240,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle if (empty($nocommentremoval)) { $buf = preg_replace('/([,;ERLT\)])\s*--.*$/i', '\1', $buf); //remove comment from a line that not start with -- before add it to the buffer } + if ($buffer) $buffer .= ' '; $buffer .= trim($buf); } @@ -639,7 +640,7 @@ function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules) if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled) //$head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc); $head[$h][1] = $langs->trans("AvailableModules"); - $head[$h][1] .= $form->textwithpicto('', $langs->trans("YouMustEnableOneModule").'.

'.$desc.'', 1, warning); + $head[$h][1] .= $form->textwithpicto('', $langs->trans("YouMustEnableOneModule").'.

'.$desc.'', 1, 'warning'); } else { //$head[$h][1] = $langs->trans("AvailableModules").$form->textwithpicto(''.$nbofactivatedmodules.' / '.$nboftotalmodules.'', $desc, 1, 'help', '', 1, 3); $head[$h][1] = $langs->trans("AvailableModules").''.$nbofactivatedmodules.' / '.$nboftotalmodules.''; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4ce7d4691a4..2902430bf82 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -916,8 +916,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $form = new Form($db); $optioncss = GETPOST('optioncss', 'alpha'); - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); + $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $search_status = GETPOST("search_status", 'int'); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7b5cc92c75d..c70ea041e0a 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2270,13 +2270,13 @@ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('( /** * Security check when accessing to a document (used by document.php, viewimage.php and webservices to get documents). - * TODO Replace code that set $accesallowed by a call to restrictedArea() + * TODO Replace code that set $accessallowed by a call to restrictedArea() * * @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp'). Exemple: 'medias', 'invoice', 'logs', 'tax-vat', ... * @param string $original_file Relative path with filename, relative to modulepart. * @param string $entity Restrict onto entity (0=no restriction) * @param User $fuser User object (forced) - * @param string $refname Ref of object to check permission for external users (autodetect if not provided) + * @param string $refname Ref of object to check permission for external users (autodetect if not provided) or for hierarchy * @param string $mode Check permission for 'read' or 'write' * @return mixed Array with access information : 'accessallowed' & 'sqlprotectagainstexternals' & 'original_file' (as a full path name) * @see restrictedArea() @@ -2423,6 +2423,30 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; + } elseif (($modulepart == 'holiday') && !empty($conf->holiday->dir_output)) { + if ($fuser->rights->holiday->{$read} || preg_match('/^specimen/i', $original_file)) { + $accessallowed = 1; + // If we known $id of holiday, call checkUserAccessToObject to check permission on properties and hierarchy of leave request + if ($refname && !preg_match('/^specimen/i', $original_file)) { + include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + $tmpholiday = new Holiday($db); + $tmpholiday->fetch('', $refname); + $accessallowed = checkUserAccessToObject($user, array('holiday'), $tmpholiday, 'holiday', '', '', 'rowid', ''); + } + } + $original_file = $conf->holiday->dir_output.'/'.$original_file; + } elseif (($modulepart == 'expensereport') && !empty($conf->expensereport->dir_output)) { + if ($fuser->rights->expensereport->{$lire} || preg_match('/^specimen/i', $original_file)) { + $accessallowed = 1; + // If we known $id of expensereport, call checkUserAccessToObject to check permission on properties and hierarchy of expense report + if ($refname && !preg_match('/^specimen/i', $original_file)) { + include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $tmpexpensereport = new ExpenseReport($db); + $tmpexpensereport->fetch('', $refname); + $accessallowed = checkUserAccessToObject($user, array('expensereport'), $tmpexpensereport, 'expensereport', '', '', 'rowid', ''); + } + } + $original_file = $conf->expensereport->dir_output.'/'.$original_file; } elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { // Wrapping pour les apercu supplier invoice if ($fuser->rights->expensereport->{$lire}) { @@ -2686,7 +2710,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $tmptask = new Task($db); $tmptask->fetch('', $refname); - $accessallowed = checkUserAccessToObject($user, array('projet_task'), $tmptask->id, 'projet&project', '', '', 'rowid', ''); + $accessallowed = checkUserAccessToObject($user, array('projet_task'), $tmptask->id, 'projet_task&project', '', '', 'rowid', ''); } } $original_file = $conf->projet->dir_output.'/'.$original_file; @@ -2971,9 +2995,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $ret = array( - 'accessallowed' => $accessallowed, - 'sqlprotectagainstexternals'=>$sqlprotectagainstexternals, - 'original_file'=>$original_file + 'accessallowed' => ($accessallowed ? 1 : 0), + 'sqlprotectagainstexternals' => $sqlprotectagainstexternals, + 'original_file' => $original_file ); return $ret; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ed871204cae..28a20ad6b09 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -828,7 +828,10 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = // We replace chars from a/A to z/Z encoded with numeric HTML entities with the real char so we won't loose the chars at the next step (preg_replace). // No need to use a loop here, this step is not to sanitize (this is done at next step, this is to try to save chars, even if they are // using a non coventionnel way to be encoded, to not have them sanitized just after) - $out = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', 'realCharForNumericEntities', $out); + //$out = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', 'realCharForNumericEntities', $out); + $out = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', function ($m) { + return realCharForNumericEntities($m); }, $out); + // Now we remove all remaining HTML entities starting with a number. We don't want such entities. $out = preg_replace('/&#x?[0-9]+/i', '', $out); // For example if we have javascript with an entities without the ; to hide the 'a' of 'javascript'. @@ -1169,23 +1172,34 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) */ function dol_string_unaccent($str) { + global $conf; + if (utf8_check($str)) { + if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { + $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); + return $transliterator->transliterate($str); + } // See http://www.utf8-chartable.de/ $string = rawurlencode($str); $replacements = array( '%C3%80' => 'A', '%C3%81' => 'A', '%C3%82' => 'A', '%C3%83' => 'A', '%C3%84' => 'A', '%C3%85' => 'A', + '%C3%87' => 'C', '%C3%88' => 'E', '%C3%89' => 'E', '%C3%8A' => 'E', '%C3%8B' => 'E', '%C3%8C' => 'I', '%C3%8D' => 'I', '%C3%8E' => 'I', '%C3%8F' => 'I', + '%C3%91' => 'N', '%C3%92' => 'O', '%C3%93' => 'O', '%C3%94' => 'O', '%C3%95' => 'O', '%C3%96' => 'O', + '%C5%A0' => 'S', '%C3%99' => 'U', '%C3%9A' => 'U', '%C3%9B' => 'U', '%C3%9C' => 'U', + '%C3%9D' => 'Y', '%C5%B8' => 'y', '%C3%A0' => 'a', '%C3%A1' => 'a', '%C3%A2' => 'a', '%C3%A3' => 'a', '%C3%A4' => 'a', '%C3%A5' => 'a', '%C3%A7' => 'c', '%C3%A8' => 'e', '%C3%A9' => 'e', '%C3%AA' => 'e', '%C3%AB' => 'e', '%C3%AC' => 'i', '%C3%AD' => 'i', '%C3%AE' => 'i', '%C3%AF' => 'i', '%C3%B1' => 'n', '%C3%B2' => 'o', '%C3%B3' => 'o', '%C3%B4' => 'o', '%C3%B5' => 'o', '%C3%B6' => 'o', + '%C5%A1' => 's', '%C3%B9' => 'u', '%C3%BA' => 'u', '%C3%BB' => 'u', '%C3%BC' => 'u', - '%C3%BF' => 'y' + '%C3%BD' => 'y', '%C3%BF' => 'y' ); $string = strtr($string, $replacements); return rawurldecode($string); @@ -1985,7 +1999,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } } elseif (!$phototoshow) { // example if modulepart = 'societe' or 'photo' - $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); + $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photowithmargin photoref', 'small', 1, 0, $maxvisiblephotos); } if ($phototoshow) { @@ -3629,7 +3643,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'asset', 'bank_account', 'barcode', 'bank', 'bell', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'bug', 'building', - 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', + 'card', 'calendar', 'calendarmonth', 'calendarweek', 'calendarday', 'calendarperuser', 'calendarpertype', 'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'collab', 'company', 'contact', 'country', 'contract', 'conversation', 'cron', 'cubes', 'multicurrency', 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'dynamicprice', @@ -3641,7 +3655,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'label', 'language', 'link', 'list', 'list-alt', 'listlight', 'loan', 'lot', 'long-arrow-alt-right', 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'off', 'on', 'order', - 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', + 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'puce', + 'stock', 'resize', 'service', 'stats', 'trip', 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', @@ -3660,7 +3675,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $facolor = ''; $fasize = ''; $fa = 'fas'; - if (in_array($pictowithouttext, array('bell', 'clock', 'establishment', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { + if (in_array($pictowithouttext, array('card', 'bell', 'clock', 'establishment', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; } if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) { @@ -3673,7 +3688,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'billr'=>'file-invoice-dollar', 'billd'=>'file-medical', 'supplier_invoice'=>'file-invoice-dollar', 'supplier_invoicea'=>'file-excel', 'supplier_invoicer'=>'file-invoice-dollar', 'supplier_invoiced'=>'file-medical', 'bom'=>'shapes', - 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'collab'=>'people-arrows', 'conversation'=>'comments', 'country'=>'globe-americas', 'cron'=>'business-time', + 'card'=>'address-card', 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'collab'=>'people-arrows', 'conversation'=>'comments', 'country'=>'globe-americas', 'cron'=>'business-time', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accounting'=>'search-dollar', 'category'=>'tag', 'dollyrevert'=>'dolly', @@ -3693,10 +3708,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', - 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', + 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', 'recent' => 'question', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house', 'recurring'=>'history', + 'service'=>'concierge-bell', 'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier'=>'building', 'technic'=>'cogs', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', @@ -5318,7 +5334,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'CT'=Round to Max for totals with Tax of foreign currency accuracy * Numeric = Nb of digits for rounding (For example 2 for a percentage) * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) - * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). + * Put 2 if you know that number is a user input (so we know we have to fix decimal separator). * @return string Amount with universal numeric format (Example: '99.99999'). * If conversion fails to return a numeric, it returns: * - text unchanged or partial if ($rounding = ''): price2num('W9ç', '', 0) => '9ç', price2num('W9ç', '', 1) => 'W9ç', price2num('W9ç', '', 2) => '9ç' diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index d44da05fa38..7c32b377bd4 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -305,6 +305,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $texttoinsert .= "\t".$key." ".$type; if ($key == 'rowid') { $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY'; + } elseif ($type == 'timestamp') { + $texttoinsert .= ' DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'; } if ($key == 'entity') { $texttoinsert .= ' DEFAULT 1'; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 05993368802..2911564adef 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -461,9 +461,11 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } + print ''."\n"; + print '
'; - print '
'."\n"; + print '
'."\n"; if ($addformmessage) { print ''; print '
'; diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 28723ab87db..4375d14430b 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -404,7 +404,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } } - // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. + // Recall function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0, ''); if ($multicurrency_code) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e9e06708f7c..7f5daf77c4a 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -679,22 +679,23 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Title of task if (count($arrayfields) > 0 && !empty($arrayfields['t.label']['checked'])) { - print '
\n"; } @@ -822,29 +823,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } - // Contacts of tasks. Disabled, because available by default just after - /* - if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) { - print ''; - }*/ - if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) { + if (count($arrayfields) > 0 && !empty($arrayfields['c.budget_amount']['checked'])) { print ''; @@ -1385,6 +1389,10 @@ if ($action == 'create') { print ''; print ''; } else { + if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) { + print ''; + } + print $langs->trans("NA"); } print ''; diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index 1d7ee50e17c..68336e8dbf6 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -47,8 +47,8 @@ $ref = GETPOST('ref'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 81fbdd651db..378d95e00c8 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -95,7 +95,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$search_status = GETPOST('search_status'); +$search_status = GETPOST('search_status', 'intcomma'); $diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 1b82eb777b0..307294d5422 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -134,6 +134,14 @@ if ($object->id > 0) { } } +$candelete = 0; +if (!empty($user->rights->expensereport->supprimer)) { + $candelete = 1; +} +if ($object->statut == ExpenseReport::STATUS_DRAFT && $user->rights->expensereport->write && in_array($object->fk_user_author, $childids)) { + $candelete = 1; +} + // Security check if ($user->socid) { $socid = $user->socid; @@ -226,7 +234,7 @@ if (empty($reshook)) { } } - if ($action == 'confirm_delete' && GETPOST("confirm", 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->supprimer) { + if ($action == 'confirm_delete' && GETPOST("confirm", 'alpha') == "yes" && $id > 0 && $candelete) { $object = new ExpenseReport($db); $result = $object->fetch($id); $result = $object->delete($user); @@ -2737,7 +2745,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') { if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED) { // Delete print ''; - } elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED) { + } elseif ($candelete && $object->status != ExpenseReport::STATUS_CLOSED) { // Delete print ''; } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index d5695c7e49a..70dad3ff48f 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2252,7 +2252,7 @@ class ExpenseReport extends CommonObject $sql = "SELECT DISTINCT ur.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql .= " WHERE ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; - $sql .= "UNION"; + $sql .= " UNION"; $sql .= " SELECT DISTINCT ugu.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql .= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index d731c4c8c82..504101a1720 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -48,8 +48,8 @@ if ($user->socid) { $result = restrictedArea($user, 'expensereport', '', ''); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 0c84552c795..0953d314202 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -68,7 +68,7 @@ if ($page == -1) { $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -$sortorder = GETPOST('sortorder', 'alpha'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma'); if ($sortorder == "") { $sortorder = "DESC"; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index cc9e50ca52f..e14322a62e9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '15.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '16.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index fd3ec1fa34f..77932cf4e3d 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -531,10 +531,11 @@ if ($object->id > 0) { $num = $db->num_rows($query); + print '
'; print '
' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Value") . '
'; + $labeltoshow = ''; if ($showlineingray) { - print ''; + $labeltoshow .= ''; } //else print ''; for ($k = 0; $k < $level; $k++) { - print '
'; + $labeltoshow .= '
'; } - print $lines[$i]->label; + $labeltoshow .= dol_escape_htmltag($lines[$i]->label); for ($k = 0; $k < $level; $k++) { - print '
'; + $labeltoshow .= '
'; } if ($showlineingray) { - print '
'; + $labeltoshow .= '
'; } - //else print ''; + print '
'; + print $labeltoshow; print "'; - foreach (array('internal', 'external') as $source) { - $tab = $lines[$i]->liste_contact(-1, $source); - $num = count($tab); - if (!empty($num)) { - foreach ($tab as $contacttask) { - //var_dump($contacttask); - if ($source == 'internal') { - $c = new User($db); - } else { - $c = new Contact($db); - } - $c->fetch($contacttask['id']); - print $c->getNomUrl(1).' ('.$contacttask['libelle'].')
'; - } - } - } - print '
'; print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); $total_budget_amount += $lines[$i]->budget_amount; @@ -854,10 +833,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Contacts of task if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) { print ''; + $ifisrt = 1; foreach (array('internal', 'external') as $source) { $tab = $lines[$i]->liste_contact(-1, $source); - $num = count($tab); - if (!empty($num)) { + $numcontact = count($tab); + if (!empty($numcontact)) { foreach ($tab as $contacttask) { //var_dump($contacttask); if ($source == 'internal') { @@ -867,14 +847,19 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } $c->fetch($contacttask['id']); if (!empty($c->photo)) { - print $c->getNomUrl(-2).' '; + if (get_class($c) == 'User') { + print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); + } else { + print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); + } } else { if (get_class($c) == 'User') { - print $c->getNomUrl(2, '', 0, 0, 24, 1);//.' '; + print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); } else { - print $c->getNomUrl(2);//.' '; + print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); } } + $ifisrt = 0; } } } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 4f08f2a4141..4a20fbf96f2 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -626,24 +626,30 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } /** - * Check access by user to object is ok. - * This function is also called by restrictedArea that check before if module is enabled and if permission of user for $action is ok. + * Check that access by a given user to an object is ok. + * This function is also called by restrictedArea() that check before if module is enabled and if permission of user for $action is ok. * - * @param User $user User to check - * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...) - * @param int|string $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). - * @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). - * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. - * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) - * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @param string $parenttableforentity Parent table for entity. Example 'fk_website@website' - * @return bool True if user has access, False otherwise + * @param User $user User to check + * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...) + * @param int|string|Object $object Full object or object ID or list of object id. For example if we want to check a particular record (optional) is linked to a owned thirdparty (optional). + * @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). + * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. + * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) + * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) + * @param string $parenttableforentity Parent table for entity. Example 'fk_website@website' + * @return bool True if user has access, False otherwise * @see restrictedArea() */ -function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = '', $dbt_select = 'rowid', $parenttableforentity = '') +function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = '', $dbt_select = 'rowid', $parenttableforentity = '') { global $db, $conf; + if (is_object($object)) { + $objectid = $object->id; + } else { + $objectid = $object; // $objectid can be X or 'X,Y,Z' + } + //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); //print "user_id=".$user->id.", features=".join(',', $featuresarray).", feature2=".$feature2.", objectid=".$objectid; //print ", tableandshare=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select."
"; @@ -656,7 +662,7 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta foreach ($featuresarray as $feature) { $sql = ''; - //var_dump($feature); + //var_dump($feature);exit; // For backward compatibility if ($feature == 'member') { @@ -669,11 +675,15 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $feature = 'projet_task'; } + $checkonentitydone = 0; + + // Array to define rules of checks to do $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); // Test for task object + $checkhierarchy = array('expensereport', 'holiday'); $nocheck = array('barcode', 'stock'); // No test //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...). @@ -714,10 +724,12 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } - } elseif (in_array($feature, $checksoc)) { // We check feature = checksoc + $checkonentitydone = 1; + } + if (in_array($feature, $checksoc)) { // We check feature = checksoc // If external user: Check permission for external users if ($user->socid > 0) { - if ($user->socid <> $objectid) { + if ($user->socid != $objectid) { return false; } } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) { @@ -736,7 +748,10 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $sql .= " WHERE s.rowid IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } - } elseif (in_array($feature, $checkother)) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...). + + $checkonentitydone = 1; + } + if (in_array($feature, $checkother)) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...). // If external user: Check permission for external users if ($user->socid > 0) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; @@ -758,25 +773,19 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - if ($feature == 'agenda') { - // Also check owner or attendee for users without allactions->read - if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $action = new ActionComm($db); - $action->fetch($objectid); - if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) { - return false; - } - } - } - } elseif (in_array($feature, $checkproject)) { + + $checkonentitydone = 1; + } + if (in_array($feature, $checkproject)) { if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { + $projectid = $objectid; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($db); $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); $tmparray = explode(',', $tmps); - if (!in_array($objectid, $tmparray)) { + if (!in_array($projectid, $tmparray)) { return false; } } else { @@ -785,16 +794,21 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - } elseif (in_array($feature, $checktask)) { + + $checkonentitydone = 1; + } + if (in_array($feature, $checktask)) { if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { $task = new Task($db); $task->fetch($objectid); + $projectid = $task->fk_project; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $projectstatic = new Project($db); $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); + $tmparray = explode(',', $tmps); - if (!in_array($task->fk_project, $tmparray)) { + if (!in_array($projectid, $tmparray)) { return false; } } else { @@ -803,7 +817,10 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - } elseif (!in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield + + $checkonentitydone = 1; + } + if (!$checkonentitydone && !in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield // If external user: Check permission for external users if ($user->socid > 0) { if (empty($dbt_keyfield)) { @@ -845,11 +862,47 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta } //print $sql; + // For events, check on users assigned to event + if ($feature === 'agenda') { + // Also check owner or attendee for users without allactions->read + if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $action = new ActionComm($db); + $action->fetch($objectid); + if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) { + return false; + } + } + } + + // For some object, we also have to check it is in the user hierarchy + // Param $object must be the full object and not a simple id to have this test possible. + if (in_array($feature, $checkhierarchy) && is_object($object)) { + $childids = $user->getAllChildIds(1); + $useridtocheck = 0; + if ($feature == 'holiday') { + $useridtocheck = $object->fk_user; + if (!in_array($useridtocheck, $childids)) { + return false; + } + $useridtocheck = $object->fk_validator; + if (!in_array($useridtocheck, $childids)) { + return false; + } + } + if ($feature == 'expensereport') { + $useridtocheck = $object->fk_user_author; + if (!in_array($useridtocheck, $childids)) { + return false; + } + } + } + if ($sql) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if (!$obj || $obj->nb < count(explode(',', $objectid))) { + if (!$obj || $obj->nb < count(explode(',', $objectid))) { // error if we found 0 or less record than nb of id provided return false; } } else { diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index f102cd2f358..292ce1b44f5 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2015 Laurent Destailleur * Copyright (C) 2007-2015 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2022 Harry Winner Kamdem * * 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 @@ -104,7 +105,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } // Check crypted password according to crypt algorithm if ($cryptType == 'auto') { - if (dol_verifyHash($passtyped, $passcrypted, '0')) { + if ($passcrypted && dol_verifyHash($passtyped, $passcrypted, '0')) { $passok = true; dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - hash ".$cryptType." of pass is ok"); } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index dcdbca568c5..625022e6bbf 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1488,7 +1488,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Intracomm report if (!empty($conf->intracommreport->enabled)) { - $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 60, '', '', '', img_picto('', 'intracommreport', 'class="paddingright pictofixedwidth"')); if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { // DEB / DES $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); @@ -1817,7 +1817,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("Evalutions"), 1, $user->rights->hrm->evaluation->read, '', $mainmenu, 'hrm_sm', 0, '', '', '', img_picto('', 'user', 'class="pictofixedwidth"')); //$newmenu->add("/hrm/evaluation_card.php?mainmenu=hrm&leftmenu=hrm_sm&action=create", $langs->trans("NewEval"), 1, $user->rights->hrm->evaluation->write); //$newmenu->add("/hrm/evaluation_list.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("List"), 1, $user->rights->hrm->evaluation->read); - $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, $user->rights->hrm->evaluation->read || $user->rights->hrm->compare->read); + $newmenu->add("/hrm/compare.php?mainmenu=hrm&leftmenu=hrm_sm", $langs->trans("SkillComparison"), 1, $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read); } } diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 35186e423ef..5b426199a6e 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -317,7 +317,7 @@ class MenuManager print ''; } if ($val['enabled'] == 2) { - print ''; + print ''; // Add font-awesome if ($val['level'] == 0 && !empty($val['prefix'])) { print $val['prefix']; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 913438b4600..0ed0134a944 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -201,6 +201,7 @@ class pdf_einstein extends ModelePDFCommandes } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -567,10 +568,14 @@ class pdf_einstein extends ModelePDFCommandes if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { @@ -882,16 +887,16 @@ class pdf_einstein extends ModelePDFCommandes * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { // phpcs:enable global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -994,8 +999,9 @@ class pdf_einstein extends ModelePDFCommandes } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1009,11 +1015,17 @@ class pdf_einstein extends ModelePDFCommandes } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index e6ed244fc8f..a901a23cc69 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -185,6 +185,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -792,10 +793,14 @@ class pdf_eratosthene extends ModelePDFCommandes if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { @@ -1098,15 +1103,15 @@ class pdf_eratosthene extends ModelePDFCommandes * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -1207,8 +1212,9 @@ class pdf_eratosthene extends ModelePDFCommandes } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1222,11 +1228,46 @@ class pdf_eratosthene extends ModelePDFCommandes } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); + } + } + + // VAT + foreach ($this->tva_array as $tvakey => $tvaval) { + if ($tvakey != 0) { // On affiche pas taux 0 + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl = ''; + if (preg_match('/\*/', $tvakey)) { + $tvakey = str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 903c8a233cd..742d06e2e34 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -156,6 +156,9 @@ class pdf_storm extends ModelePDFDeliveryOrder } $this->tva = array(); + $this->tva_array = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 865bef37fbb..5875814b546 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -173,6 +173,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder } $this->tva = array(); + $this->tva_array = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 6fdc14ec1ad..a4e3ab491a5 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -197,9 +197,11 @@ class pdf_standard extends ModeleExpenseReport } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 426976a0a90..be42ab002d5 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -210,6 +210,7 @@ class pdf_crabe extends ModelePDFFactures } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -743,10 +744,14 @@ class pdf_crabe extends ModelePDFFactures if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; @@ -1349,8 +1354,6 @@ class pdf_crabe extends ModelePDFFactures if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1373,7 +1376,7 @@ class pdf_crabe extends ModelePDFFactures //} // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1385,12 +1388,19 @@ class pdf_crabe extends ModelePDFFactures $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= $tvaval['vatcode'].$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval, 'MT'), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index e9481ea371c..2def31cbf30 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -187,6 +187,7 @@ class pdf_sponge extends ModelePDFFactures // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -881,10 +882,14 @@ class pdf_sponge extends ModelePDFFactures if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); $nexY = max($nexY, $posYAfterImage); @@ -1593,9 +1598,8 @@ class pdf_sponge extends ModelePDFFactures } //} - // VAT - // Situations totals migth be wrong on huge amounts - if ($object->situation_cycle_ref && $object->situation_counter > 1) { + // Situations totals migth be wrong on huge amounts with old mode 1 + if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) { $sum_pdf_tva = 0; foreach ($this->tva as $tvakey => $tvaval) { $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object @@ -1612,10 +1616,14 @@ class pdf_sponge extends ModelePDFFactures foreach ($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey] = $tvaval * $coef_fix_tva; } + foreach ($this->tva_array as $tvakey => $tvaval) { + $this->tva_array[$tvakey]['amount'] = $tvaval['amount'] * $coef_fix_tva; + } } } - foreach ($this->tva as $tvakey => $tvaval) { + // VAT + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1629,11 +1637,17 @@ class pdf_sponge extends ModelePDFFactures } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); $totalvat .= ' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index b5f8b62d419..e188f66b1ad 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -42,10 +42,14 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ public $error = ''; + public $tva; + public $tva_array; + public $localtax1; + public $localtax2; + public $atleastonediscount = 0; public $atleastoneratenotnull = 0; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index cc6f8baab80..d8ba1f98146 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -210,6 +210,13 @@ class modCommande extends DolibarrModules $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } + // Add multicompany field + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { + $nbofallowedentities = count(explode(',', getEntity('commande'))); + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { + $this->export_fields_array[$r]['c.entity'] = 'Entity'; + } + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", @@ -224,7 +231,8 @@ class modCommande extends DolibarrModules 'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric", - 'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text' + 'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text', + 'c.entity'=>'List:entity:label:rowid', ); $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index ef341c83e89..fac768b9c60 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -270,6 +270,13 @@ class modFacture extends DolibarrModules $this->export_fields_array[$r]['f.module_source'] = 'Module'; $this->export_fields_array[$r]['f.pos_source'] = 'POSTerminal'; } + // Add multicompany field + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { + $nbofallowedentities = count(explode(',', getEntity('invoice'))); + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { + $this->export_fields_array[$r]['f.entity'] = 'Entity'; + } + } $this->export_TypeFields_array[$r] = array( 's.rowid'=>'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', @@ -280,7 +287,8 @@ class modFacture extends DolibarrModules 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date", 'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', - $alias_product_perentity . '.accountancy_code_sell'=>'Text' + $alias_product_perentity . '.accountancy_code_sell'=>'Text', + 'f.entity'=>'List:entity:label:rowid', ); if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { $this->export_TypeFields_array[$r]['f.module_source'] = 'Text'; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 63c76e24548..53f69dfefaf 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -199,7 +199,7 @@ class modHoliday extends DolibarrModules $this->rights[$r][0] = 20005; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'writeall_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][4] = 'writeall'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 53647db5dae..4f0633cd578 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -204,6 +204,13 @@ class modPropale extends DolibarrModules $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } + // Add multicompany field + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { + $nbofallowedentities = count(explode(',', getEntity('propal'))); + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { + $this->export_fields_array[$r]['c.entity'] = 'Entity'; + } + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", @@ -216,7 +223,8 @@ class modPropale extends DolibarrModules 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", - 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text' + 'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text', + 'c.entity'=>'List:entity:label:rowid', ); $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company', diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index e70011a2195..a733484d043 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -327,7 +327,7 @@ class modSociete extends DolibarrModules 'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text', 's.outstanding_limit'=>'Numeric', 'pbacc.ref'=>'Text', 'incoterm.code'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', - 's.entity'=>'Numeric', 's.price_level'=>'Numeric', + 's.entity'=>'List:entity:label:rowid', 's.price_level'=>'Numeric', 's.accountancy_code_sell'=>'Text', 's.accountancy_code_buy'=>'Text' ); @@ -376,6 +376,20 @@ class modSociete extends DolibarrModules 's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email", 't.libelle'=>"ThirdPartyType" ); + // Add multicompany field + if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { + if (!empty($conf->multicompany->enabled)) { + $nbofallowedentities = count(explode(',', getEntity('socpeople'))); + if ($nbofallowedentities > 1) { + $this->export_fields_array[$r]['c.entity'] = 'Entity'; + } + + $nbofallowedentities = count(explode(',', getEntity('societe'))); + if ($nbofallowedentities > 1) { + $this->export_fields_array[$r]['s.entity'] = 'Entity'; + } + } + } $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_TypeFields_array[$r] = array( 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean", @@ -386,14 +400,17 @@ class modSociete extends DolibarrModules 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.client'=>"Text", 's.fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text", - 't.libelle'=>"Text" + 't.libelle'=>"Text", + 'c.entity'=>'List:entity:label:rowid', + 's.entity'=>'List:entity:label:rowid', ); $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company", 's.code_compta'=>"company", 's.code_compta_fournisseur'=>"company", 's.client'=>"company", 's.fournisseur'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company", - 't.libelle'=>"company" + 't.libelle'=>"company", + 's.entity'=>'company', ); // We define here only fields that use another picto if (empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { unset($this->export_fields_array[$r]['s.code_fournisseur']); diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index bf06a1b73d2..48483066e5e 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -238,8 +238,8 @@ class pdf_standard extends ModelePDFMovement $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); + $sortorder = GETPOST('sortorder', 'aZ09comma'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index e97eb0ff81d..ea2ea8add99 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -197,6 +197,7 @@ class pdf_azur extends ModelePDFPropales } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -677,10 +678,14 @@ class pdf_azur extends ModelePDFPropales if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; @@ -1059,9 +1064,10 @@ class pdf_azur extends ModelePDFPropales * @param int $deja_regle Amount already paid * @param int $posy Start position * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position for continuation */ - protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { // phpcs:enable global $conf, $mysoc; @@ -1164,8 +1170,9 @@ class pdf_azur extends ModelePDFPropales } } //} + // VAT - foreach ($this->tva as $tvakey => $tvaval) { + foreach ($this->tva_array as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 $this->atleastoneratenotnull++; @@ -1177,12 +1184,19 @@ class pdf_azur extends ModelePDFPropales $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat .= vatrate($tvakey, 1).$tvacompl; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; + if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') { + $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl; + } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') { + $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl; + } else { + $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl; + } $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1); } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index bb688c137a6..9963ecd9527 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -179,6 +179,7 @@ class pdf_cyan extends ModelePDFPropales // Use new system for position of columns, view $this->defineColumnField() $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -802,10 +803,14 @@ class pdf_cyan extends ModelePDFPropales if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = max($nexY, $posYAfterImage); @@ -1178,15 +1183,15 @@ class pdf_cyan extends ModelePDFPropales * @param int $deja_regle Amount already paid (in the currency of invoice) * @param int $posy Position depart * @param Translate $outputlangs Objet langs + * @param Translate $outputlangsbis Object lang for output bis * @return int Position pour suite */ - protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) + protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null) { global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -1293,6 +1298,7 @@ class pdf_cyan extends ModelePDFPropales } } //} + // VAT foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 5d5e24f5fd1..f66e7e6e5d1 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -1,5 +1,6 @@ + * 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 @@ -173,10 +174,13 @@ class pdf_standard extends ModelePDFStock $this->postotalht -= 20; } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + $this->tabTitleHeight = 11; } @@ -290,7 +294,7 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 80 + $top_shift; + $tab_top = 65 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -319,7 +323,6 @@ class pdf_standard extends ModelePDFStock $i = 0; $nblines = $num; - $this->tabTitleHeight = 0; $nexY = $tab_top + $this->tabTitleHeight; for ($i = 0; $i < $nblines; $i++) { @@ -357,14 +360,16 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 3, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 4, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text @@ -417,8 +422,8 @@ class pdf_standard extends ModelePDFStock $productstatic->status_batch = $objp->tobatch; // Ref. - $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + //$pdf->SetXY($this->posxdesc, $curY); + //$pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); // Label $pdf->SetXY($this->posxlabel + 0.8, $curY); @@ -505,7 +510,7 @@ class pdf_standard extends ModelePDFStock /** * Footer table */ - $nexY = $pdf->GetY(); + //$nexY = $pdf->GetY(); $nexY += 2; $curY = $nexY; @@ -569,11 +574,11 @@ class pdf_standard extends ModelePDFStock $height_note = 0; } - $iniY = $tab_top + 7; + /*$iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage + 25 + $top_shift; + $tab_top = $tab_top_newpage + 25 + $top_shift;*/ // Show square if ($pagenb == 1) { @@ -726,10 +731,12 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R'); } - $pdf->SetDrawColor(200, 200, 200); - $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); - $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); - $pdf->SetLineStyle(array('dash'=>0)); + if (empty($hidetop)) { + $pdf->SetDrawColor(200, 200, 200); + $pdf->SetLineStyle(array('dash' => '0', 'color' => array(200, 200, 200))); + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); + $pdf->SetLineStyle(array('dash' => 0)); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -761,8 +768,8 @@ class pdf_standard extends ModelePDFStock pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); + if ($object->statut == 0 && (!empty($conf->global->STOCK_DRAFT_WATERMARK))) { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->STOCK_DRAFT_WATERMARK); } $pdf->SetTextColor(0, 0, 60); @@ -774,6 +781,7 @@ class pdf_standard extends ModelePDFStock $pdf->SetXY($this->marge_gauche, $posy); // Logo + $height = 0; $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { @@ -790,29 +798,19 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } + $yafterleft = $pdf->GetY() + $height; + $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("Warehouse"); - $pdf->MultiCell(100, 3, $title, '', 'R'); - $pdf->SetFont('', 'B', $default_font_size); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Warehouse").' '.$outputlangs->convToOutputCharset($object->label), '', 'R'); - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R'); - - $posy += 5; + $posy += 6; $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); - - $posy += 4; - $pdf->SetXY($posx - 50, $posy); - $pdf->MultiCell(150, 3, $object->lieu, '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Label").' : '.$object->lieu, '', 'R'); $posy += 4; $pdf->SetXY($posx, $posy); @@ -830,8 +828,10 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(150, 3, $e->label, '', 'R'); } + $yafterright = $pdf->GetY(); + // Description - $nexY = $pdf->GetY(); + $nexY = max($yafterleft, $yafterright); $nexY += 5; $pdf->SetXY($posx, $posy); $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); @@ -853,6 +853,9 @@ class pdf_standard extends ModelePDFStock $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); $nexY = $pdf->GetY(); + // Value + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Date").' : '.dol_print_date(dol_now(), 'dayhour'), 0, 1); + $nexY = $pdf->GetY(); // Last movement $sql = "SELECT max(m.datem) as datem"; diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 08ccf213b18..23a38b961ec 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -181,6 +181,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 7738f1ec404..c30a2512083 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -169,6 +169,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support durring PDF transition: TODO remove this at the end $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -738,10 +739,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 76d264f2444..bb3d4f073fe 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -197,6 +197,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -617,10 +618,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 24ae9a71781..608d765b1c5 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -168,6 +168,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index c2ab5c99ea6..0417d06e44d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -194,6 +194,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -611,10 +612,14 @@ class pdf_aurore extends ModelePDFSupplierProposal if (($object->lines[$i]->info_bits & 0x01) == 0x01) { $vatrate .= '*'; } + + // Fill $this->tva and $this->tva_array if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } $this->tva[$vatrate] += $tvaligne; + $vatcode = $object->lines[$i]->vat_src_code; + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index aeac5d038f3..8d21a789648 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1013,7 +1013,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#prod_entry_mode_free").prop('checked',true).change(); jQuery("#prod_entry_mode_predef").prop('checked',false).change(); jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); - jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_fourn_ref, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #multicurrency_price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_fourn_ref, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#fournprice_predef").hide(); } @@ -1032,7 +1032,17 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#multicurrency_price_ht").val('').hide(); jQuery("#title_up_ht, #title_up_ht_currency").hide(); - jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_fourn_ref, #title_vat, #title_up_ttc, #title_up_ttc_currency").hide(); + global->MAIN_ENABLE_EDIT_PREDEF_PRICETTC)) { ?> + jQuery("#price_ttc").val('').hide(); + jQuery("#multicurrency_price_ttc").val('').hide(); + jQuery("#title_up_ttc, #title_up_ttc_currency").hide(); + + jQuery("#price_ttc").val('').show(); + jQuery("#multicurrency_price_ttc").val('').show(); + jQuery("#title_up_ttc, #title_up_ttc_currency").show(); + + jQuery("#fourn_ref, #tva_tx, #title_vat").hide(); + /* jQuery("#title_fourn_ref").hide(); */ jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); jQuery('#trlinefordates, .divlinefordates').show(); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index c2480581501..fc208fd9ac3 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -46,8 +46,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cro $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/document.php b/htdocs/document.php index 2a708ff3334..7498fbb3cf6 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -214,7 +214,7 @@ $check_access = dol_check_secure_access_document($modulepart, $original_file, $e $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name -//var_dump($fullpath_original_file);exit; +//var_dump($fullpath_original_file.' '.$original_file.' '.$refname.' '.$accessallowed);exit; if (!empty($hashp)) { $accessallowed = 1; // When using hashp, link is public so we force $accessallowed diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 19da17f2be2..960ff7e7b2d 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -140,6 +140,7 @@ if (empty($reshook)) { exit; } else { setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; } } @@ -172,7 +173,7 @@ if (empty($reshook)) { $object->lastname = (string) GETPOST("lastname", 'alpha'); $object->societe = (string) GETPOST("societe", 'alpha'); $object->address = (string) GETPOST("address", 'alpha'); - $object->amount = price2num(GETPOST("amount", 'alpha')); + $object->amount = price2num(GETPOST("amount", 'alpha'), '', 2); $object->town = (string) GETPOST("town", 'alpha'); $object->zip = (string) GETPOST("zipcode", 'alpha'); $object->country_id = (int) GETPOST('country_id', 'int'); @@ -193,6 +194,9 @@ if (empty($reshook)) { if ($object->update($user) > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } } } @@ -230,7 +234,7 @@ if (empty($reshook)) { $object->lastname = (string) GETPOST("lastname", 'alpha'); $object->societe = (string) GETPOST("societe", 'alpha'); $object->address = (string) GETPOST("address", 'alpha'); - $object->amount = price2num(GETPOST("amount", 'alpha')); + $object->amount = price2num(GETPOST("amount", 'alpha'), '', 2); $object->zip = (string) GETPOST("zipcode", 'alpha'); $object->town = (string) GETPOST("town", 'alpha'); $object->country_id = (int) GETPOST('country_id', 'int'); @@ -254,6 +258,7 @@ if (empty($reshook)) { exit; } else { setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } } } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 7ca70a31aa2..cbd5a386354 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -353,6 +353,13 @@ class Don extends CommonObject $this->town = ($this->town > 0 ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->country = ($this->country ? $this->country : $this->country); + $this->amount = price2num($this->amount); + + // Check parameters + if ($this->amount < 0) { + $this->error = $langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv("Amount")); + return -1; + } $this->db->begin(); @@ -382,7 +389,7 @@ class Don extends CommonObject $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->date ? $this->date : $now)."'"; $sql .= ", ".((int) $conf->entity); - $sql .= ", ".price2num($this->amount); + $sql .= ", ".((float) $this->amount); $sql .= ", ".($this->modepaymentid ? $this->modepaymentid : "null"); $sql .= ", ".($this->socid > 0 ? $this->socid : "null"); $sql .= ", '".$this->db->escape($this->firstname)."'"; @@ -464,29 +471,36 @@ class Don extends CommonObject $this->town = ($this->town > 0 ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->country = ($this->country ? $this->country : $this->country); + $this->amount = price2num($this->amount); + + // Check parameters + if ($this->amount < 0) { + $this->error = $langs->trans('FieldCannotBeNegative', $langs->transnoentitiesnoconv("Amount")); + return -1; + } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET "; - $sql .= "amount = ".price2num($this->amount); - $sql .= ",fk_payment = ".($this->modepaymentid ? $this->modepaymentid : "null"); - $sql .= ",firstname = '".$this->db->escape($this->firstname)."'"; - $sql .= ",lastname='".$this->db->escape($this->lastname)."'"; - $sql .= ",societe='".$this->db->escape($this->societe)."'"; - $sql .= ",address='".$this->db->escape($this->address)."'"; - $sql .= ",zip='".$this->db->escape($this->zip)."'"; - $sql .= ",town='".$this->db->escape($this->town)."'"; - $sql .= ",fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) : '0'); - $sql .= ",public=".((int) $this->public); - $sql .= ",fk_projet=".($this->fk_project > 0 ? $this->fk_project : 'null'); - $sql .= ",note_private=".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); - $sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); - $sql .= ",datedon='".$this->db->idate($this->date)."'"; - $sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null"); - $sql .= ",email='".$this->db->escape(trim($this->email))."'"; - $sql .= ",phone='".$this->db->escape(trim($this->phone))."'"; - $sql .= ",phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'"; - $sql .= ",fk_statut=".((int) $this->statut); + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET"; + $sql .= " amount = ".((float) $this->amount); + $sql .= ", fk_payment = ".($this->modepaymentid ? $this->modepaymentid : "null"); + $sql .= ", firstname = '".$this->db->escape($this->firstname)."'"; + $sql .= ", lastname='".$this->db->escape($this->lastname)."'"; + $sql .= ", societe='".$this->db->escape($this->societe)."'"; + $sql .= ", address='".$this->db->escape($this->address)."'"; + $sql .= ", zip='".$this->db->escape($this->zip)."'"; + $sql .= ", town='".$this->db->escape($this->town)."'"; + $sql .= ", fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) : '0'); + $sql .= ", public=".((int) $this->public); + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->fk_project : 'null'); + $sql .= ", note_private=".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); + $sql .= ", note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); + $sql .= ", datedon='".$this->db->idate($this->date)."'"; + $sql .= ", date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null"); + $sql .= ", email='".$this->db->escape(trim($this->email))."'"; + $sql .= ", phone='".$this->db->escape(trim($this->phone))."'"; + $sql .= ", phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'"; + $sql .= ", fk_statut=".((int) $this->statut); $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::Update", LOG_DEBUG); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 0c8f51281a3..d7697dba43d 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -37,8 +37,8 @@ $langs->loadLangs(array("companies", "donations")); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist'; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index 1416983e3a3..d7de6acc727 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -66,8 +66,8 @@ if ($module == 'ecm') { } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index 793e199f180..930575d1778 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -47,8 +47,8 @@ if (empty($module)) { // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index 237f70a0a42..7de02f56083 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -46,8 +46,8 @@ if ($user->socid > 0) { } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/file_note.php b/htdocs/ecm/file_note.php index 505e432f982..43dcc20e744 100644 --- a/htdocs/ecm/file_note.php +++ b/htdocs/ecm/file_note.php @@ -48,8 +48,8 @@ if ($user->socid > 0) { } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 813ee69b6fb..2b68206d70a 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -45,8 +45,8 @@ $section_dir = GETPOST('section_dir', 'alpha'); $overwritefile = GETPOST('overwritefile', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index c4ec6afc90b..3b906883c00 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -52,8 +52,8 @@ $section_dir = GETPOST('section_dir', 'alpha'); $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 9a6c20392a9..42b8efba42f 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -59,8 +59,8 @@ if (empty($module)) { $upload_dir = $conf->ecm->dir_output.'/'.$section; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 729762be327..ff29e56b1e7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -762,6 +762,11 @@ class EmailCollector extends CommonObject if ($norsh || !empty($conf->global->IMAP_FORCE_NORSH)) { $flags .= '/norsh'; } + //Used in shared mailbox from Office365 + if (strpos($this->login, '/') != false) { + $partofauth = explode('/', $this->login); + $flags .= '/authuser='.$partofauth[0].'/user='.$partofauth[1]; + } $connectstringserver = '{'.$this->host.':993'.$flags.'}'; @@ -2360,7 +2365,7 @@ class EmailCollector extends CommonObject // this code action is hook..... for support this call global $hookmanager; - if (!is_object($hookmanager)) { + if (is_object($hookmanager)) { $hookmanager->initHooks(array('emailcollectorcard')); } @@ -2381,6 +2386,7 @@ class EmailCollector extends CommonObject 'messagetext'=>$messagetext, 'subject'=>$subject, 'header'=>$header, + 'attachments'=>$attachments, ); $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index 2b791ea0e6f..742585ffb16 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -52,8 +52,8 @@ $project_ref = GETPOST('project_ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8d5dbd6ec7f..064dfc3a52c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1206,6 +1206,10 @@ if ($action == 'create') { print ''; print ''; } else { + if (! empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) { + print ''; + } + print $langs->trans("NA"); } print '
'; print ''; print ''; $return = array(); @@ -556,7 +557,7 @@ if ($object->id > 0) { print $productstatic->getNomUrl(1); print ''; print ''; print '
'.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("AllProductReferencesOfSupplier").''.$object->nbOfProductRefs().''; + print ''.$langs->trans("AllProductReferencesOfSupplier").''.$object->nbOfProductRefs().''; print '
'; - print $objp->supplier_ref; + print dol_escape_htmltag($objp->supplier_ref); print ''; print dol_trunc(dol_htmlentities($objp->label), 30); @@ -565,7 +566,7 @@ if ($object->id > 0) { print ''; //print (isset($objp->unitprice) ? price($objp->unitprice) : ''); if (isset($objp->price)) { - print price($objp->price); + print ''.price($objp->price).''; if ($objp->quantity > 1) { print ' / '; print $objp->quantity; @@ -577,6 +578,7 @@ if ($object->id > 0) { } print '
'; + print '
'; } @@ -601,12 +603,13 @@ if ($object->id > 0) { $num = $db->num_rows($resql); if ($num > 0) { + print '
'; print ''; print ''; print ''; @@ -638,7 +641,7 @@ if ($object->id > 0) { $db->free($resql); if ($num > 0) { - print "
'; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPriceRequests").''.$num.''.$langs->trans("AllPriceRequests").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
"; + print "
"; } } else { dol_print_error($db); @@ -690,7 +693,7 @@ if ($object->id > 0) { $num = $object_count->total; } - $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; + $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql .= " WHERE p.fk_soc = ".((int) $object->id); $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")"; @@ -702,12 +705,13 @@ if ($object->id > 0) { $i = 0; if ($num > 0) { + print '
'; print ''; print ''; - print ''; @@ -716,22 +720,23 @@ if ($object->id > 0) { while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); - print ''; - print ''; + print ''; print ''; + print ''; print ''; print ''; $i++; @@ -739,7 +744,7 @@ if ($object->id > 0) { $db->free($resql); if ($num > 0) { - print "
'; + print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").''.$num.''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
'; $orderstatic->id = $obj->rowid; $orderstatic->ref = $obj->ref; $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; + $orderstatic->date = $db->jdate($obj->date); + + print '
'; print $orderstatic->getNomUrl(1); print ''; - if ($obj->dc) { - print dol_print_date($db->jdate($obj->dc), 'day'); - } else { - print "-"; + if ($obj->date) { + print dol_print_date($orderstatic->date, 'day'); } print ''.price($orderstatic->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut, 5).'
"; + print "
"; } } else { dol_print_error($db); @@ -755,7 +760,7 @@ if ($object->id > 0) { if ($user->rights->fournisseur->facture->lire) { // TODO move to DAO class - $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,'; + $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,'; $sql .= ' SUM(pf.amount) as am'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; @@ -768,11 +773,13 @@ if ($object->id > 0) { $i = 0; $num = $db->num_rows($resql); if ($num > 0) { + print '
'; print ''; print ''; print ''; @@ -781,9 +788,6 @@ if ($object->id > 0) { while ($i < min($num, $MAXLIST)) { $obj = $db->fetch_object($resql); - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; print ''; @@ -806,7 +814,7 @@ if ($object->id > 0) { } $db->free($resql); if ($num > 0) { - print '
'; - print ''; + print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').''.$num.'
'; + print ''; print ''; print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
'; - print ''; $facturestatic->id = $obj->rowid; $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); $facturestatic->ref_supplier = $obj->ref_supplier; @@ -792,12 +796,16 @@ if ($object->id > 0) { $facturestatic->total_ht = $obj->total_ht; $facturestatic->total_tva = $obj->total_tva; $facturestatic->total_ttc = $obj->total_ttc; - print $facturestatic->getNomUrl(1); + $facturestatic->date = $db->jdate($obj->df); + + print '
'; + print ''.$facturestatic->getNomUrl(1).''; print $obj->ref_supplier ? ' - '.$obj->ref_supplier : ''; print ($obj->label ? ' - ' : '').dol_trunc($obj->label, 14); print ''.dol_print_date($db->jdate($obj->df), 'day').''.price($obj->amount).''.dol_print_date($facturestatic->date, 'day').''.price($facturestatic->total_ttc).''; print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am); print '
'; + print '
'; } } else { dol_print_error($db); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9b68ef199db..0151af97acf 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2012,6 +2012,8 @@ class CommandeFournisseur extends CommonOrder if ($product > 0) { // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) $mouv->origin = &$this; + $mouv->origin_type = $this->element; + $mouv->origin_id = $this->id; $result = $mouv->reception($user, $product, $entrepot, $qty, $price, $comment, $eatby, $sellby, $batch); if ($result < 0) { $this->error = $mouv->error; @@ -3008,10 +3010,10 @@ class CommandeFournisseur extends CommonOrder $clause = " WHERE"; - $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date"; + $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date, c.total_ht"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".((int) $user->id); $clause = " AND"; } @@ -3043,12 +3045,13 @@ class CommandeFournisseur extends CommonOrder } while ($obj = $this->db->fetch_object($resql)) { - $response->nbtodo++; - $commandestatic->delivery_date = $this->db->jdate($obj->delivery_date); $commandestatic->date_commande = $this->db->jdate($obj->date_commande); $commandestatic->statut = $obj->fk_statut; + $response->nbtodo++; + $response->total += $obj->total_ht; + if ($commandestatic->hasDelay()) { $response->nbtodolate++; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a202e459e6d..e9db81e298f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1793,14 +1793,14 @@ class FactureFournisseur extends CommonInvoice * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param int $origin_id id origin document - * @param double $pu_ht_devise Amount in currency + * @param double $pu_devise Amount in currency * @param string $ref_supplier Supplier ref * @param string $special_code Special code * @param int $fk_parent_line Parent line id * @param int $fk_remise_except Id discount used * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = false, $array_options = 0, $fk_unit = null, $origin_id = 0, $pu_ht_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = false, $array_options = 0, $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) { global $langs, $mysoc, $conf; @@ -1906,7 +1906,7 @@ class FactureFournisseur extends CommonInvoice $product_type = $type; } - if (!empty($conf->multicurrency->enabled) && $pu_ht_devise > 0) { + if (!empty($conf->multicurrency->enabled) && $pu_devise > 0) { $pu = 0; } @@ -1925,7 +1925,7 @@ class FactureFournisseur extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2052,21 +2052,21 @@ class FactureFournisseur extends CommonInvoice * @param integer $date_end Date end of service * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Amount in currency + * @param double $pu_devise Amount in currency * @param string $ref_supplier Supplier ref * @return int <0 if KO, >0 if OK */ - public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = false, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') + public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = false, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_devise = 0, $ref_supplier = '') { global $mysoc, $langs; - dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$notrigger,$date_start,$date_end,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$notrigger,$date_start,$date_end,$fk_unit,$pu_devise,$ref_supplier", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $pu = price2num($pu); $qty = price2num($qty); $remise_percent = price2num($remise_percent); - $pu_ht_devise = price2num($pu_ht_devise); + $pu_devise = price2num($pu_devise); // Check parameters //if (! is_numeric($pu) || ! is_numeric($qty)) return -1; @@ -2110,7 +2110,7 @@ class FactureFournisseur extends CommonInvoice $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2418,20 +2418,21 @@ class FactureFournisseur extends CommonInvoice // phpcs:enable global $conf, $langs; - $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut'; + $clause = " WHERE"; + + $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut, ff.total_ht'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff'; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ff.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".((int) $user->id); + $clause = " AND"; } - $sql .= ' WHERE ff.paye=0'; + $sql .= $clause.' ff.paye=0'; $sql .= ' AND ff.fk_statut = '.self::STATUS_VALIDATED; $sql .= " AND ff.entity = ".$conf->entity; if ($user->socid) { $sql .= ' AND ff.fk_soc = '.((int) $user->socid); } - if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } $resql = $this->db->query($sql); if ($resql) { @@ -2449,16 +2450,18 @@ class FactureFournisseur extends CommonInvoice $facturestatic = new FactureFournisseur($this->db); while ($obj = $this->db->fetch_object($resql)) { - $response->nbtodo++; - $facturestatic->date_echeance = $this->db->jdate($obj->datefin); $facturestatic->statut = $obj->fk_statut; + $response->nbtodo++; + $response->total += $obj->total_ht; + if ($facturestatic->hasDelay()) { $response->nbtodolate++; $response->url_late = DOL_URL_ROOT.'/fourn/facture/list.php?search_option=late&mainmenu=billing&leftmenu=suppliers_bills'; } } + $this->db->free($resql); return $response; } else { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 88469e6d01a..00408c1e43b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -129,7 +129,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'com // Common permissions $usercanread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire); $usercancreate = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); -$usercandelete = ($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer); +$usercandelete = (($user->rights->fournisseur->commande->supprimer || $user->rights->supplier_order->supprimer) || ($usercancreate && isset($object->statut) && $object->statut == $object::STATUS_DRAFT)); // Advanced permissions $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))); @@ -853,6 +853,8 @@ if (empty($reshook)) { $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; @@ -2580,14 +2582,14 @@ if ($action == 'create') { } // Cancel - if ($object->statut == 2) { + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { if ($usercanorder) { print ''.$langs->trans("CancelOrder").''; } } // Delete - if (!empty($usercandelete) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($usercancreate))) { + if (!empty($usercandelete)) { if ($hasreception) { print ''.$langs->trans("Delete").''; } else { diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index c7e3f609164..d54d5553efb 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -48,8 +48,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 09bf1ab08e6..6c64672ee84 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -41,8 +41,8 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6470dc62bcd..59c3a57c4ac 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -135,8 +135,8 @@ $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; @@ -738,7 +738,7 @@ $help_url = ''; // llxHeader('',$title,$help_url); $sql = 'SELECT'; -if ($sall || $search_product_category > 0 || $search_user > 0) { +if ($sall || $search_product_category > 0) { $sql = 'SELECT DISTINCT'; } $sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; @@ -780,10 +780,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -if ($search_user > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; -} $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; @@ -869,7 +865,13 @@ if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } if ($search_user > 0) { - $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".((int) $search_user); + $sql .= " AND EXISTS ("; + $sql .= " SELECT ec.rowid "; + $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact"; + $sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user); + $sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'"; + $sql .= ")"; } if ($search_total_ht != '') { $sql .= natural_search('cf.total_ht', $search_total_ht, 1); diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index cabf726beee..9d6e3abd4cf 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -41,8 +41,8 @@ if ($user->socid > 0) { } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e969ae01412..76159d177c5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -265,6 +265,8 @@ if (empty($reshook)) { // Remove a product line $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language /*$outputlangs = $langs; $newlang = ''; @@ -1297,7 +1299,7 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); $remise_percent = price2num(GETPOST('remise_percent'), '', 2); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'MU', 2); + $pu_devise = price2num(GETPOST('multicurrency_subprice'), 'MU', 2); // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1309,7 +1311,7 @@ if (empty($reshook)) { } } - $result = $object->updateline(GETPOST('lineid', 'int'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, price2num(GETPOST('qty'), 'MS'), GETPOST('productid', 'int'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, GETPOST('units'), $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + $result = $object->updateline(GETPOST('lineid', 'int'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, price2num(GETPOST('qty'), 'MS'), GETPOST('productid', 'int'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, GETPOST('units'), $pu_devise, GETPOST('fourn_ref', 'alpha')); if ($result >= 0) { unset($_POST['label']); unset($_POST['fourn_ref']); @@ -1355,17 +1357,18 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $tva_tx = ''; } + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); // Can be '1.2' or '1.2 (CODE)' + + $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); + $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2); + $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'MU', 2); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1455,8 +1458,8 @@ if (empty($reshook)) { } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { - $product_desc=''; + if (trim($product_desc) == trim($desc) && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc = ''; } if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) { $desc = $product_desc; @@ -1465,32 +1468,39 @@ if (empty($reshook)) { $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); } - $type = $productsupplier->type; - if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { - $price_base_type = 'HT'; - $pu = price2num($price_ht, 'MU'); - $pu_ht_devise = price2num($price_ht_devise, 'CU'); - } else { - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); - if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency - $pu = $productsupplier->fourn_pu; - $pu_ht_devise = 0; - } else { - $pu = $productsupplier->fourn_pu; - $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; - } - } - $ref_supplier = $productsupplier->ref_supplier; - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + // Get vat rate + if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + } if (empty($tva_tx)) { $tva_npr = 0; } $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + $type = $productsupplier->type; + if (GETPOST('price_ht') != '' || GETPOST('price_ht_devise') != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_devise = price2num($price_ht_devise, 'CU'); + } elseif (GETPOST('price_ttc') != '' || GETPOST('price_ttc_devise') != '') { + $price_base_type = 'TTC'; + $pu = price2num($price_ttc, 'MU'); + $pu_devise = price2num($price_ttc_devise, 'CU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_devise = $productsupplier->fourn_multicurrency_unitprice; + } + } + if (empty($pu)) { $pu = 0; // If pu is '' or null, we force to have a numeric value } @@ -1515,7 +1525,7 @@ if (empty($reshook)) { $array_options, $productsupplier->fk_unit, 0, - $pu_ht_devise, + $pu_devise, $ref_supplier, '' ); @@ -1557,9 +1567,9 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_ht_devise = price2num($price_ht_devise, 'CU'); + $pu_devise = price2num($price_devise, 'CU'); - $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise, $ref_supplier); + $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } //print "xx".$tva_tx; exit; @@ -1956,7 +1966,7 @@ if ($action == 'create') { print $societe->getNomUrl(1, 'supplier'); print ''; } else { - print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 widthcentpercentminusxx'); + print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print ''."\n"; + $urlforjs = dol_buildpath($jsfile, 1); + if ($urlforjs && $urlforjs != '/') { + print ''."\n".''."\n"; + } else { + dol_syslog("Warning: module ".$modjs." declared a js path file for a file we can't find.", LOG_WARNING); + } } } } @@ -2929,7 +2941,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ */ function main_area($title = '') { - global $conf, $langs; + global $conf, $langs, $hookmanager; if (empty($conf->dol_hide_leftmenu)) { print '
'; @@ -2939,14 +2951,17 @@ function main_area($title = '') print ''."\n".'
'."\n"; + $hookmanager->initHooks(array('main')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('printMainArea', $parameters); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED), 0, 0, 1, 'warning maintenancemode'); } // Permit to add user company information on each printed document by setting SHOW_SOCINFO_ON_PRINT if (!empty($conf->global->SHOW_SOCINFO_ON_PRINT) && GETPOST('optioncss', 'aZ09') == 'print' && empty(GETPOST('disable_show_socinfo_on_print', 'az09'))) { - global $hookmanager; - $hookmanager->initHooks(array('main')); $parameters = array(); $reshook = $hookmanager->executeHooks('showSocinfoOnPrint', $parameters); if (empty($reshook)) { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 7fe151b93f7..290a94908c0 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -129,8 +129,8 @@ if ($socid > 0) { print ''; } -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (!$sortorder) { $sortorder = "ASC"; } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 062462be267..93895b01e2f 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -43,8 +43,8 @@ if (!empty($user->socid)) { $object = new Product($db); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 43e9c87c6e6..c69c0443e28 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -35,8 +35,8 @@ if (!empty($user->socid)) { } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 7a92402224b..aa836842e71 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -32,7 +32,8 @@ * This script reads the conf file, init $lang, $db and and empty $user */ -// Declaration of variables. May have been already require by main.inc.php. But may not by scripts. So, here the require_once must be kept. +// Include the conf.php and functions.lib.php and security.lib.php. This defined the constants like DOL_DOCUMENT_ROOT, DOL_DATA_ROOT, DOL_URL_ROOT... +// This file may have been already required by main.inc.php. But may not by scripts. So, here the require_once must be kept. require_once 'filefunc.inc.php'; diff --git a/htdocs/modulebuilder/template/lib/mymodule.lib.php b/htdocs/modulebuilder/template/lib/mymodule.lib.php index 32ae980e946..ab8a647efe4 100644 --- a/htdocs/modulebuilder/template/lib/mymodule.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule.lib.php @@ -62,7 +62,7 @@ function mymoduleAdminPrepareHead() //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'mymodule@mymodule'); - complete_head_from_modules($conf, $langs, $object, $head, $h, 'mymodule@mymodule', 'remove'); + complete_head_from_modules($conf, $langs, null, $head, $h, 'mymodule@mymodule', 'remove'); return $head; } diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index b7d3fcfaa80..5eb4f6e3028 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -102,8 +102,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index e77fec58167..3db0271dd01 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -92,8 +92,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index c4480f76ed0..d9ee0e39cc6 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -155,7 +155,7 @@ print '
'; $max = 5; -$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a"; $sql .= " WHERE a.entity IN (".getEntity('bom').")"; $sql .= $db->order("a.tms", "DESC"); @@ -176,6 +176,7 @@ if ($resql) { $staticbom->id = $obj->rowid; $staticbom->ref = $obj->ref; + $staticbom->fk_product = $obj->fk_product; $staticbom->date_modification = $obj->datem; $staticbom->status = $obj->status; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 95dab4e62ab..e1b19d87ad0 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -55,8 +55,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index c81ed1f995e..acb5cb3e1c4 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -44,8 +44,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index f0fe25eddb6..10e430479cf 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -65,8 +65,8 @@ $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 2c32e0b03e8..73cff1b4502 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -55,8 +55,8 @@ $dateinput = dol_mktime(0, 0, 0, GETPOST('dateinputmonth', 'int'), GETPOST('d $rateinput = price2num(GETPOST('rateinput', 'alpha')); $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { diff --git a/htdocs/partnership/partnership_agenda.php b/htdocs/partnership/partnership_agenda.php index f154e1b9f5b..4c68a83d4e2 100644 --- a/htdocs/partnership/partnership_agenda.php +++ b/htdocs/partnership/partnership_agenda.php @@ -53,8 +53,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/partnership/partnership_document.php b/htdocs/partnership/partnership_document.php index 79b7be0057a..f96eb6e58ec 100644 --- a/htdocs/partnership/partnership_document.php +++ b/htdocs/partnership/partnership_document.php @@ -43,8 +43,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 815014e259f..40d451653e7 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -54,8 +54,8 @@ if ($user->socid) { } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index e230d148026..32c4c83378c 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -47,7 +47,7 @@ if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) { require '../../main.inc.php'; -$htmlname = GETPOST('htmlname', 'alpha'); +$htmlname = GETPOST('htmlname', 'aZ09'); $socid = GETPOST('socid', 'int'); $type = GETPOST('type', 'int'); $mode = GETPOST('mode', 'int'); @@ -73,7 +73,7 @@ restrictedArea($user, 'produit|service', 0, 'product&product'); // print ''."\n"; // print_r($_GET); -if (!empty($action) && $action == 'fetch' && !empty($id)) { +if ($action == 'fetch' && !empty($id)) { // action='fetch' is used to get product information on a product. So when action='fetch', id must be the product id. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -242,7 +242,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // Filter on the product to search can be: // Into an array with key $htmlname123 (we take first one found). Which page use this ? // Into a var with name $htmlname can be 'prodid', 'productid', ... - $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.preg_quote($htmlname, '/').'[0-9]+)/', array_keys($_GET)); sort($match); $idprod = (empty($match[0]) ? '' : $match[0]); // Take first key found into GET array with matching $htmlname123 diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 230f8375538..79ff858ba6e 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -58,8 +58,8 @@ $hookmanager->initHooks(array('productdocuments')); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b79fe5fb843..98ab414a8c3 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -63,10 +63,9 @@ $error = 0; $extrafields = new ExtraFields($db); // If socid provided by ajax company selector -if (!empty($_REQUEST['search_fourn_id'])) { +if (GETPOST('search_fourn_id', 'int')) { $_GET['id_fourn'] = GETPOST('search_fourn_id', 'int'); $_POST['id_fourn'] = GETPOST('search_fourn_id', 'int'); - $_REQUEST['id_fourn'] = GETPOST('search_fourn_id', 'int'); } // Security check @@ -81,8 +80,8 @@ if (empty($user->rights->fournisseur->lire)) { } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; @@ -518,7 +517,7 @@ if ($id > 0 || $ref) { } else { $events = array(); $events[] = array('method' => 'getVatRates', 'url' => dol_buildpath('/core/ajax/vatrates.php', 1), 'htmlname' => 'tva_tx', 'params' => array()); - print $form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', 'fournisseur=1', 'SelectThirdParty', 0, 0, $events); + print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company(GETPOST("id_fourn", 'alpha'), 'id_fourn', 'fournisseur=1', 'SelectThirdParty', 0, 0, $events); $parameters = array('filtre'=>"fournisseur=1", 'html_name'=>'id_fourn', 'selected'=>GETPOST("id_fourn"), 'showempty'=>1, 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 949158289a0..778565dd2cb 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -65,7 +65,12 @@ $search_barcode = GETPOST("search_barcode", 'alpha'); $search_label = GETPOST("search_label", 'alpha'); $search_type = GETPOST("search_type", 'int'); $search_vatrate = GETPOST("search_vatrate", 'alpha'); -$searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0); +$searchCategoryProductOperator = 0; +if (GETPOSTISSET('formfilteraction')) { + $searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int'); +} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) { + $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; +} $searchCategoryProductList = GETPOST('search_category_product_list', 'array'); $search_tosell = GETPOST("search_tosell", 'int'); $search_tobuy = GETPOST("search_tobuy", 'int'); @@ -94,8 +99,8 @@ if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES $diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$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; diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 9028e81a757..707f95d2202 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -44,8 +44,8 @@ if (!empty($user->socid)) { } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 309853a7bb6..4c14add3660 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1671,8 +1671,8 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($db); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); + $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b0a1ce87ddd..62bfd626f82 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -48,8 +48,8 @@ $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index e75d1504267..2bd62b2ce22 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -52,8 +52,8 @@ $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) { $page = 0; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index ef4923e89be..b7c4321dfd1 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -50,8 +50,8 @@ $option = ''; // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; @@ -129,11 +129,11 @@ if ($id > 0 || !empty($ref)) { //Calcul total qty and amount for global if full scan list $total_qty_toconsume = 0; $total_qty_toproduce = 0; + $product_cache=array(); $bom_data_result = array(); - //Qauntity to produce - $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,"; + $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid, b.fk_product,"; $sql .= " b.qty as qty_toproduce"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b"; $sql .= " WHERE "; @@ -166,7 +166,20 @@ if ($id > 0 || !empty($ref)) { $objp = $db->fetch_object($result); $bomtmp->id = $objp->rowid; $bomtmp->ref = $objp->ref; + $product = new Product($db); + if (!empty($objp->fk_product)) { + if (!array_key_exists($product->id, $product_cache)) { + $resultFetch = $product->fetch($objp->fk_product); + if ($resultFetch < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } else { + $product_cache[$product->id] = $product; + } + } + } + $bomtmp->fk_product = $objp->fk_product; $bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production'); + $bom_data_result[$objp->rowid]['product'] = (array_key_exists($objp->fk_product, $product_cache)? $product_cache[$objp->fk_product]->getNomUrl(1): ''); $bom_data_result[$objp->rowid]['qty_toproduce'] += ($objp->qty_toproduce > 0 ? $objp->qty_toproduce : 0); $bom_data_result[$objp->rowid]['qty_toconsume'] = 0; $bom_data_result[$objp->rowid]['date_valid'] = dol_print_date($db->jdate($objp->date_valid), 'dayhour'); @@ -180,7 +193,7 @@ if ($id > 0 || !empty($ref)) { $db->free($result); //Qauntity to consume - $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,"; + $sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid, b.fk_product,"; $sql .= " SUM(bl.qty) as qty_toconsume"; $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid"; @@ -214,9 +227,22 @@ if ($id > 0 || !empty($ref)) { $objp = $db->fetch_object($result); $bomtmp->id = $objp->rowid; $bomtmp->ref = $objp->ref; + $product = new Product($db); + if (!empty($objp->fk_product)) { + if (!array_key_exists($product->id, $product_cache)) { + $resultFetch = $product->fetch($objp->fk_product); + if ($resultFetch < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } else { + $product_cache[$product->id] = $product; + } + } + } + $bomtmp->fk_product = $objp->fk_product; if (!array_key_exists($objp->rowid, $bom_data_result)) { $bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production'); + $bom_data_result[$objp->rowid]['product'] = (array_key_exists($objp->fk_product, $product_cache)? $product_cache[$objp->fk_product]->getNomUrl(1): ''); $bom_data_result[$objp->rowid]['qty_toproduce'] = 0; $bom_data_result[$objp->rowid]['qty_toconsume'] += ($objp->qty_toconsume > 0 ? $objp->qty_toconsume : 0); $bom_data_result[$objp->rowid]['date_valid'] = dol_print_date($db->jdate($objp->date_valid), 'dayhour'); @@ -232,7 +258,6 @@ if ($id > 0 || !empty($ref)) { } $db->free($result); - if ($limit > 0 && $limit != $conf->liste_limit) { $option .= '&limit='.urlencode($limit); } @@ -265,6 +290,7 @@ if ($id > 0 || !empty($ref)) { print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "b.rowid", "", "&id=".$product->id, '', $sortfield, $sortorder); + print_liste_field_titre("Product", $_SERVER["PHP_SELF"], "b.fk_product", "", "&id=".$product->id, '', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "b.date_valid", "", "&id=".$product->id, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("RowMaterial", $_SERVER["PHP_SELF"], "", "", "&id=".$product->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Finished", $_SERVER["PHP_SELF"], "", "", "&id=".$product->id, '', $sortfield, $sortorder, 'center '); @@ -277,6 +303,9 @@ if ($id > 0 || !empty($ref)) { print ''; print $data['link']; print "\n"; + print ''; + print $data['product']; + print "\n"; print ""; print $data['date_valid'].""; print ''.$data['qty_toconsume'].''; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index abfd329dfa4..9f38f68ee33 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -49,8 +49,8 @@ $hookmanager->initHooks(array('productstatsorder')); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index e44619d1b19..0c569d3530c 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -46,8 +46,8 @@ $hookmanager->initHooks(array('productstatscontract')); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 8da6e97f55c..13c6329b34f 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -52,8 +52,8 @@ $showmessage = GETPOST('showmessage'); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index d61b6de9491..9db71e92148 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -50,8 +50,8 @@ $hookmanager->initHooks(array('productstatssupplierinvoice')); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index c63034e95a6..693f1fbae03 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -46,8 +46,8 @@ $hookmanager->initHooks(array('productstatsmo')); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index ffa593639b5..18a394559a3 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -54,8 +54,8 @@ $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); $ref = GETPOST('ref', 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (!$sortfield) { $sortfield = "p.ref"; } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index f9c0778eea4..ebe8f0552ce 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -75,8 +75,8 @@ $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ed5896ca6cc..405528a3480 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -84,14 +84,19 @@ $search_fk_projet=GETPOST("search_fk_projet", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $type = GETPOST("type", "int"); +// 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'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -if (empty($page) || $page == -1) { +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 +} $offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + if (!$sortfield) { $sortfield = "m.datem"; } @@ -103,8 +108,10 @@ $pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); -$hookmanager->initHooks(array('movementlist')); $extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('movementlist')); + $formfile = new FormFile($db); // fetch optionals attributes and labels @@ -156,6 +163,8 @@ if (!$user->rights->stock->mouvement->lire) { accessforbidden(); } +$uploaddir = $conf->stock->dir_output.'/movements'; + $permissiontoread = $user->rights->stock->mouvement->lire; $permissiontoadd = $user->rights->stock->mouvement->creer; $permissiontodelete = $user->rights->stock->mouvement->creer; // There is no deletion permission for stock movement as we shoul dnever delete @@ -172,7 +181,8 @@ $error = 0; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -185,9 +195,10 @@ if ($reshook < 0) { } if (empty($reshook)) { + // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Do we click on purge search criteria ? + // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers $search_date_startday = ''; $search_date_startmonth = ''; @@ -212,11 +223,92 @@ if (empty($reshook)) { $toselect = ''; $search_array_options = array(); } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions $objectclass = 'MouvementStock'; $objectlabel = 'MouvementStock'; - $uploaddir = $conf->stock->dir_output; + + if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { + if (empty($diroutputmassaction)) { + dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); + exit; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $objecttmp = new $objectclass($db); + $listofobjectid = array(); + foreach ($toselect as $toselectid) { + $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $listofobjectid[$toselectid] = $toselectid; + } + } + + $arrayofinclusion = array(); + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; + } + foreach ($listofobjectref as $tmppdf) { + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + } + $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); + + // Define output language (Here it is not used because we do only merging existing PDF) + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + //elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty + // $newlang = $objecttmp->thirdparty->default_lang; + //} + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + // Create output dir if not exists + dol_mkdir($diroutputmassaction); + + // Defined name of merged file + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename = preg_replace('/\s/', '_', $filename); + + // Save merged file + /* + if ($year) { + $filename .= '_'.$year; + } + if ($month) { + $filename .= '_'.$month; + } + */ + $now = dol_now(); + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; + + + // Create PDF + // TODO Create the pdf including list of movement ids found into $listofobjectid + // ... + + + if (!$error) { + $langs->load("exports"); + setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); + } + + $massaction = ''; + $action = ''; + } + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -482,6 +574,8 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tosell, p.tobuy, p.tobatch, p.fk_product_type as type, p.entity,"; $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,"; $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; @@ -499,7 +593,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; @@ -572,6 +667,31 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +/* If a group by is required + $sql .= " GROUP BY "; + foreach($object->fields as $key => $val) { + $sql .= "t.".$key.", "; + } + // Add fields from extrafields + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + } + } + // Add where from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql = preg_replace('/,\s*$/', '', $sql); + */ + +// Add HAVING from hooks +/* + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook + $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; + */ + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -589,20 +709,19 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + 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); } +// Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); } -//print $sql; - $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -624,20 +743,24 @@ if ($id > 0 || $ref) { $num = $db->num_rows($resql); -$arrayofselected = is_array($toselect) ? $toselect : array(); +// Output page +// -------------------------------------------------------------------- $i = 0; $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) { - $texte = $langs->trans('StockMovementForId', $msid); + $title = $langs->trans('StockMovementForId', $msid); } else { - $texte = $langs->trans("ListOfStockMovements"); + $title = $langs->trans("ListOfStockMovements"); if ($id) { - $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + $title .= ' ('.$langs->trans("ForThisWarehouse").')'; } } -llxHeader("", $texte, $help_url); + +llxHeader('', $title, $help_url); + +$arrayofselected = is_array($toselect) ? $toselect : array(); /* * Show tab only if we ask a particular warehouse @@ -774,26 +897,20 @@ if ($object->id > 0) { } -/* - * Correct stock - */ +// Correct stock if ($action == "correction") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stockcorrection.tpl.php'; print '
'; } -/* - * Transfer of units - */ +// Transfer of units if ($action == "transfert") { include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php'; print '
'; } -/* - * Action bar - */ +// Action bar if ((empty($action) || $action == 'list') && $id > 0) { print "
\n"; @@ -867,12 +984,11 @@ if ($idproduct > 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), -// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), -); -// By default, we should never accept deletion of stock movement. +$arrayofmassactions = array(); +if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + $arrayofmassactions['builddoc'] = img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("GeneratePDF"); +} +// By default, we should never accept deletion of stock movement if (!empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } @@ -881,7 +997,7 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -print '
'; +print ''."\n"; if ($optioncss != '') { print ''; } @@ -891,15 +1007,16 @@ print ''; print ''; print ''; print ''; +print ''; print ''; if ($id > 0) { print ''; } if ($id > 0) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } // Add code for pre mass action (confirmation or email presend form) @@ -919,7 +1036,7 @@ if ($sall) { $moreforfilter = ''; $parameters = array('arrayfields'=>&$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { @@ -934,12 +1051,14 @@ 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) : ''); -print '
'; -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search -print ''; +// -------------------------------------------------------------------- +print ''; if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } -// Actions +// Action column print ''; -print "\n"; +print ''."\n"; + +// Fields title label +// -------------------------------------------------------------------- print ''; if (!empty($arrayfields['m.rowid']['checked'])) { print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); @@ -1127,7 +1249,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['m.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); @@ -1135,32 +1257,39 @@ if (!empty($arrayfields['m.datec']['checked'])) { if (!empty($arrayfields['m.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } +// Action column print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); -print "\n"; +print ''."\n"; $arrayofuniqueproduct = array(); + +// Loop on record +// -------------------------------------------------------------------- $i = 0; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); +while ($i < ($limit ? min($num, $limit) : $num)) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } - $userstatic->id = $objp->fk_user_author; - $userstatic->login = $objp->login; - $userstatic->lastname = $objp->lastname; - $userstatic->firstname = $objp->firstname; - $userstatic->photo = $objp->photo; - $userstatic->email = $objp->user_email; - $userstatic->statut = $objp->user_status; + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_status; // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) { // If multilang is enabled // TODO Use a cache $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $objp->rowid); + $sql .= " WHERE fk_product = ".((int) $obj->rowid); $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; $sql .= " LIMIT 1"; @@ -1168,37 +1297,37 @@ while ($i < min($num, $limit)) { if ($result) { $objtp = $db->fetch_object($result); if (!empty($objtp->label)) { - $objp->produit = $objtp->label; + $obj->produit = $objtp->label; } } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->product_ref; - $productstatic->label = $objp->produit; - $productstatic->type = $objp->type; - $productstatic->entity = $objp->entity; - $productstatic->status = $objp->tosell; - $productstatic->status_buy = $objp->tobuy; - $productstatic->status_batch = $objp->tobatch; + $productstatic->id = $obj->rowid; + $productstatic->ref = $obj->product_ref; + $productstatic->label = $obj->produit; + $productstatic->type = $obj->type; + $productstatic->entity = $obj->entity; + $productstatic->status = $obj->tosell; + $productstatic->status_buy = $obj->tobuy; + $productstatic->status_batch = $obj->tobatch; - $productlot->id = $objp->lotid; - $productlot->batch = $objp->batch; - $productlot->eatby = $objp->eatby; - $productlot->sellby = $objp->sellby; + $productlot->id = $obj->lotid; + $productlot->batch = $obj->batch; + $productlot->eatby = $obj->eatby; + $productlot->sellby = $obj->sellby; - $warehousestatic->id = $objp->entrepot_id; - $warehousestatic->ref = $objp->warehouse_ref; - $warehousestatic->label = $objp->warehouse_ref; - $warehousestatic->lieu = $objp->lieu; - $warehousestatic->fk_parent = $objp->fk_parent; - $warehousestatic->statut = $objp->statut; + $warehousestatic->id = $obj->entrepot_id; + $warehousestatic->ref = $obj->warehouse_ref; + $warehousestatic->label = $obj->warehouse_ref; + $warehousestatic->lieu = $obj->lieu; + $warehousestatic->fk_parent = $obj->fk_parent; + $warehousestatic->statut = $obj->statut; - $movement->type = $objp->type_mouvement; + $movement->type = $obj->type_mouvement; - $arrayofuniqueproduct[$objp->rowid] = $objp->produit; - if (!empty($objp->fk_origin)) { - $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); + $arrayofuniqueproduct[$obj->rowid] = $obj->produit; + if (!empty($obj->fk_origin)) { + $origin = $movement->get_origin($obj->fk_origin, $obj->origintype); } else { $origin = ''; } @@ -1208,12 +1337,12 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['m.rowid']['checked'])) { print ''; // This is primary not movement id } if (!empty($arrayfields['m.datem']['checked'])) { // Date - print ''; + print ''; } if (!empty($arrayfields['p.ref']['checked'])) { // Product ref @@ -1237,10 +1366,10 @@ while ($i < min($num, $limit)) { print ''; } if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse if (!empty($arrayfields['e.ref']['checked'])) { @@ -1256,11 +1385,11 @@ while ($i < min($num, $limit)) { } if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code - print ''; + print ''; } if (!empty($arrayfields['m.label']['checked'])) { // Label of movement - print ''; + print ''; } if (!empty($arrayfields['origin']['checked'])) { // Origin of movement @@ -1269,8 +1398,8 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project print ''; } @@ -1283,14 +1412,14 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; @@ -1298,8 +1427,8 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } @@ -1307,25 +1436,26 @@ while ($i < min($num, $limit)) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'objp'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by 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"; + print ''."\n"; + $i++; } @@ -1365,6 +1495,26 @@ if (count($arrayofuniqueproduct) == 1 && is_numeric($year)) { //print ''; } +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} + // End of page llxFooter(); $db->close(); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 4f695f990e4..789b03aa6ce 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -58,8 +58,8 @@ $hookmanager->initHooks(array('productlotdocuments')); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 695e4356582..23e93aba785 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -623,7 +623,7 @@ if (empty($reshook)) { } print '
'; -print ''; +print ''; print '
'; print ''; diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 91ff0b40fbc..1eba8556753 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -37,11 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'replenishorders'; // To manage different context of search $sall = GETPOST('search_all', 'alphanohtml'); $sref = GETPOST('search_ref', 'alpha'); @@ -56,8 +52,8 @@ $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (!$sortorder) { $sortorder = 'DESC'; } @@ -70,6 +66,12 @@ if ($page < 0) { } $offset = $limit * $page; +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service'); + /* * Actions @@ -171,9 +173,10 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - print ''.$langs->trans("ReplenishmentOrdersDesc").'

'; + print ''; + print ''; - print ''; + print ''.$langs->trans("ReplenishmentOrdersDesc").'
'; print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); @@ -209,6 +212,7 @@ if ($resql) { $param .= '&optioncss='.urlencode($optioncss); } + print '
'; print '
'; @@ -1052,7 +1171,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['m.datec']['checked'])) { @@ -1064,13 +1183,16 @@ if (!empty($arrayfields['m.tms']['checked'])) { print ''; print ''; -$searchpicto = $form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print $objp->mid; + print $obj->mid; print ''.dol_print_date($db->jdate($objp->datem), 'dayhour', 'tzuserrel').''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''.dol_print_date($objp->eatby, 'day').''.dol_print_date($obj->eatby, 'day').''.dol_print_date($objp->sellby, 'day').''.dol_print_date($obj->sellby, 'day').'inventorycode.'$').'&search_type_mouvement='.urlencode($objp->type_mouvement).'">'.$objp->inventorycode.'inventorycode.'$').'&search_type_mouvement='.urlencode($obj->type_mouvement).'">'.$obj->inventorycode.''.$objp->label.''.$obj->label.''; - if ($objp->fk_project != 0) { - print $movement->get_origin($objp->fk_project, 'project'); + if ($obj->fk_project != 0) { + print $movement->get_origin($obj->fk_project, 'project'); } print ''; - if ($objp->qty > 0) { + if ($obj->qty > 0) { print ''; print '+'; - print $objp->qty; + print $obj->qty; print ''; } else { print ''; - print $objp->qty; + print $obj->qty; print ''; } print ''; - if ($objp->price != 0) { - print price($objp->price); + if ($obj->price != 0) { + print price($obj->price); } 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($objp->mid, $arrayofselected)) { + if (in_array($obj->mid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; } print '
'; print ''; @@ -347,6 +351,8 @@ if ($resql) { $i++; } print '
'; + print '
'; + print ''; $db->free($resql); diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 7f7f9610d1f..926b0c01634 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -36,8 +36,8 @@ $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); if (!$sortfield) { $sortfield = "e.ref"; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 32e8fc40381..b743dffbc53 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -77,8 +77,8 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_declared_progress = GETPOST('search_declared_progress', 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $monthofday = GETPOST('addtimemonth'); $dayofday = GETPOST('addtimeday'); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index f84a7112504..763ecefe650 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -77,8 +77,8 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_declared_progress = GETPOST('search_declared_progress', 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $startdayarray = dol_get_first_day_week($day, $month, $year); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index dac2afa4834..d0b27caf326 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -165,6 +165,11 @@ class Task extends CommonObject $this->label = trim($this->label); $this->description = trim($this->description); + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values @@ -384,6 +389,11 @@ class Task extends CommonObject $this->budget_amount = trim($this->budget_amount); } + if (!empty($this->date_start) && !empty($this->date_end) && $this->date_start > $this->date_end) { + $this->errors[] = $langs->trans('StartDateCannotBeAfterEndDate'); + return -1; + } + // Check parameters // Put here code to add control on parameters values diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 1bfbb9aa4a6..9e8d3a6ce8e 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -53,8 +53,8 @@ if ($id > 0 || !empty($ref)) { // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index e1f86bcffc9..51e78f23d57 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -56,8 +56,8 @@ if (!$user->rights->projet->lire) { accessforbidden(); } -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 4078afb20c0..6019011956a 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -198,6 +198,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; // Add non object fields to fields for list $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); +$arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); // Force some fields according to search_usage filter... if (GETPOST('search_usage_opportunity')) { @@ -911,7 +912,7 @@ if (!empty($arrayfields['p.public']['checked'])) { // Opp status if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; - print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); + print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100', 1); print ''; } if (!empty($arrayfields['p.opp_amount']['checked'])) { @@ -933,6 +934,10 @@ if (!empty($arrayfields['p.budget_amount']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['c.assigned']['checked'])) { + print ''; + print ''; +} if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print ''; print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1); @@ -1003,7 +1008,7 @@ if (!empty($arrayfields['p.fk_statut']['checked'])) { $arrayofstatus[$key] = $langs->trans($val); } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth150 selectarrowonleft'); + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth125 selectarrowonleft'); print ajax_combobox('search_status'); print ''; } @@ -1052,6 +1057,9 @@ if (!empty($arrayfields['opp_weighted_amount']['checked'])) { if (!empty($arrayfields['p.budget_amount']['checked'])) { print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); } +if (!empty($arrayfields['c.assigned']['checked'])) { + print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', ''); +} if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); } @@ -1312,6 +1320,41 @@ while ($i < min($num, $limit)) { $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; } } + // Contacts of project + if (!empty($arrayfields['c.assigned']['checked'])) { + print ''; + $ifisrt = 1; + foreach (array('internal', 'external') as $source) { + $tab = $object->liste_contact(-1, $source); + $numcontact = count($tab); + if (!empty($numcontact)) { + foreach ($tab as $contactproject) { + //var_dump($contacttask); + if ($source == 'internal') { + $c = new User($db); + } else { + $c = new Contact($db); + } + $c->fetch($contactproject['id']); + if (!empty($c->photo)) { + if (get_class($c) == 'User') { + print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); + } else { + print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); + } + } else { + if (get_class($c) == 'User') { + print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); + } else { + print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); + } + } + $ifisrt = 0; + } + } + } + print ''; + } // Usage opportunity if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print ''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index e8c938d2156..dc482c1c60c 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -811,9 +811,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam); print '
'; - if ($optioncss != '') { - print ''; - } + print ''; print ''; print ''; print ''; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index c60e3324741..155cb261040 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -46,8 +46,8 @@ $project_ref = GETPOST('project_ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 1553c58683f..697969c6060 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -115,8 +115,8 @@ if (!$user->rights->projet->lire) { $diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8feb682f023..8e773f92788 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -117,6 +117,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; } } } else { diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index f9f3a2aca43..bbf33b620c4 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -82,8 +82,8 @@ if (!$user->rights->projet->lire) { } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 80e092f2951..4bf2a6b94bf 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -92,8 +92,8 @@ function llxFooterVierge() } -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index cb2458de4ff..3aaa3676663 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -62,6 +62,8 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", // Get parameters $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + $refusepropal = GETPOST('refusepropal', 'alpha'); $message = GETPOST('message', 'aZ09'); @@ -148,7 +150,7 @@ if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) { * Actions */ -if ($action == 'confirm_refusepropal') { +if ($action == 'confirm_refusepropal' && $confirm == 'yes') { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; @@ -213,6 +215,7 @@ print ''."\n print ''."\n"; print ''."\n"; print ''; +print ''; print "\n"; print ''."\n"; @@ -336,18 +339,28 @@ if ($source == 'proposal') { } } else { $last_main_doc_file = $proposal->last_main_doc; - if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed - $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file); - $datefilesigned = dol_filemtime($last_main_doc_file); - $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed); + if ($proposal->status == $proposal::STATUS_NOTSIGNED) { + $directdownloadlink = $proposal->getLastMainDocLink('proposal'); + if ($directdownloadlink) { + print '
'; + print img_mime($proposal->last_main_doc, ''); + print $langs->trans("DownloadDocument").''; + } + } elseif ($proposal->status == $proposal::STATUS_SIGNED || $proposal->status == $proposal::STATUS_BILLED) { + if (preg_match('/_signed-(\d+)/', $last_main_doc_file)) { // If the last main doc has been signed + $last_main_doc_file_not_signed = preg_replace('/_signed-(\d+)/', '', $last_main_doc_file); - if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { - $directdownloadlink = $proposal->getLastMainDocLink('proposal'); - if ($directdownloadlink) { - print '
'; - print img_mime($proposal->last_main_doc, ''); - print $langs->trans("DownloadDocument").''; + $datefilesigned = dol_filemtime($last_main_doc_file); + $datefilenotsigned = dol_filemtime($last_main_doc_file_not_signed); + + if (empty($datefilenotsigned) || $datefilesigned > $datefilenotsigned) { + $directdownloadlink = $proposal->getLastMainDocLink('proposal'); + if ($directdownloadlink) { + print '
'; + print img_mime($proposal->last_main_doc, ''); + print $langs->trans("DownloadDocument").''; + } } } } @@ -392,6 +405,7 @@ if ($action == "dosign" && empty($cancel)) { print ''; print '
'; print '
'; + // Do not use class="reposition" here: It breaks the submit and there is a message on top to say it's ok, so going back top is better. print ''; print ''; @@ -459,7 +473,7 @@ if ($action == "dosign" && empty($cancel)) { } } else { print ''; - print ''; + print ''; } } } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index ef16b716db2..8a353eea881 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -294,8 +294,8 @@ if ($action == "view_ticketlist") { require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); + $sortorder = GETPOST('sortorder', 'aZ09comma'); if (!$sortfield) { $sortfield = 't.datec'; diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index 9093f645e48..f592dba452a 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -47,8 +47,8 @@ $ref = GETPOST('ref'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 00c59e47336..70775e112f6 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -75,7 +75,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $contextpage = 'receptionlist'; -$search_status = GETPOST('search_status'); +$search_status = GETPOST('search_status', 'intcomma'); $object = new Reception($db); diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php new file mode 100644 index 00000000000..e0c2cb5da11 --- /dev/null +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -0,0 +1,647 @@ + + * + * 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 . + */ + +use Luracast\Restler\RestException; + +dol_include_once('/recruitment/class/recruitmentjobposition.class.php'); +dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); + + + +/** + * \file recruitment/class/api_recruitment.class.php + * \ingroup recruitment + * \brief File for API management of recruitment. + */ + +/** + * API class for recruitment + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Recruitment extends DolibarrApi +{ + /** + * @var jobposition $jobposition {@type jobposition} + */ + public $jobposition; + public $candidature; + + /** + * Constructor + * + * @url GET / + * + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->jobposition = new RecruitmentJobPosition($this->db); + $this->candidature = new RecruitmentCandidature($this->db); + } + + /** + * Get properties of a jobposition object + * + * Return an array with jobposition informations + * + * @param int $id ID of jobposition + * @return array|mixed data without useless information + * + * @url GET jobposition/{id} + * + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found + */ + public function getJobPosition($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'JobPosition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->jobposition); + } + + /** + * Get properties of a candidature object + * + * Return an array with candidature informations + * + * @param int $id ID of candidature + * @return array|mixed data without useless information + * + * @url GET candidature/{id} + * + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found + */ + public function getCandidature($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'Candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->candidature); + } + + + /** + * List jobpositions + * + * Get a list of jobpositions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /jobposition/ + */ + public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + $tmpobject = new RecruitmentJobPosition($this->db); + + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } + $sql .= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".((int) $socid); + } + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".((int) $search_sale); + } + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit + 1, $offset); + } + + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $tmp_object = new RecruitmentJobPosition($this->db); + if ($tmp_object->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No jobposition found'); + } + return $obj_ret; + } + + /** + * List candatures + * + * Get a list of candidatures + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + * + * @url GET /candidature/ + */ + public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + $tmpobject = new RecruitmentCandidature($this->db); + + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->read) { + throw new RestException(401); + } + + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; + + $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t"; + + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } + $sql .= " WHERE 1 = 1"; + + // Example of use $mode + //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; + //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; + + if ($tmpobject->ismultientitymanaged) { + $sql .= ' AND t.entity IN ('.getEntity($tmpobject->element).')'; + } + if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($restrictonsocid && $socid) { + $sql .= " AND t.fk_soc = ".((int) $socid); + } + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } + // Insert sale filter + if ($restrictonsocid && $search_sale > 0) { + $sql .= " AND sc.fk_user = ".((int) $search_sale); + } + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit + 1, $offset); + } + + $result = $this->db->query($sql); + $i = 0; + if ($result) { + $num = $this->db->num_rows($result); + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $tmp_object = new RecruitmentCandidature($this->db); + if ($tmp_object->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No candidature found'); + } + return $obj_ret; + } + + /** + * Create jobposition object + * + * @param array $request_data Request datas + * @return int ID of jobposition + * + * @throws RestException + * + * @url POST jobposition/ + */ + public function postJobPosition($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach ($request_data as $field => $value) { + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->jobposition->create(DolibarrApiAccess::$user)<0) { + throw new RestException(500, "Error creating jobposition", array_merge(array($this->jobposition->error), $this->jobposition->errors)); + } + return $this->jobposition->id; + } + + /** + * Create candidature object + * + * @param array $request_data Request datas + * @return int ID of candidature + * + * @throws RestException + * + * @url POST candidature/ + */ + public function postCandidature($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach ($request_data as $field => $value) { + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->candidature->create(DolibarrApiAccess::$user)<0) { + throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); + } + return $this->candidature->id; + } + + /** + * Update jobposition + * + * @param int $id Id of jobposition to update + * @param array $request_data Datas + * @return int + * + * @throws RestException + * + * @url PUT jobposition/{id} + */ + public function putJobPosition($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'jobposition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->jobposition->$field = $this->_checkValForAPI($field, $value, $this->jobposition); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->jobposition->update(DolibarrApiAccess::$user, false) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->jobposition->error); + } + } + + /** + * Update candidature + * + * @param int $id Id of candidature to update + * @param array $request_data Datas + * @return int + * + * @throws RestException + * + * @url PUT candidature/{id} + */ + public function putCandidature($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->write) { + throw new RestException(401); + } + + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->candidature->$field = $this->_checkValForAPI($field, $value, $this->candidature); + } + + // Clean data + // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + + if ($this->candidature->update(DolibarrApiAccess::$user, false) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->candidature->error); + } + } + + + /** + * Delete jobposition + * + * @param int $id jobposition ID + * @return array + * + * @throws RestException + * + * @url DELETE jobposition/{id} + */ + public function deleteJobPosition($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) { + throw new RestException(401); + } + $result = $this->jobposition->fetch($id); + if (!$result) { + throw new RestException(404, 'jobposition not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->jobposition->id, 'recruitment_recruitmentjobposition')) { + throw new RestException(401, 'Access to instance id='.$this->jobposition->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (!$this->jobposition->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting jobposition : '.$this->jobposition->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'jobposition deleted' + ) + ); + } + + /** + * Delete candidature + * + * @param int $id candidature ID + * @return array + * + * @throws RestException + * + * @url DELETE candidature/{id} + */ + public function deleteCandidature($id) + { + if (!DolibarrApiAccess::$user->rights->recruitment->recruitmentjobposition->delete) { + throw new RestException(401); + } + $result = $this->candidature->fetch($id); + if (!$result) { + throw new RestException(404, 'candidature not found'); + } + + if (!DolibarrApi::_checkAccessToResource('recruitment', $this->candidature->id, 'recruitment_recruitmentcandidature')) { + throw new RestException(401, 'Access to instance id='.$this->candidature->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (!$this->candidature->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting candidature : '.$this->candidature->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'candidature deleted' + ) + ); + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); + + unset($object->rowid); + unset($object->canvas); + + /*unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->statut); + unset($object->state); + unset($object->state_id); + unset($object->state_code); + unset($object->region); + unset($object->region_code); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_account); + unset($object->comments); + unset($object->note); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->shipping_method_id); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + */ + + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) { + $this->_cleanObjectDatas($object->lines[$i]); + + unset($object->lines[$i]->lines); + unset($object->lines[$i]->note); + } + } + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array of data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $jobposition = array(); + foreach ($this->jobposition->fields as $field => $propfield) { + if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) { + continue; // Not a mandatory field + } + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $jobposition[$field] = $data[$field]; + } + return $jobposition; + } +} diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 79795472b4e..9cc259c21e1 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -81,8 +81,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index dcd29c88118..792b413b5e4 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -71,8 +71,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index 4c3e642a224..3f9e76d4dcf 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -81,8 +81,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index 14355aeb0e3..e9615777ade 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -71,8 +71,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index bf300141bc4..363f334a7eb 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -55,8 +55,8 @@ if (GETPOST('actioncode', 'array')) { $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 025ec2fbf70..97d55c7bb33 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -38,7 +38,7 @@ $element = GETPOST('element', 'alpha'); $element_id = GETPOST('element_id', 'int'); $resource_id = GETPOST('resource_id', 'int'); -$sortorder = GETPOST('sortorder', 'alpha'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index ec59482b345..1aa7093299d 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -52,8 +52,8 @@ if ($user->socid) { $result = restrictedArea($user, 'societe', $socid, '&societe'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 7edd00db4d5..9dfe3909393 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -44,7 +44,7 @@ if (!defined('NOCSRFCHECK')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -$htmlname = GETPOST('htmlname', 'alpha'); +$htmlname = GETPOST('htmlname', 'aZ09'); $filter = GETPOST('filter', 'alpha'); $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); $action = GETPOST('action', 'aZ09'); @@ -102,7 +102,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // Filter on the company to search can be: // Into an array with key $htmlname123 (we take first one found). Which page use this ? // Into a var with name $htmlname can be 'prodid', 'productid', ... - $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.preg_quote($htmlname, '/').'[0-9]+)/', array_keys($_GET)); sort($match); $id = (!empty($match[0]) ? $match[0] : ''); // Take first key found into GET array with matching $htmlname123 diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d75d9256b34..b6c483fc026 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1765,10 +1765,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('name')) { // We overwrite with values if posted $object->name = GETPOST('name', 'alphanohtml'); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->name_alias = GETPOST('name_alias', 'alphanohtml'); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); $object->client = GETPOST('client', 'int'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur', 'int'); + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur', 'int'); $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); $object->address = GETPOST('address', 'alphanohtml'); $object->zip = GETPOST('zipcode', 'alphanohtml'); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 315bdb9af13..7490fca0265 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -554,13 +554,14 @@ class Societe extends CommonObject * Accounting code for client * @var string */ - public $code_compta; + public $code_compta_client; /** - * Accounting code for client + * Duplicate of code_compta_client (for backward compatibility) * @var string */ - public $code_compta_client; + public $code_compta; + /** * Accounting code for customer @@ -580,6 +581,14 @@ class Societe extends CommonObject */ public $accountancy_code_supplier; + + /** + * Accounting code for product (for level 3 of suggestion of prouct accounting account) + * @var string + */ + public $code_compta_product; + + /** * @var string * @deprecated Note is split in public and private notes @@ -1822,7 +1831,8 @@ class Societe extends CommonObject $this->code_client = $obj->code_client; $this->code_fournisseur = $obj->code_fournisseur; - $this->code_compta = $obj->code_compta; + $this->code_compta = $obj->code_compta; // For backward compatibility + $this->code_compta_client = $obj->code_compta; $this->code_compta_fournisseur = $obj->code_compta_fournisseur; $this->barcode = $obj->barcode; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index d9abbd61c22..596f9b6f3c6 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -47,8 +47,8 @@ if ($socid > 0) { // Sort & Order fields $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 9ce01c64638..707c573f116 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -41,8 +41,8 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index dbb380bd405..da056ec33da 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -111,8 +111,8 @@ $place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is $diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) { $sortorder = "ASC"; diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 4ed16e948c5..8729ed3b46e 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -45,8 +45,8 @@ if ($user->socid) { $result = restrictedArea($user, 'societe', '', ''); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) { $sortorder = "DESC"; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 72246fdf9cb..75818a34f72 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -245,8 +245,8 @@ print dol_get_fiche_end(); if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($db); - $sortfield = GETPOST("sortfield", 'alpha'); - $sortorder = GETPOST("sortorder", 'alpha'); + $sortfield = GETPOST('sortfield', 'aZ09comma'); + $sortorder = GETPOST('sortorder', 'aZ09comma'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index d0511d53a1f..82d815f0ac4 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -40,8 +40,8 @@ $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) { $sortorder = "ASC"; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 108a4bdf34a..bc93d72d60e 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -43,8 +43,6 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'web $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$search_status = GETPOST('search_status'); - // Security check $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); if ($user->socid) { @@ -53,8 +51,8 @@ if ($user->socid) { $result = restrictedArea($user, 'societe', $socid, '&societe'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index c6a07593a04..49db54b444f 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -42,8 +42,8 @@ if ($user->socid) { $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index a520e83f0ee..18ebce96f8b 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -607,9 +607,6 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } - if (!empty($conf->global->STRIPE_KLARNA)) { - $paymentmethodtypes[] = "klarna"; - } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 75c24ef0561..34b4ea1dc4f 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -42,8 +42,8 @@ if ($user->socid) { $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 0d43c830e8e..6bab8459d18 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -42,8 +42,8 @@ if ($user->socid) { $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 884519a4f9a..fa73ec22fa8 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -52,8 +52,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id); // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 1a1110fba1c..ad35c8f9914 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -103,8 +103,8 @@ $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6cfbf4b3c1a..58c1906cd42 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -53,6 +53,8 @@ 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')); /* * View @@ -109,13 +111,30 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p'; + $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; + + // 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; + $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'; $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; + $resql = $db->query($sql); if ($resql) { $rows = array(); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 2c44acdaae2..0b159e96a38 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -335,7 +335,11 @@ function LoadProducts(position, issubcat) { var titlestring = ; global->TAKEPOS_HIDE_PRODUCT_IMAGES) { echo '$("#prodivdesc"+ishow).show();'; - echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + if ($conf->global->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 '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; } else { @@ -401,7 +405,12 @@ function MoreProducts(moreorless) { else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); + + $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#probutton"+ishow).text(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { @@ -579,7 +588,12 @@ function Search2(keyCodeForEnter) { $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']"; ?> var titlestring = ; - $("#prodesc" + i).text(data[i]['label']); + global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> + $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).text(data[i]['label']); + $("#prodivdesc" + i).show(); $("#probutton" + i).text(data[i]['label']); $("#probutton" + i).show(); @@ -1203,11 +1217,15 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) { } ?>"> -
- + global->TAKEPOS_HIDE_CATEGORIES == 1) { + print '