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/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/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/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/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.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/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/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..4713542bf5b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1169,23 +1169,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); @@ -5318,7 +5329,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..4da32edd666 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -844,7 +844,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } 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") . '
'; print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); $total_budget_amount += $lines[$i]->budget_amount; @@ -856,8 +856,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t print ''; 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') { 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/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/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/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..1597ee32c18 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,6 +174,7 @@ class pdf_standard extends ModelePDFStock $this->postotalht -= 20; } $this->tva = array(); + $this->tva_array = array(); $this->localtax1 = array(); $this->localtax2 = array(); $this->atleastoneratenotnull = 0; @@ -290,7 +292,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 +321,7 @@ class pdf_standard extends ModelePDFStock $i = 0; $nblines = $num; - $this->tabTitleHeight = 0; + $this->tabTitleHeight = 10; $nexY = $tab_top + $this->tabTitleHeight; for ($i = 0; $i < $nblines; $i++) { @@ -357,14 +359,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 +421,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 +509,7 @@ class pdf_standard extends ModelePDFStock /** * Footer table */ - $nexY = $pdf->GetY(); + //$nexY = $pdf->GetY(); $nexY += 2; $curY = $nexY; @@ -569,11 +573,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 +730,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 + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); + $pdf->SetLineStyle(array('dash' => 0)); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore 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..913b7b08a55 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.'}'; @@ -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..83b737a050e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3008,10 +3008,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 +3043,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/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index fa58139b7e7..de9aa4eade9 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -93,7 +93,7 @@ class PaiementFourn extends Paiement $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as payment_code, c.libelle as payment_type,'; - $sql .= ' p.num_paiement as num_payment, p.note, b.fk_account'; + $sql .= ' p.num_paiement as num_payment, p.note, b.fk_account, p.fk_paiement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; @@ -130,6 +130,7 @@ class PaiementFourn extends Paiement $this->note_private = $obj->note; $this->type_code = $obj->payment_code; $this->type_label = $obj->payment_type; + $this->fk_paiement = $obj->fk_paiement; $this->statut = $obj->statut; $error = 1; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 88469e6d01a..af7950b0a35 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -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 = ''; 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 4c634e1c1db..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']); @@ -1325,6 +1327,8 @@ if (empty($reshook)) { unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); + unset($_POST['price_ttc']); + unset($_POST['price_ht']); $db->commit(); } else { @@ -1353,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); @@ -1453,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; @@ -1463,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 } @@ -1513,7 +1525,7 @@ if (empty($reshook)) { $array_options, $productsupplier->fk_unit, 0, - $pu_ht_devise, + $pu_devise, $ref_supplier, '' ); @@ -1555,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; @@ -1954,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 '